/service-mesh-gateway-skills:api-gateway-rate-limiting-and-quota-managementfrom service-mesh-gateway-skills
Designs vendor-neutral rate-limiting and quota strategy for API gateways: token bucket vs. sliding/fixed window algorithms, per-client vs. global vs. tiered scoping, burst allowance sizing, and distributed counter consistency. Use when designing rate-limiting policy, choosing an algorithm, or diagnosing inconsistent enforcement across nodes.
Ships in service-mesh-gateway-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every gateway tool exposes a rate-limiting plugin, but the plugin configuration is downstream of decisions that are the same regardless of which tool implements them: which algorithm actually matches the traffic pattern being protected against, whether the limit should be scoped per-client, per-API-key-tier, or globally, how large a burst allowance is safe versus how much it just delays the same overload, and how (or whether) the counter is kept consistent across multiple gateway nodes. Getting these wrong produces two opposite failures that are equally bad: a limit so tight it throttles legitimate traffic and gets "temporarily" raised during an incident until it's effectively meaningless, or a limit so loose (or inconsistently enforced across nodes) that it fails to protect the backend it was meant to protect at all. This skill covers that vendor-neutral strategy layer — the tool-specific plugin mechanics for applying it live in kong-api-gateway-configuration and apigee-api-management-and-governance.
RESOURCE_EXHAUSTED response rates per client/
tier after a policy ships, so an overly tight or overly loose limit
is discoverable from data rather than only from a support escalation.Decide whether you're rate-limiting or quota-managing — or both, as separate policies — before picking an algorithm:
SpikeArrest and Quota as separate
policies (see
apigee-api-management-and-governance)
rather than one combined mechanism.Choose an algorithm based on the traffic pattern, not habit:
Scope the limit at the right level deliberately:
Size the burst allowance from observed traffic, not intuition. Pull real percentile data (p50/p95/p99 request rate per client over short windows) and set the bucket/burst size to comfortably cover legitimate p99 burst behavior, with the sustained/refill rate set to the backend's real sustained capacity:
Observed: typical client bursts to ~40 req/s for 2-3s during a page
load, then idles; sustained backend capacity: 500 req/s total.
Token bucket per client: bucket size 50 (covers the p99 burst),
refill rate 10 req/s (bounds sustained abuse without punishing the
normal burst-then-idle pattern).
A burst allowance sized purely as "whatever number stops complaints" without reference to real traffic data tends to ratchet upward over time as each complaint is resolved by raising it, until it no longer protects anything.
Use a shared, distributed counter for any multi-node gateway deployment — this is the single most common way a "correctly designed" limit fails in practice:
3 gateway nodes, each with an in-memory (local) counter,
configured limit: 100 req/min per client
→ actual enforced limit: up to 300 req/min per client
(100 independently on each node a client's requests happen to hit)
Back the counter with Redis (or the gateway's cluster-aware counting
mode) so all nodes enforce against the same count. See
kong-configuration-validation
and
kong-api-gateway-configuration
for the concrete policy: redis configuration this maps to in one
specific tool.
Return a response that lets well-behaved clients self-correct, not just a bare rejection:
HTTP/1.1 429 Too Many Requests
Retry-After: 12
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1795891200
A Retry-After header (or the gRPC-equivalent status detail) lets a
well-implemented client back off correctly instead of immediately
retrying and compounding the overload — and its absence is a common,
easily-fixed reason a rate limit doesn't actually reduce load the
way intended.
Monitor 429/RESOURCE_EXHAUSTED rate per client/tier after
shipping, treating a sustained high rejection rate for a specific
client as a signal to investigate (is this abuse, or a legitimate
traffic pattern the limit was sized wrong for?) rather than either
ignoring it or reflexively raising the limit:
# example query against a metrics/logging backend
sum(rate(gateway_requests_total{status="429"}[5m])) by (consumer)
A single client consistently hitting 429 might be legitimately under-provisioned for their tier (a business conversation, possibly a tier upgrade) or might be misbehaving (a retry loop with no backoff) — the fix differs, so don't default to "just raise the limit" without checking which case it is.
Re-validate limits after any significant backend capacity change, since a rate limit sized to protect a specific backend capacity becomes wrong (too tight or, more dangerously, too loose) the moment that capacity changes and nobody revisits the limit.
Retry-After and remaining-quota headers on every throttled
response so well-behaved clients can back off correctly instead of
hammering the gateway harder.Symptom: A configured "100 requests/minute per client" limit
clearly allows more than 100/minute in production, confirmed by
request logs.
Fix: The gateway is very likely running multiple nodes with a
per-node (local/in-memory) counter instead of a shared one — the true
enforced limit is close to 100 * node_count. Switch to a
Redis-backed (or equivalent cluster-aware) counting policy so every
node enforces against the same count.
Symptom: A rate limit sized from "round numbers that seemed reasonable" either constantly throttles normal usage (frequent support complaints) or never triggers at all even during a known abuse incident. Fix: The limit wasn't sized from real observed traffic. Pull actual p95/p99 per-client request-rate data and re-derive the burst/refill (or window) size from it, rather than guessing and then reactively adjusting after each complaint.
Symptom: A fixed-window rate limit is bypassed by a client sending a burst right at the window boundary — twice the intended rate gets through in a one-second span spanning two windows. Fix: This is fixed window's known structural weakness, not a configuration bug. Move to a sliding-window or token-bucket implementation, which doesn't have a hard reset boundary an informed client can time against.
Symptom: During a traffic spike, an on-call engineer doubles or removes the rate limit for the affected client "to stop the 429s," the incident resolves, and the change is never reverted. Fix: This is a real, standing risk once left in place — the limit no longer protects the backend from that client (or anyone using the same raised ceiling) going forward. Treat any incident-time limit change as temporary and explicitly tracked for revert, and once the incident is over, investigate whether the real fix is a legitimate tier increase (a deliberate, reviewed change) or addressing an actual misbehaving client (a retry loop, a missing cache) rather than leaving the emergency value in place by default.
Symptom: A quota (long-window, e.g. monthly) is correctly enforced and a client is well within it, but the same client's traffic still occasionally degrades the shared backend. Fix: Quota and rate-limiting solve different problems — a client can be far under a monthly quota while still sending a short burst the backend can't absorb in real time. Add a separate short-window rate-limit (or burst-aware token-bucket policy) alongside the existing quota rather than assuming the quota alone provides burst protection.
Scenario: payments-api is called by many partner clients through
a 3-node gateway cluster. Observed traffic: typical client bursts to
~15 req/s for a few seconds during checkout completion, then idles;
overall backend sustained capacity is 300 req/s across all clients
combined. Partner contracts also specify a 500,000-request monthly
allowance per partner.
Design:
429/Retry-After plus
X-RateLimit-Remaining/quota-remaining headers so partner clients can
observe how close they are to either limit and back off accordingly.Monitoring: a dashboard tracking 429 rate per partner and per limit type (rate-limit vs. quota) separately, so a partner hitting their monthly quota (a contract conversation) is distinguishable at a glance from a partner triggering the per-second rate-limit (likely a retry loop or a genuine burst that needs investigating), rather than both showing up as an undifferentiated "429 spike."
The concrete plugin configuration implementing this design in Kong is
covered in
kong-api-gateway-configuration;
the equivalent Quota/SpikeArrest policy pairing in Apigee is covered
in
apigee-api-management-and-governance.
rate-limiting plugin configuration (including the redis/cluster counter policy) implementing this strategy in Kong.Quota/SpikeArrest policy pairing implementing rate-limiting vs. quota management separately in Apigee, plus how quota ties into monetization tiers.EnvoyFilter) as an alternative enforcement point for east-west traffic, versus enforcing at the north-south gateway edge covered here.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin service-mesh-gateway-skills11 skills in this plugin
/apigee-api-management-and-governanceGoverns the full API lifecycle in Google Apigee (or comparable enterprise API-management platforms) — API proxy design, policy attachment (OAuth2/API key verification, quota, spike arrest, transformation), developer portal publishing, product-based monetization, and semantic versioning/deprecation of published APIs at organizational scale. Use when a user asks to "design an Apigee API proxy," "set up an API product for monetization," "version an API without breaking existing consumers," "add a spike arrest or quota policy in Apigee," "publish an API to a developer portal," or "govern API lifecycle across many teams."
/cilium-configuration-validationValidates CiliumNetworkPolicy, CiliumClusterwideNetworkPolicy, and Hubble observability configuration before a production rollout — syntax-checking policy files offline, confirming which endpoints and identities a policy actually selects, and using Hubble flow data to prove a policy enforces what it's meant to instead of trusting the YAML. Use when a user asks to "validate a CiliumNetworkPolicy before applying it," "check if this policy will actually match my pods," "confirm kube-proxy replacement is healthy before a rollout," "test an egress FQDN policy before merging," or "why is Hubble showing drops I didn't expect."
Other plugins' skills for the same job