Rate Limits and Backpressure
In this article
- Turn a provider's per-minute limit into a cap on calls in flight, and say when that cap stops holding.
- Split the cap between tenants with quotas and a fair queue, and show with sums that a burst stays under the limit.
- Decline old queued work with an explicit answer instead of letting it wait without end.
- Predict the sending rate for each minute after a 429 under halve-then-add throttling.
- Terms defined here: concurrency cap, tenant quota, fair queueing, load shedding, backpressure, adaptive throttling.
Overview
Two teams share one account with a model provider. One runs the support agent that handles refunds; the other starts a job that rewrites 400 product pages at once. Within seconds the provider starts refusing requests, and customers waiting for a refund see their runs time out. Nothing is broken: the account was asked for more work than it may send.
The fix is limits your own code keeps first. You will turn a per-minute limit into a cap on calls in flight (sent and not yet answered), split it between the teams, decline old queued work out loud, and slow down after a refusal, with sums that show the burst staying inside the limit.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- A burst that does not fit
- From a limit to a cap
- Sharing the cap between tenants
- Saying no early
- Slowing down after a 429
- One dispatcher check
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions