Page 5 of 8~245 min topic

Rate limiting lab

Triage and recover rate limiting

When Redis down → fail-open floods provider → shared 429s, the system must degrade on purpose without widening blast radius.

~35 min this pageFailure handling

1Learn the idea

Read

Classify and bound retries

Map failure classes for POST /v1/rag/answer: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After. The chapter’s signature failure — Redis down → fail-open floods provider → shared 429s — must take a deliberate branch, not a generic catch-all.

Read

Containment path

Implement the degrade/rollback/refuse behavior platform SRE stopping noisy neighbor tenant StormCo needs when RL-FAILOPEN-61 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”

Read

Implementation artifact

if redis_down:
    return LimitDecision(allow=False, remaining=0, retry_after_ms=1000)  # fail closed

Read

Verify harm reduction

After containment, check 429_ratio_by_tenant and provider_429_ratio ≤ 0.01 moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.

Read

Stage depth

Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how Redis down → fail-open floods provider → shared 429s becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for 429_ratio_by_tenant and provider_429_ratio ≤ 0.01.

Read

Field notes for `rate-limiting-lab` / `failure-handling`

Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is layered token-bucket limiter for multi-tenant RAG API, the human stakeholder is platform SRE stopping noisy neighbor tenant StormCo, and the incident id you design against is RL-FAILOPEN-61. Re-state the oracle in your notes — StormCo at 200 RPM gets 429 after burst; Globex at 40 RPM unaffected — and keep the invariant visible: tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After. Track 429_ratio_by_tenant and provider_429_ratio ≤ 0.01 as the scoreboard. Surface under change control: POST /v1/rag/answer. If you only have forty minutes, finish the fixture for Redis down → fail-open floods provider → shared 429s before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

Assume Redis down → fail-open floods provider → shared 429s is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: tenant RPM soft=60 hard=100; global 5k RPM; 429 includes Retry-After.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Are retry budgets explicit?
2. Is containment scoped?
3. Do you preserve evidence for RL-FAILOPEN-61?

All responses are required.