How Token-Bucket Rate Limiting Contained a 40x API Traffic Spike Gracefully
A firmware update pushed to an integration partner's device fleet triggered a simultaneous sync, causing API traffic from that partner to surge from 40 to over 1,600 requests per second within 90 seconds. The engineering team discovered their existing fixed-window rate limiter handled the incident poorly, alternating between allowing all requests and rejecting everything with hard 429 errors, worsening the retry storm. Switching to a token-bucket approach allowed traffic to degrade smoothly into a steady trickle rather than cutting off abruptly at window boundaries. The team also implemented per-API-key buckets instead of shared endpoint-level buckets, successfully isolating the incident so no other partners experienced elevated error rates. A further lesson involved tuning Retry-After headers to accurately reflect real bucket refill times, which prevented well-behaved clients from inadvertently creating secondary retry surges.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in