Back to Blog
We use this to reply to you. Privacy policy
DDoSDDoS TestingRate LimitingAPI GatewayLayer 7

Rate Limit Testing Under DDoS: Where the Counter Lives

BlackNeuron Research Team
November 26, 2026
12 min read
Rate Limit Testing Under DDoS: Where the Counter Lives

A rate limit is written once and enforced in as many places as you run it.

The configuration says 100 requests a second per client. Production runs that rule on six proxy replicas, twenty edge locations or one shared counter store, and each of those choices changes what "100" means on the day a flood arrives.

Most rate limit reviews read the rule. Rate limit testing reads the deployment: how many counters exist, where they keep their state, and what happens to the limit when that state is slow, full or gone.

Rate limit testing, defined

Rate limit testing is controlled, authorised traffic sent through the real production path to measure the limit a client actually meets, compared with the limit that was configured, and how that limit behaves when the components that count requests are under pressure.

In a DDoS test the question is narrow. Not "is there a rate limit", and not "is the threshold sensible", but "when the flood comes, how many requests per key reach the backend, and does that number hold while the limiter itself is being loaded?"

What other pages already cover

How a limit counts (aggregation keys, fixed and sliding windows, token and leaky buckets) is set out in the rate limiting definition. The AWS version of keys, scope-down and evaluation windows is in AWS WAF rate-based rule testing, nginx's limit_req burst behaviour is in DDoS testing for NGINX and load balancers, and per-tenant budgets are in DDoS testing for SaaS.

This post is about the part those leave alone: the counter as a distributed component with its own failure modes. Authorisation, ramps and stop conditions are no different here than for any target, and the complete guide to DDoS testing has them.

At a glance: four questions about the counter

QuestionWhy it changes the limitWhat the test records
How many counters see one client?Per-instance counters multiply the limit by the instance countRequests per second admitted for one key, at the backend
Does the count grow with scale-out?Autoscaling adds counters during the attackThe same figure at minimum and maximum replica counts
What if the shared store is slow or gone?The limiter either waits, allows everything or refuses everythingAdmission and latency with the store degraded, in staging
Which layer refuses first?The deepest limit is the most expensive place to dropStatus code and refusing layer, per request

One limit, many counters

The simplest limiter keeps its count in the memory of the process that enforces it. That is fast and has no dependency. It also means the count is local.

Per-instance counters multiply the limit

Put three replicas behind a round-robin load balancer and a single client's requests are dealt across all three. Each replica sees a third of the traffic and compares that third against the full limit.

A client sending 300 requests a second never crosses 100 on any one counter. The configured limit was 100. The enforced limit is 300.

One limit in the config, three counters in production Each replica counts only the requests it receives. One client key sends 300 rps Load balancer round-robin Replica A: counter sees 100 rps limit 100 rps, allows all of it Replica B: counter sees 100 rps limit 100 rps, allows all of it Replica C: counter sees 100 rps limit 100 rps, allows all of it Backend gets 300 rps Configured: 100 rps per client. Enforced: 100 rps per client, per replica. Effective here: 300 rps. Scale out to 30 replicas and the same client gets 3,000 rps through, with no change to the rule. BlackNeuron™
Rate limit testing with per-instance counters: one client key sending 300 requests per second passes through a round-robin load balancer to three proxy replicas, each of which counts only the 100 requests per second it receives against a 100 rps limit, allows all of them, and so the backend receives the full 300 requests per second

nginx is a useful example of where the boundary sits. Its limit_req_zone lives in shared memory, so the worker processes of one instance share a count. A second nginx instance has its own zone and its own count, and so does every pod of an ingress controller scaled to several replicas.

Scale-out raises the limit mid-attack

The multiplication gets worse at the worst moment. A flood drives CPU up, the autoscaler adds replicas, and every new replica brings a fresh, empty counter.

2026-11-26T07:04:04.011550 image/svg+xml Matplotlib v3.5.1, https://matplotlib.org/ 0 500 1000 1500 2000 2500 3000 3500 rps 1 replica 3 replicas 10 replicas 30 replicas, after scale-out 100 rps 300 rps 1000 rps 3000 rps configured limit: 100 rps Requests per second one client key gets through a 100 rps per-instance limit, even round-robin spread. Model, not a measurement. Source: Arithmetic in the post: configured limit x replica count, per-instance counters, even spread One configured limit, counted once per replica BlackNeuron™
Bar chart, a model rather than a measurement: requests per second that one client key gets through a 100 rps per-instance rate limit with an even round-robin spread, which is 100 rps on 1 replica, 300 rps on 3 replicas, 1,000 rps on 10 replicas and 3,000 rps on 30 replicas after scale-out

