Skip to content

Load Testing Paginated and Rate-Limited APIs

Test pagination and API quotas without retry storms by modeling cursors, 429 behavior, backoff, fairness, and client versus server limits.

Cursor-following pagination chain above a bar chart of requests against a quota, comparing an immediate retry storm of 429s with Retry-After backoff

Paginated and rate-limited APIs make the client decide things. It follows a cursor or page token, stops when the collection ends, and reacts to a quota signal without starting a retry storm. A test that sends the first page over and over, or treats every 429 as a generic error, measures neither the product journey nor the protection policy.

Design the workload around both sides of the contract. The server owns page size, cursors, quotas, and response headers. The client owns pacing, concurrency, retries, and how it shows partial progress. Test how they interact with named scenarios.

Model pagination as a state machine

Start with one page, then carry the returned cursor into the next request. Assert that a cursor exists when more data is expected, that the page advances, and that the flow stops at the documented end condition. Cap the pages per virtual user so a malformed response cannot start an endless loop.

Use realistic page sizes and filters. A small page can raise the request count. A large page can raise response size, serialization, and database work. Test the distribution your customers use, plus a bounded edge case if the API allows it. Do not compare a candidate that uses a different page mix as if it were the same workload.

The correlation guide covers carrying cursors and IDs safely. A cursor is a dependency. Do not hard-code it as a string in a fixture.

Distinguish client and server limits

A server quota may apply per user, token, tenant, IP, route, or shared account. A client may also limit itself to protect its own resources. Identify the key and the scope for each scenario. A test with one shared credential can trip a global quota and tell you little about fairness between users.

Use several named actors where the product promises isolation. Add a noisy actor next to ordinary actors only when you are testing fairness or protection. Measure accepted requests, rejected requests, reset timing, and the effect on actors that should be unaffected. If a rate limit protects one tenant by starving every other tenant, that is a policy question as well as a throughput result.

Keep quota headers and retry hints visible in bounded diagnostics. Do not log tokens. Record the status class and the client’s decision, so a 429 from an expected ceiling stays distinct from a 429 that arrives unexpectedly under ordinary, permitted traffic.

Test 429 behavior deliberately

Set up a controlled quota case with a safe target and explicit stop conditions. Check that the client recognizes the 429 response, waits as the contract says, and limits its attempts. Test a single actor and concurrent actors if sharing is part of the design.

A retry is extra work. Count original attempts, retries, successful operations, and final failures separately. If every request is replayed several times, a lower final error rate can hide higher latency and more load on dependencies. The error analysis guide explains why recovered calls need their own labels.

Test missing, malformed, and conflicting retry hints as negative cases only where the client has a defined policy. Do not invent a server behavior and present it as a product fact. The point is to check that the client fails within bounds when the contract is incomplete.

Preserve pagination correctness under concurrency

Two users can page through the same changing collection and see different pages. Decide whether the product promises a snapshot, cursor consistency, or best-effort traversal, and use fixtures that make the promise observable. If records are inserted or removed during the run, label that as a separate consistency experiment.

Do not assert a fixed global item count when the system is changing on purpose. Assert no duplicates within one user’s traversal, correct ordering where promised, and a bounded end condition. For a stable fixture, stronger item-level checks make sense.

Writes that create or update records can invalidate cursors. Keep mutation and traversal scenarios apart unless the user journey mixes them. If it does, name the expected relationship and clean up safely.

Measure the expensive parts

Track page latency, response size, item count, cursor extraction failures, status classes, quota responses, retry delay, and completion time. Where you can, watch database scans, cache behavior, serialization, and network transfer. A page can be slow because it fetches too much, with rate limiting playing no part.

Watch client pacing and generator health. A worker that cannot sleep, schedule, or hold connections changes the offered request rate. The test should report how many requests it intended to send and how many it sent.

Decide on fairness and backoff

Write success criteria before the run. A pagination baseline may require complete traversal, no duplicates, and a latency budget per page. A quota test may require the expected 429 boundary, bounded retries, and normal service for ordinary actors. A resilience test may look at recovery after the limit resets.

Make backoff observable. Do not infer it from low throughput. Record delay ranges and attempt counts, and make sure the client does not fire every retry at the same instant. If synchronized recovery is a real risk, test it as a named burst with authorization and a stop condition.

Keep the result honest

Show the traversal state in the result. Record the starting cursor or page, items seen, pages completed, throttles received, backoff applied, and the final reason for stopping. Set a deliberate ceiling on pages and retries so a malformed response cannot trap the client in an unbounded loop. Test a normal quota response, a quota boundary, a 429 with a valid retry hint, and a server error without a retry hint as separate cases. You are not trying to maximize retries. You are checking that the client protects the service and still makes the progress its contract promises. When several virtual users share a quota, label the fairness assumption and check whether one identity uses up the budget meant for another. A bounded, stateful result explains both client correctness and server protection without creating a retry storm.

Report the API route, actor scope, page distribution, quota key, retry policy, fixture state, and expected outcomes. Link the run to the client version and the policy configuration. If the test used a stubbed quota service or a private route, say so.

For a decision review, split the work into three runs: ordinary pagination under the quota, a deliberate quota-boundary case, and a recovery case after the limit resets. The first should show complete traversal. The second should show the expected protective response with bounded attempts. The third should show controlled progress instead of synchronized replay. Folding them into one total error rate makes each conclusion harder to trust.

Keep the quota key and actor mix in the artifact. A result from one shared token does not generalize to many independent tenants, and a result from many tenants cannot prove a single user’s burst policy. State the scope plainly, then pick the next experiment if fairness or isolation is still open.

Also record where traversal stopped and why. “Completed” should mean the client reached the documented end condition. A last request that happened to return a transport success does not count. A bounded report of pages visited, items seen, retries, and final status lets you diagnose a partial result without keeping every response body.