Skip to content
BENIBIX Learn

Rate Limiting

Development🔌 APIsAPI Design Practices

Also known as Rate Limit, Throttling, 429 Too Many Requests, Retry-After

A cap on how many calls one user can make each minute.

Think of it like

Think of it like a ride at a fair. Only so many people get on each minute, and the rest wait.

Example

Jack's script calls a weather API in a tight loop. After 60 calls in a minute, every answer is 429 until the minute is up.

Why it matters

It keeps a service fair and running. It also turns many attacks from fast to very slow.

Definition

Rate limiting caps how many requests one user or key may send in a stretch of time. A limit might be 100 requests a minute. Past the limit, the server answers 429 Too Many Requests and often says how long to wait in a Retry-After header. It keeps one busy or buggy client from slowing the service for everyone. It also makes guessing passwords much slower.

Example code

http
HTTP/1.1 429 Too Many Requests
Retry-After: 30
Too many requests: wait 30 seconds, then try again.

Common mistake

Retrying a 429 at once, again and again. Wait the time Retry-After gives, and back off further if it repeats.

Key takeaways

  1. 1
    A cap per time. Like 100 a minute.
  2. 2
    429 past the limit. With a wait time.
  3. 3
    Fair for everyone. One client cannot hog it.