Fixed window rate limiting: one counter, reset on the clock

Fixed window rate limiting cuts time into equal blocks, counts a client's requests inside the current block, and refuses the ones that pass the limit. At the end of the block the count goes back to zero. It is the simplest limiter to build and the cheapest to run, and it has one well-known flaw: a client can spend two allowances back to back across the reset.

Section Rate limiting Updated State one counter per key

Quick facts

State
One counter per key and per window; the Redis tutorial rates the memory at one key per client (Redis tutorial on five rate limiters)
Strength
Minimal memory, simple logic, one round trip to the store (Redis tutorial on five rate limiters)
Weakness
Boundary bursts: up to twice the limit at the edge of a window (Redis tutorial on five rate limiters)
Typical store pattern
INCR the counter, set an expiry on the first hit; Redis shows it with a limit of ten requests per second per IP address (Redis INCR reference)
Refusal
429 Too Many Requests, optionally with Retry-After, which RFC 6585 says a server may include (RFC 6585, section 4)
Neighbours
The sliding window moves the period with the clock; token bucket and leaky bucket control the shape of arrivals instead of counting blocks

The four common algorithms are compared on rate limiting algorithms. This page goes deeper on the first of them.

How the counter works

The idea fits in three lines. Pick a window length, such as 60 seconds. Work out which window the current moment falls in. Add one to that window's counter, and refuse the request if the result is over the limit. A new window means a new counter, so nothing has to be cleared by hand.

fixed window counter, pseudocode
on request(key):
    w = floor(now / WINDOW)           # which block we are in
    count = increment(key + ":" + w)  # first hit creates it at 1
    if count == 1:
        set_expiry(key + ":" + w, WINDOW)
    if count <= LIMIT:
        return allow
    return refuse(retry_after = (w + 1) * WINDOW - now)

The Redis documentation describes two ways to build this with INCR. The first keeps a counter for every IP address for every different second, and each call increments it and sets a ten-second expiry inside one MULTI/EXEC block, so old counters remove themselves. The second keeps a single counter per IP address whose expiry is set when the first request arrives, so the window runs from that first request instead of from the clock. Both examples in the reference limit API calls to ten requests per second per IP address (source).

That difference matters for the next section. A clock-aligned window resets for every client at the same instant. A window that starts at the first request resets at a moment that depends on when each client began, which is harder to see from outside, but the structure is the same: a counter, a deadline, a reset.

The boundary double burst

The Redis tutorial states the flaw plainly: a fixed window is susceptible to boundary bursts. A client could send 10 requests at second 9 and 10 more at second 11, which is 20 requests in 2 seconds, while staying inside a limit of 10 per 10 seconds, because the requests straddle two windows (source).

The same arithmetic works at any scale [derived]. With a limit of 100 per minute, 100 requests at 12:00:59 and 100 more at 12:01:00 are 200 requests inside two seconds, and the counter never refuses one of them. More generally, any stretch of time as long as one window can overlap at most two blocks, so it can contain up to twice the limit.

Limit of 100 per 60-second window, clock-aligned [derived]
MomentRequests sentCounter of that windowOutcome
12:00:59, window 12:00100100All allowed
12:01:00, window 12:01100100 (fresh counter)All allowed
Across the two seconds200none holds bothTwice the stated rate

Does it matter? That depends on what the limit protects. For fairness between users it is a nuisance. For a service sized for the stated rate, the doubled burst is the very event the limit was meant to prevent. And the reset time is predictable, so a script can learn it and wait. A client that is merely busy will rarely hit the edge on purpose; one that is probing will.

The fix is not a smaller window, which only moves the edge closer. Counting over a moving period removes it: see sliding window rate limiting. If bursts are normal and you want to say so out loud, a token bucket states the allowance directly, and the leaky bucket algorithm smooths arrivals instead. Bursts and rate limits covers why the shape of traffic matters more than its average.

What the client is told

A refused request should say so in a way software can act on. The status for it is 429 Too Many Requests, defined in RFC 6585. The RFC says the response may include a Retry-After header indicating how long to wait before a new request, and it adds that the specification does not define how the origin server identifies the user or counts requests. So the choice of key and of window is yours, not the standard's. Which key to count is its own decision, covered in limiting by IP, user or API key.

The Retry-After header is defined in RFC 9110, section 10.2.3. Its value is either an HTTP-date or a number of seconds to delay after receiving the response, and the number is a non-negative decimal integer. A fixed window has a convenient property here: the reset moment is known exactly, so the honest value is the time left in the current window. The Redis tutorial's example reads the remaining time to live of the counter key for this purpose.

