All posts

One Open-Source Project Changed How I Think About System Design

How reading Redis source closed the gap between interview diagrams and real systems—event loops, eviction, and learning from production code.

ossium
ossium3 min read

You can clear system design rounds on paper—load balancer, cache, database, sharding—and still not understand systems. Reading a production codebase can close that gap faster than another course.

One weekend with thousands of lines of Redis made the difference between memorizing diagrams and understanding why designs survive production.

The interview answer that fell apart

A clean answer for “design a caching layer” is often: cache reads, invalidate on writes, add a TTL. It matches every slide deck.

Redis’s hard problems are not “caching” in that shallow sense. They’re memory eviction policies, a single-threaded event loop that avoids lock races, and what to do when a slow client forces the server to choose between buffering and disconnecting.

Whiteboard interviews rarely cover that. 2 AM outages often do.

Why the event loop mattered more than the algorithm

Redis sustains huge throughput on a single thread. The insight is structural:

Clients → Event Loop
              ├─ Socket reads
              ├─ Timer events
              └─ Command queue

Commands run to completion before the next starts—no lock contention on the hot path because nothing competes at the same instant. The elegant move often removes a problem instead of managing it with more concurrency.

Interview prep trains you to reach for multi-threading first. The better first question: does this system need concurrency, or a smarter ordering of work?

The part that only makes sense after you’ve been paged

A service that randomly spiked latency under load looked like a database problem. It wasn’t. Cache eviction—copied from a tutorial years earlier—was thrashing hot keys under memory pressure because access patterns were never considered, only expiry.

Recognizing multiple eviction strategies in Redis pointed at the real failure mode. A tutorial teaches the happy path. Source shows decisions the happy path hid.

Example impact after fixing eviction (mid-size Node service, simulated peak, single region):

MetricBeforeAfter
p50 latency40 ms22 ms
p99 latency340 ms95 ms
Cache hit rate61%88%

Mental model

Interview prep shows what a system looks like. Source code shows what a system survived.

Treat diagrams as suspect until you’ve traced at least one real implementation behind them.

Where to start on Monday

  1. Open the GitHub repo of a tool you already use daily.
  2. Search for the function behind your last production incident—not a random file.
  3. Read that function and its callers only.
  4. Write one sentence on why it was built that way.

For a queue, start with retries. For a cache, start with eviction. For a web framework, start with routing. You’re not reading the whole project—you’re hunting the decision no tutorial explained.

Mock interviews and boxes still help. They’re better when every box has a real function behind it you’ve actually read—the difference between sounding right and being right when the pager fires.

open-sourcesystem-designredislearninggithub

Related posts