Skip to content

Lesson 6 of 9 · 26m

Failure Modes, Observability, and Rate-Limit Incidents

Plan for limiter outages, thundering herds after resets, bad deploys, and observability that distinguishes protection from product breakage.

Rate limiters fail in both directions. Sometimes they fail open and the database melts. Sometimes they fail closed and customers cannot log in because Redis is down. Occasionally they fail sideways: every response is 200, but quota accounting doubles because a retry middleware replayed the mutation. If you have not rehearsed these states, you do not have a control; you have a hope.

Fail-open and fail-closed are both product decisions

Ask what the limiter protects:

credential stuffing protection    fail closed or heavily degraded login
paid API quota accounting         fail closed for billable overuse
read-only public content          often fail open with shedding elsewhere
internal anti-hot-loop guard      usually fail closed or clamp concurrency

"Always fail open because availability" is lazy. "Always fail closed because security" is also lazy. The correct behavior depends on which failure creates more harm and who bears that harm.

Thundering herds happen after recovery

When a limiter or dependency recovers, queued clients retry at once. Window resets create the same effect every minute. Add jittered client retry guidance and smooth internal release:

Retry-After: 17

Do not return the exact same retry delay to every client if you can avoid it. A bucket refill or reset boundary already synchronizes them; your response should not sharpen the spike.

Instrument decisions, not just rejections

Useful metrics include:

rl_decisions_total{action,decision,layer,key_scope}
rl_tokens_remaining{action,key_scope}
rl_cost_units_total{action,tenant_class}
rl_backend_latency_seconds{action}
rl_limiter_errors_total{mode}

Do not put raw tenant IDs or IPs into metric labels; cardinality will hurt the metrics system and leak operational identity. Aggregate by key scope, tenant class, endpoint, and decision. Keep detailed keys in access logs or trace baggage where retention and access controls are appropriate.

Alerts must separate attack from breakage

A spike in 429s can mean an attack, a customer bug, a deploy regression, or a successful launch. Tie rejection telemetry to traffic shape:

new source cardinality     attack or botnet
single tenant spike        integration bug or legitimate batch job
post-deploy spike          cost-weight regression
limiter error spike        dependency or configuration failure

During incident review, the first question should be "which budget was exhausted?" If nobody can answer, the observability is not doing its job.

Test the control plane, not only the data plane

Changing a quota must propagate predictably. Record policy version, rollout state, and decision provenance. When a customer is throttled, support should be able to determine whether edge policy, gateway policy, service quota, or worker concurrency caused it. "The platform did it" is not an operable answer.

Rehearse bypass carefully

Emergency bypasses are sometimes necessary, but a broad disable flag is a loaded weapon. Prefer scoped, expiring exceptions:

subject: tenant_9182
action: exports
ceiling_multiplier: 4
expires_at: "2026-12-01T00:00:00Z"
reason: incident-4821-data-backfill

Every bypass should have an owner, expiry, reason, and audit event.

Field notes

  • Retry middleware can consume budget twice even when the side effect is idempotent.
  • A redis reconnect storm can look like an application traffic spike; graph dependency errors beside decisions.
  • The first observable symptom is often latency, not 429s, because queues fill before rejection starts.
  • Test deploys with old and new policy versions simultaneously; production will do it whether you test it or not.

Was this lesson helpful?

Sign in to rate