Rate Limiting
Protecting the system.
One buggy script can send Shoply ten thousand requests a second. Without protection, it slows the site down for everyone. Rate limiting caps how many requests each client can make.

- One buggy script
- Slows everyone down
- Cap each client
Why limit
Rate limits protect you in several ways. They stop accidental floods from buggy code. They slow down attackers guessing passwords. They keep costs under control. And they keep things fair, so one heavy user can't starve everyone else.
Designing the limit
When you design a limit, decide a few things. Who is limited, by user, API key, or IP address. What the limit is, like a hundred requests per minute. Where it runs, often in the gateway. And what to answer, which is status four two nine, too many requests, with a header saying when to try again.
| key | value |
|---|---|
| Who | user, API key or IP |
| How many | e.g. 100 per minute |
| Where | usually the gateway |
| Answer | 429 + Retry-After |
Summary
Rate limiting caps requests per client, to stop floods, attacks, and unfair use. Over the limit, answer four two nine. Next, the algorithms that count requests.
Key takeaways- Per client limits
- Usually in the gateway
- 429 Too Many Requests