We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
6 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Caching Strategies
Free preview: the first 2 parts of this 11-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Caching Strategies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
The remote cache lesson measured a hit from one client on an idle server. That is the right way to find the floor, and it deliberately leaves out the property that decides how Redis behaves in production.
A Redis server runs one command at a time, in the order the commands arrive.

Nothing about the small request changed. It was sent to the same server, on the same connection, for the same 200 byte value. What changed is that it spent most of that time in a queue.
This is the fact to carry through the whole lesson. Redis is fast because it does one thing at a time in memory with no locks, and the price of that design is that any single slow command becomes every other client's .

A thread pool would let the small commands overtake. Redis has no pool, and that is deliberate: with one thread there are no locks, no context switches and no coordination.
Read the design as a trade, not a limitation. Single threading buys a latency floor that a locked, multi-threaded store cannot reach, and it sells you a head-of-line blocking problem that you have to manage by never issuing an expensive command.

The three medians are 0.016, 0.017 and 0.016 milliseconds, identical to three decimal places. Nothing in an average panel would show that anything happened at all.

Most requests still arrive while the server is idle and are answered in microseconds, so the median does not move. The ones that arrive during the slow command absorb the whole of it.
An average latency panel would show none of this, and a 99th percentile panel would show a tenth of it. If a cache is occasionally, inexplicably slow, the number to plot is the maximum, and the thing to look for is one client issuing one expensive command.