The arithmetic is plain: configured limit times replica count, assuming an even spread. A service that scales from 3 to 30 replicas under load has raised its per-client limit tenfold while the attack is running, with nobody touching the configuration. The scaling side of that interaction is covered in autoscaler exposure and Kubernetes DDoS testing.

The balancer decides how the count is split

Round-robin spreads a client evenly, which gives the clean multiplication above. Session affinity or consistent hashing on the client address does the opposite: the client lands on one replica, and its counter sees all of its traffic.

That makes a per-IP limit behind a hashing balancer close to accurate, and the same limit behind round-robin generous by a factor of N. Change the balancing algorithm for an unrelated reason and the rate limit changes with it.

Edge locations are counters too

An anycast edge spreads a distributed flood across many locations by design. Whether a rate limit counts globally or per location is a property of the platform, and providers differ.

Read the provider's documentation, then confirm it. A per-location counter facing a botnet spread across forty locations behaves like forty limits, each seeing a small share of the attack.

When the counter lives in a store

The usual fix for per-instance counting is a shared counter: a central rate limit service, often backed by Redis, that every proxy consults. One count per key, wherever the request lands.

That fixes the multiplication and adds a dependency that sits in the request path of every request, including the ones about to be refused.

When the counter lives in a store One count per key, and a dependency in the path of every request. Request Gateway or proxy Rate limit service Counter store read, increment, expire Store slow every request waits on the lookup, including the ones it will refuse the limiter becomes the load Store unreachable fail open: every request allowed fail closed: every request refused a default setting decides Store full one new key per attacking source; eviction deletes live counters counts restart from zero Ask what the proxy does when the limiter does not answer. Envoy's global rate limit filter allows the request unless failure_mode_deny is set to true. BlackNeuron™
Rate limit testing with a shared counter store: a request passes through a gateway that asks a rate limit service, which reads and increments a counter store; three failure branches follow, a slow store makes every request wait on the lookup so the limiter becomes the load, an unreachable store leaves the proxy to fail open and allow everything or fail closed and refuse everything, and a full store evicts live counters so counts restart from zero

Slow store, slow everything

Every request now makes a network round trip before it is admitted or refused. Under a flood, the store sees the flood's full request rate, not the admitted rate. The DDoS testing for APIs post notes the contention this causes on a single hot key; the wider point is that the store's latency becomes part of every response time.

If the store slows from one millisecond to fifty, every legitimate request pays fifty milliseconds more, and the limiter has become the layer that fails first.

Unreachable store: the default decides

When the limiter cannot get an answer, the proxy has to choose. Allow the request and the limit disappears. Refuse it and the service is down for everyone.

Most proxies make that choice in a setting few people read. Envoy's global rate limit filter is a clear example: unless failure_mode_deny is set to true, a request is allowed when the rate limit service fails to respond. That default favours availability, which is often right, and it also means that overloading the rate limit service switches the limit off.

Self-written middleware usually has no explicit setting at all. The behaviour is whatever the exception handler does when the client library times out.

Full store: eviction resets counts

A distributed flood is a cardinality attack on the store. Every attacking source, token or session is a new key, and a carpet-bombing pattern can create hundreds of thousands of them in minutes.

What happens next depends on the memory policy. Redis defaults to noeviction, which refuses writes once the memory limit is reached, so the limiter's increments start failing and the fail-open question above comes back. Under volatile-lru or volatile-ttl, Redis evicts keys that carry an expiry, which is exactly what a windowed counter is. The counts that get deleted are the live ones, and a deleted counter starts again from zero.

nginx makes the same trade inside its zone: when the zone is full it removes the least recently used state, and if it still cannot store a new one, it refuses the request with an error.

Two commands that should be one

A common hand-written fixed window issues an increment, then sets an expiry on the key, as two separate commands. If the second never runs (a timeout, a restart, a dropped connection under load), the key never expires.

That client is then counted forever and refused forever. Under a flood, with timeouts at their most frequent, this is the moment it happens to real users. A server-side script or a transaction that runs both together removes it, and a test that forces store timeouts finds it.

Counters that sync later

Some limiters count locally and reconcile with a central store every few hundred milliseconds, trading accuracy for speed. Between syncs, each node admits against stale totals.

The overshoot is roughly the attack rate times the sync interval, per node. That can be a sensible trade. The test makes it a known number instead of an assumed one.

Layers: which limit fires first

Most stacks carry more than one limit: one at the CDN or edge, one at an API gateway, one in the application. They were usually set by different teams at different times.

