Before you ship a rate-limiting policy, it helps to see exactly what your API will tell clients. This
tool simulates a stream of requests against a fixed-window limiter and prints the precise
X-RateLimit-* and Retry-After header values for every request — so you can verify the policy and
explain it in your docs.
How it works
The simulator implements a fixed-window counter. Time is divided into windows of the duration
you set. Within each window the limiter allows up to an effective cap equal to your base limit
plus any burst allowance, and reports that cap in X-RateLimit-Limit.
For each simulated request at time t:
- Determine which window
tfalls in; if it has crossed into a new window, reset the counter to 0. - If the in-window count is below the cap, the request returns 200 OK, the counter increments,
and
X-RateLimit-Remainingbecomescap - count. - If the cap is reached, the request returns 429 Too Many Requests,
X-RateLimit-Remainingis0, andRetry-Afteris set to the number of whole seconds until the window resets (rounded up).
X-RateLimit-Reset is shown here as the seconds remaining until the current window ends; in
production you may emit it as an absolute Unix timestamp instead.
Example
With a limit of 5 per 10 seconds, no burst, and a client sending one request per second: requests
1–5 return 200 with remaining counting down 4, 3, 2, 1, 0; requests 6–10 return 429 with
Retry-After shrinking as the window reset approaches; at t = 10s the window resets and request 11
returns 200 again.
Notes and tips
- Always return
Retry-Afteron a 429 so well-behaved clients back off instead of hammering you. - Fixed windows can permit a burst of up to
2 × limitstraddling a window boundary. If you need smoother enforcement, use a token bucket or sliding-window log. - Document your headers publicly. Clients that read
X-RateLimit-Remainingcan pace themselves and generate far fewer 429s. - Apply limits at the identity that matters (API key, user, or IP) and consider separate, tighter limits for expensive endpoints like search or auth.