How it works
Return 429 for rejected synchronous requests and a Retry-After value, a wait in seconds or a date, when a meaningful wait can be computed. Quota and remaining-allowance headers can help clients pace themselves; GitHub’s API, for example, returns x-ratelimit-limit, x-ratelimit-remaining, and x-ratelimit-reset. Keep their semantics consistent with the algorithm. Clients should back off, avoid retry storms, and cache or batch work where appropriate. Queueing is suitable only when the API contract permits delayed processing.
A retry storm is easy to cause. Suppose 5,000 clients are rejected in the same second and each is told to wait 30 seconds. All 5,000 return together 30 seconds later, and most are rejected again. If clients add jitter, a random extra delay, of up to 10 seconds, the return spreads to about 500 per second.
Track allowed and rejected requests by rule, endpoint, and safe aggregate client segment; measure decision latency, counter-store errors, and downstream load. A high reject rate may mean the rule is too strict, an attack is active, or the key groups unrelated users. Review both false blocks and capacity protection. Load-test boundary bursts and concurrent requests, then tune based on the actual traffic shape. Consider rolling out a new rule in shadow mode, logging what it would have rejected without rejecting anything. That delays protection, so it does not suit a rule written during an active attack.
After a new rule ships, database load falls but checkout failures surge. Is the limiter successful?
No. The rule protects capacity but may be blocking valid checkout traffic. Segment rejects, inspect key choice and thresholds, then tune the policy while retaining the necessary protection.
Use this as a guide for self review; written answers are not graded.Keep in mind
- A 429 response should lead to predictable client behavior.
- Monitor both the protection gained and legitimate traffic blocked.