Three limits in a row, and which one fires Illustrative values. A client sending 300 rps meets all three. Edge limit configured: 1,000 rps per IP a drop here costs nothing behind it answers: 403 or a challenge 300 rps: never fires API gateway limit configured: 500 rps per key a drop here costs TLS and routing answers: 429 300 rps: never fires Application limit configured: 50 rps per user a drop costs a worker, maybe a read answers: 429 or 503 300 rps: fires, at the highest cost If the tightest limit sits deepest, it does all the work and the edge never fires. The status code each refused request receives names the layer that refused it. Record it per request. A count-mode limit at any layer looks like a defence on the dashboard and refuses nothing. BlackNeuron™
Three rate limits in a row, with illustrative values: an edge limit of 1,000 rps per IP whose drop costs nothing behind it and answers with a 403 or a challenge, an API gateway limit of 500 rps per key whose drop costs a TLS handshake and routing and answers with a 429, and an application limit of 50 rps per user whose drop costs a worker and possibly a database read and answers with a 429 or a 503; if the tightest limit sits deepest it does all the work and the edge never fires

The tightest limit should not be the deepest

The closer to the edge a request is dropped, the less it costs, as the rate limiting definition explains. The trouble starts when the deepest limit is the tightest.

An edge limit of 1,000 requests a second per address, a gateway limit of 500 per key and an application limit of 50 per user means neither of the first two fires against a client sending 300. Every one of those requests crosses the edge, completes TLS at the gateway, takes a worker in the application and is refused there. The limit works. It works in the most expensive place available.

The status code names the layer

Each layer refuses in its own way. An edge often returns 403 or a challenge page. A gateway returns 429, sometimes with Retry-After. nginx returns 503 unless limit_req_status was changed, as the NGINX post explains.

So the response code is free telemetry. Record it for every refused test request and the share of refusals per layer falls out of the results. If 90% of refusals are application 429s, the edge is decoration.

Count mode at one layer, block at another

A limit in count mode at the edge and enforcing at the application looks, from the dashboards, like two layers of defence. One of them is a counter. The test that drives traffic past both thresholds and reads the status codes tells you which.

Designing a rate limit test

The aim is a small set of numbers: the effective limit per key, how it changes with scale and with the store under stress, and the layer that refuses. All of them are measured where requests land, not where the rule is configured.

Measure the effective limit through the real path

Send a single key at a known rate, above the configured limit, through the same DNS name, edge, balancer and proxies a real client uses. Count admitted requests per second at the backend.

Divide admitted by configured. A ratio of 1 means one counter. A ratio near the replica count means per-instance counting. A ratio that drifts during the run means something is scaling.

Repeat at the replica counts you actually run

Run the same measurement at the minimum replica count and again at the count the service reaches under load, which you can pin for the test. If the ratio moves with replicas, the limit scales with the attack.

Break the store on purpose, in staging

The store failure modes are not things to induce in production. In a staging copy of the path, add latency to the store, make it unreachable, and fill it to its memory limit, and record admission, refusals and latency for each.

Three answers come out: what a slow store does to response time, whether the proxy fails open or closed, and whether counts survive memory pressure.

Ramp cardinality, not only rate

Most tests ramp rate on a few keys. A cardinality ramp holds a low rate per key and increases the number of keys, from hundreds to the volume the store would face under a distributed flood.

Watch the store's memory, its eviction counters and the admitted rate per key. The point at which counts start resetting is the limit's real ceiling against a distributed attack.

Keep legitimate traffic running

A limiter that fails closed under store pressure refuses your users, not just the test. Keep known-good traffic flowing through every stage and count its success rate separately. Any stage that touches the live path needs a rate cap and written abort criteria before it starts; how to set both is in DDoS testing without disrupting production.

FAQ

What is rate limit testing?

It is authorised traffic sent through the production path to measure the rate limit a client actually meets and how that limit behaves under load. In a DDoS test it checks how many counters see one client, whether scaling changes the limit, what happens when the shared counter store is slow, full or unreachable, and which layer refuses the traffic.

Why does my rate limit allow more requests than configured?

The most common reason is per-instance counting. If each proxy or pod keeps its own count and a load balancer spreads requests evenly, one client can send the configured limit times the number of instances before any single counter crosses the line.

Should a rate limiter fail open or fail closed?

It depends on what the limit protects. Failing open keeps the service available and removes the limit while the limiter is down, which an attacker can cause by loading the limiter. Failing closed keeps the limit and refuses everyone. The test establishes which one your proxy does today, so the choice is deliberate.

Is a rate limit test just a load test?

No. A load test asks how much legitimate traffic the service can carry. A rate limit test asks how much traffic per client the service lets through, and whether that number holds when the counting components themselves are under pressure. For the wider difference at the application layer, see L7 DDoS testing.

The limit is a distributed system

A rate limit looks like a number in a config file. In production it is a set of counters, a way of splitting traffic between them, a store they may share, a policy for when that store fills, and a default for when it does not answer.

Each of those was chosen for a reason that had nothing to do with an attack: lower latency, simpler operations, a library's default. Together they decide the limit a flood actually meets.

Configured limits are reviewed. Effective limits are measured, and the two are rarely the same number.

We use this to reply to you. Privacy policy