Unit V · Money and limits
Rate limits, retries and runaway loops
APIs limit how fast you may call them. How your app reacts to "slow down" decides whether it recovers quietly or hammers the API and burns your quota.
429 Too Many Requests
When you send too many requests in a given time, an API typically answers with status 429 Too Many Requests, sometimes with a Retry-After header saying how long to wait. Treat it as an instruction, not as an error to retry at once.
Back off, with jitter
Retry after a delay that grows with each failure (1, 2, 4, 8 seconds), add a little randomness so many clients do not retry in step, and stop after a few tries. AWS's architecture blog describes this as exponential backoff with jitter.
Guard against loops
Put a timeout on every outside call, a maximum number of retries, and a limit that stops a job when it goes far past its normal number of calls. Cache answers that do not change. A loop that runs while you sleep is how a two-dollar day becomes a two-hundred-dollar day.
Words to know
- Rate limit
- the most requests allowed in a time window
- 429
- the status code for too many requests
- Exponential backoff
- waiting longer after each failure
- Jitter
- random variation added to the wait
Sources
Checked October 17, 2026. Pages on other sites change; if a source no longer says what the lesson says, the source wins.