What you will have at the end
A Route, orders-api, on which every Consumer may make a fixed number of requests per minute. The mobile app exceeding its budget is answered 429 while the partner portal, with its own budget, is not. The counter lives in Redis, so every gateway node of the Environment counts the same window. The refusals appear as request records in Traffic Explorer, with the Consumer’s name on each, and as a share of the Route’s traffic in Analytics.
Prerequisites
- A Route with an authentication Plugin, so that requests carry a Consumer. Here
orders-apiserves/orders/*from the Upstreamorders-backendand carrieskey-auth. - Two Consumers with a
key-authcredential each:mobile_appandpartner_portal. A credential is created on the Consumer’s Credentials tab; the key is shown as••••afterwards. - A Redis the gateway nodes can reach. The address in this article is
redis:6379. - Traffic logging turned on under Traffic Explorer › Settings, and a Prometheus the Environment reads.
Count, window and key
Open the Route, select the Plugins tab, Add plugin, and choose limit-count from the catalog. Under Basics, keep One limit for everything here and set the budget:
- Count: how many requests one key may make in each window. The article uses 5, so the refusal is easy to reach by hand; a production value is a matter of the backend’s capacity.
- Time window: 60 seconds.
- Key type:
var, the default. Key:consumer_name. The engine then counts under the name of the authenticated Consumer, so every Consumer gets a window of its own.

That note matters. consumer_name is only set once an authentication Plugin has admitted the request, which is why key-auth sits on the Route first. The engine runs key-auth at priority 2500 and limit-count at 1002, so a request without a valid key is refused with 401 before it is counted.
A limit for each key, the other choice in Basics, takes a list of rules, each with its own key, count and window, for a Route that needs different budgets for different kinds of callers.
The Redis policy for several nodes
Under Behavior, Policy is local by default: each gateway node keeps its own counter in memory, so an Environment with three nodes allows three times the budget. Choose redis and the fields of the store appear: Redis host redis, Redis port 6379, and the Redis password, which is stored on the engine and shown only to roles that manage the Route. redis-cluster and redis-sentinel are the other two choices, with their own fields.

The engine keeps one counter per Consumer under the Route’s id, which is how the two budgets stay apart.
Allow degradation is off by default. The form explains the two choices: when the limit cannot be counted, because the store is unreachable, off answers 500 and on lets every request through unlimited. Decide this before the first incident, not during it.
The rejected code
The engine’s default answer for a request over the budget is 503. The first measurement of this article got exactly that: five 200s and then a 503, which Analytics would count as a server error. Set Rejected code to 429 under Behavior, and leave Show limit quota header on, so the client learns its budget from the response headers.

Save the Plugin. The change is in the audit log as a Route update with the limit-count block as the difference and the Redis password masked.

What a client sees
Eight requests from the mobile app within one minute, then one from the partner portal:
mobile_app 1 200 2 200 3 200 4 200 5 200 6 429 7 429 8 429
partner_portal 200
The refused response carries the budget:
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 59
The 429 in Traffic Explorer
Open Observe › Traffic Explorer, type the Consumer’s name in the search field and choose Filter by Consumer. The list is the mobile app’s traffic alone: five 200s answered by the backend node, then 429s whose Upstream node reads gateway, because the engine answered them without calling the backend.

Open a 429 record: the Overview names the Route and the Consumer, and the Response tab holds the x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset headers as the client received them.
The 4xx share in Analytics
The Route’s Analytics tab counts the same requests from Prometheus. The Requests card splits them by status class; after half an hour of the mobile app overrunning its budget once a minute, 4xx was 43 percent of the Route’s traffic. The Client errors card beside it splits the 4xx by code and by source: 429 and 401 only, all answered by the gateway and none by the backend, so the limit and the key check did their work before any request reached the orders service.

What to do next
- Read the Route’s Analytics tab for a day before you choose the production count, and set the budget from the 2xx rate you see there.
- The Consumer the limit counts comes from an identity Plugin: OAuth 2.0 access tokens at the gateway or Directory accounts as API callers; the 429s in your own store: Access logs to Elasticsearch, syslog and HTTP.
- The Plugin can also sit on a Service or on a Consumer; the Route’s Request path card shows where each copy joins the list, and the Consumer’s copy joins after authentication.
- How rate limiting fits with the other traffic rules is on API gateway › Rate limiting and on Rate limiting and traffic management.