There is also a draft for announcing the policy itself. The IETF HTTPAPI working group's RateLimit header fields for HTTP defines two fields, RateLimit-Policy for the quota a server applies and RateLimit for the current limit, and states that the time window is a non-zero integer number of seconds. The datatracker page listed it as an active Internet-Draft, version 11, on 4 Nov 2026. It is not an RFC, so treat the field names as provisional. The Redis tutorial makes a related point about the older X-RateLimit-* headers: they are only common patterns, and there is no single standard.

Keeping the count correct

Counting is easy; counting under concurrency is where mistakes creep in. The Redis reference flags a race in its single-counter version: if the client performs INCR but never gets to EXPIRE, the key is leaked until the same address is seen again. The documented fix is to run the increment and the conditional expiry as one Lua script sent with EVAL (source). The Redis tutorial makes the same choice for all its limiters, so that the read, decision and write cannot interleave with another client.

Three smaller points follow from the design [derived]:

  • Do you want refused requests to count? Incrementing before checking, as the pseudocode above does, makes a client who keeps hammering a closed window keep growing its counter. That is harmless for the decision but it is worth knowing when you read the numbers later.
  • Clock-aligned keys need every node to agree about the time. A few seconds of skew between servers moves the reset by a few seconds, which is another reason counts across machines drift; distributed rate limits goes into it.
  • Counters created per key live as long as the expiry says. A large number of one-off keys is a memory question the expiry has to answer.

If the limiter is already part of a proxy, nginx rate limiting shows what a configured limit looks like in practice.

When a fixed window is enough

The Redis tutorial recommends it when simplicity matters most and occasional boundary bursts can be tolerated, and lists basic API limits, login throttling and internal services where approximate enforcement is acceptable. That is a vendor view, not a rule, but the reasoning is sound: one counter is the least state any limiter can keep.

Three questions settle most cases:

  • What is the worst thing that happens if a client sends twice the limit across a reset?
  • Is the reset moment something a client could exploit, or merely stumble over?
  • Is the count more important than the exact moment a client may retry?

If the honest answer to the first is "nothing much", a fixed window is fine and the saved complexity is real. If it is "the database falls over", use a method that counts a moving period, and test it before enforcing it; testing a rate limit shows how.

Where a WAF helps and where it does not

A rate limit sees requests and a key, nothing more. It cannot tell a customer who pressed refresh four times from a script, and a fixed window will refuse both once the counter passes the limit. It also does not read request bodies for attacks; that is the work of filtering rules, a separate layer. What a limit does well is bound how much any one key can ask of an origin in a period, and a fixed window does that with the weak edge described above.

Picking a window and a limit blind is how real users get refused. Run the rule first in a mode that records what it would have refused, read the log for who and how often, and only then let it refuse anything. That order is the point of monitor mode: off does nothing, monitor records and serves every request, block refuses and records.

Bridge WAF applies rate limiting per domain, with three modes: off, monitor and block. This page does not state which counting method any part of the platform uses, and nothing here is a claim about live protection.

Questions

What is a fixed window rate limit?

A limit that divides time into equal blocks, keeps one counter per block and refuses requests once the counter passes the limit. When the block ends the counter starts again from zero, so a client gets a fresh allowance at every reset.

What is the boundary burst in a fixed window?

Because the counter resets at a set moment, a client can spend a full allowance just before the reset and another full allowance just after it. With a limit of 10 per 10 seconds, 10 requests at second 9 and 10 more at second 11 are 20 requests in 2 seconds, and both bursts stay within the rule. Redis documents this as a burst of up to twice the limit at the window edge.

When is a fixed window good enough?

When simplicity and low memory matter more than precision at the edges: basic API quotas, login throttling, internal services where approximate enforcement is acceptable. It is a poor fit when the system behind the limit is sized for the stated rate and cannot absorb a doubled burst.

Should a fixed window limiter send Retry-After?

It can, and the value is cheap to compute, because the reset moment is known: the time left in the current window. RFC 6585 says a 429 response may include Retry-After, and RFC 9110 defines the value as either an HTTP-date or a number of seconds. Sending it is optional.

Does this page say which algorithm Bridge WAF uses?

No. Bridge WAF applies rate limiting per domain with three modes: off, monitor and block. This page explains the fixed window in general and does not state which counting method any part of the platform uses.