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.
Working-memory budget
Temporary state used while the program runs.
Stored records are not these tiles.
Illustrative space, not measured bytes. B is the running program; R is retained request state; dashed empty tiles are free space.
Read the numbered steps in order. The explanation below follows the narration.
Memory is working space; a process is a running program.
Waiting work can retain memory. A failed allocation or terminated process can stop service.
Waiting work can retain memory. A failed allocation or terminated process can stop service.
Memory is an application's working space, not permanent storage. A process is a running program. It uses memory even before customers arrive. While Maya waits for her report, the application can hold her request details, temporary data, and connection information. Waiting is not free.
After the work finishes and cleanup releases those resources, space can become available again. But if more requests remain unfinished, more state stays in memory. Our tiles illustrate that accumulation; they are not measured bytes per request. Maya closing her browser does not itself release this state. The application must finish or cancel the work and clean up.
A container is an environment for running a program. It can have an enforced memory limit. The host machine can still have free memory while this container reaches its limit. Asking for additional memory is an allocation. If the required memory cannot be provided, we have an out-of-memory condition, or OOM. An allocation can fail, or a process can be killed; the outcome depends on the runtime and system policy.
If the serving process is killed, this copy stops serving requests. Maya gets no report from it. The whole machine has not necessarily failed, and stored data has not necessarily been lost. The lesson is to protect room for finishing work, cleanup, and responses before reaching a hard limit. Refusing more work also costs resources. Waiting until memory is completely exhausted is too late to rely on an orderly refusal.
The application needs working space to run. This picture represents one application’s memory budget, not its database records or the size of the entire host computer.
The tiles marked B represent the program’s existing memory use. This is a qualitative illustration: we are not assigning a fixed number of bytes to every request or runtime.
The new R tile represents request details, temporary buffers, and connection state retained while Maya waits. The request can occupy memory without producing a useful result yet.
In this successful alternative, the work finishes and cleanup releases the request’s resources. Actual memory reuse and return to the operating system depend on the runtime; completion alone is not proof of immediate reclamation.
Return to the waiting case. More requests remain in flight and retain more state. The running program has not become larger in this simplified picture; the extra occupied space belongs to unfinished work.
Different requests can retain very different amounts of memory. These equal visual tiles help track occupied and free space; they are not a prediction of bytes, request capacity, or a safe production threshold.
The R tiles remain: Maya’s browser giving up is not evidence that the application cancelled the underlying work. The application must finish or cancel it and release the resources it owns.
A container is an environment for running a program and may have an enforced memory limit. That limit is a ceiling on this environment’s use, not a claim that the host reserves these exact physical tiles.
The illustrated container has reached its own boundary even though the host may still have free RAM. Looking only at machine-wide memory can miss the limit that actually stops this application.
The application asks the runtime or operating system for additional memory. If the required memory cannot be provided after the applicable reclamation and enforcement behavior, that is an out-of-memory condition.
An allocation may fail and be handled by the program, or system policy may terminate a process. These are alternative possibilities, not a guaranteed two-step chain or a rule that the largest process always dies.
Follow the process-termination branch: the application copy serving Maya is stopped. That does not automatically mean the whole host failed, every replica stopped, or permanent records were lost.
Return to a running application with some free space. Keep enough room for accepted work, cleanup, and responses; even refusing a request consumes resources. A check made only after total exhaustion cannot guarantee an orderly refusal.
Content revision: 07c7dd00db17
Download review copy (27 lessons)Maya closes her browser. Does the application automatically release everything her request holds?
No. The application must finish or cancel that work and release its resources; the browser giving up does not establish that cleanup happened.
Track retained work and the enforced process/container budget. Check cancellation and cleanup, including requests whose callers have gone away.
The illustrated termination is one possible OOM outcome. Victim selection and failure scope vary.
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.
Include garbage collection, native allocations, connection buffers and enforcement scope when selecting headroom; a single ratio cannot cover every runtime.
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.