A single bot can send thousands of login attempts per minute — trying stolen password lists against your users. Or a poorly written client can accidentally DDoS your own API. Without a gate, there's nothing to stop it.
Make another request → Keep clicking until you hit the limit and see what gets blocked.
Increment the counter, then set a timer. The timer only runs once — on the first request of each window.
Check if the counter is over the limit. No need to reset anything — the timer is already running.
No cron job. No scheduled cleanup. Redis just deletes the key when the timer expires. The next request starts a fresh window at count = 1.
GitHub API allows 5,000 requests/hour per token. Twilio rate-limits SMS sending to prevent abuse. Banks limit login attempts to prevent brute-force attacks. Stripe uses it per API key to prevent runaway billing.