Why you shouldn’t use Redis as a rate limiter: Part 1 of 2
A tour of the common Redis-based rate limiter implementations — and the correctness and performance traps each one hides.
We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Rate limiting and admission checks that help reduce overload and protect expensive work.
Set admission budgets for launch spikes and promos before excess work reaches your handlers.
Fewer moving parts to run and monitor. Spend less on Redis and ops.
Add via SDK. Keep your stack. Clear limits your customers understand.
UNDERSTAND OVERLOAD · KEEP USEFUL WORK MOVING
For developers, architects, and managers: 27 narrated lessons on why services overload and how to protect them. No cloud experience required. Start with one request, or jump to any lesson.
Four chapters, one learning path. Read or listen in any order. ~41 minutes total · Times shown at 1×.
Keep enough capacity to finish work and recover.
Contain one customer's excess without punishing everyone.
Reduce work entering a shared dependency when it slows.
Choose, combine, and test the right protections.
Read the explanation or use the course map above. Audio is optional.
Timing and reporting
Immediately before the chosen operation.
At its defined endpoint.
Finish time minus start time.
Brackets mark the stopwatch interval. Labels and line patterns distinguish boundaries. Order only—not a time scale.
Read the numbered steps in order. The explanation below follows the narration.
Choose the operation before choosing a threshold.
Define one meaningful stopwatch boundary before interpreting its measurements.
Define one meaningful stopwatch boundary before interpreting its measurements.
Latency is how long an operation takes. To learn about a shared database, measure the database operation, not the whole page including unrelated work. A measurement boundary says exactly when that stopwatch starts and stops.
For example, start just before asking for a database connection, and stop when the required database result arrives. This boundary includes waiting for a connection and the query itself. Another boundary could start after the connection is acquired. Neither number is meaningful unless you know which boundary produced it and use it consistently.
A report is an observation sent to RateLimitly: this operation took this much time. Report after the measured work reaches its defined endpoint. Reporting an observation is not consuming a rate-limit allowance. Do not send a made-up zero duration when a call fails or a measurement is missing.
If the measured time rises, work inside that boundary is taking longer. That may include waiting, actual computation, or communication. The number is useful evidence, but it does not directly reveal the database's memory usage or the exact cause of the delay.
Follow one operation from START to STOP. Its latency is the time between those two events, not the number of operations performed.
The page also does unrelated work. The solid bracket isolates the database operation; dashed boxes remain outside that interval.
Decide which events begin and end the stopwatch. Without that definition, a duration cannot tell another developer which work it describes.
Connection acquisition is inside this chosen boundary. Time spent waiting for an available connection therefore contributes to A, before the query can run.
Submitting a query is not the endpoint. Keep measuring through the query and the return of the required result; later page work is excluded.
Read the full solid bracket. Both acquisition and database work contribute to this observation; unrelated page work does not.
This is the same operation, not a second request. A and B stop at the same result, but B deliberately leaves connection acquisition outside its stopwatch.
A longer A does not by itself mean its query was slower than B: it includes additional work. Use a consistent definition across clients, or deliberately separate different observation scopes.
The stopwatch belongs around the chosen operation. Reporting communicates its observed duration; RateLimitly does not execute the database query shown here.
The reporting arrow lies outside the stopwatch bracket. Sending the observation must not extend the duration of the database operation being reported.
This message says how long the measured operation took. It is an observation, not a request to consume tenant allowance and not an admission decision.
A failed call or missing measurement does not prove that no time elapsed. Do not fabricate a zero-duration observation; define how valid timing, failures, and cancellations are handled.
Keep the definition fixed when interpreting a change. The observation is that the measured operation took longer; it does not yet identify why.
These are possible contributors, not three measured components or a diagnosis. Which are included depends on the chosen stopwatch boundary.
The stopwatch tells us elapsed time within its boundary. It does not directly measure database memory, reveal an exact queue length, or establish the cause of the delay.
Content revision: 07c7dd00db17
Download review copy (27 lessons)One client includes connection waiting and another excludes it. Are their durations directly comparable?
Not necessarily. They measured different operations. Use consistent boundaries or separate appropriately scoped trackers.
Start before the protected operation, report its actual measured duration after the defined endpoint, and define how failures and cancellations are observed.
Do not manufacture a zero-latency report for missing or failed measurements. Reporting semantics must match the measured operation.
Start here. No earlier lesson is required.
100 arrivals/s − 80 completions/s = 20 extra unfinished requests/s.
Bigger buffers buy time. Caching can remove work. Backpressure reduces incoming work.
Timeout, cancellation, connection failure, and operation outcome are different facts.
Database unavailable → calls wait or fail → unbounded retained app work can cause further failure.
Including pool acquisition can expose upstream contention, while excluding it isolates another boundary. Heterogeneous operation costs may need separate trackers.
Original explanation inspired by Fred Hébert and operational references; no endorsement implied.
AI-generated narration: ElevenLabs Eleven v3, Daniel stock voice. Audio streams only when you start listening.
A tour of the common Redis-based rate limiter implementations — and the correctness and performance traps each one hides.
The myth of infinite serverless scale — why adding machines doesn’t fix overload, and what to do instead.