On login, an attacker tries thousands of passwords. Limiting attempts breaks the attack.
A bot scrapes your data, or a buggy client loops. The limit protects your resources.
An endpoint calling an LLM without a limit is an open bill. A per-user cap bounds it.
One heavy consumer shouldn’t degrade everyone else’s service. The limit keeps sharing fair.
The simplest and most common algorithm: each key (IP or user) has a counter that fills over a time window. Beyond the limit, return a 429. Redis is perfect for it — atomic and shared across all your instances.
Limit per logged-in user when you can, not just per IP: behind a corporate NAT, hundreds of users share the same IP.
Watching 429s is observability: I cover logs and alerts in monitoring: logs, alerts, uptime.
No more accidentally committed .env: where secrets live, how to inject them, how to rotate them.
Know it broke before the customer does: structured logs, metrics, alerts that don’t cry wolf.