<aside>

This section is part of the 5-hour System Design Foundations course by Mukul Raina

SLIDE 63: What is Caching

Section 6: Caching

A cache is a temporary storage layer that holds frequently accessed data in a faster medium so that future requests for that data can be served without going to the slower original source. In system design, caching is the single most impactful performance optimization available.

What We’ll Cover:

  1. Why caching works (locality of reference)
  2. Cache hit vs cache miss
  3. Where to cache (the four layers)
  4. Caching strategies (cache-aside, write-through, write-behind)
  5. Cache eviction policies (LRU, LFU, TTL)
  6. Cache invalidation
  7. Redis
  8. Caching failure modes and mitigations

The Core Idea:

Without cache:
Client → App Server → Database (disk read: ~5-50ms)

With cache:
Client → App Server → Cache (RAM read: ~0.5ms) → return
                       ↓ (cache miss only)
                    Database (~5-50ms)

Speed difference: 10-100x faster for cache hits.
At 80% cache hit rate, 80% of your requests never touch the database.

Real-World Impact:

Metric Without Cache With Cache (80% hit rate)
Average response time 50ms 10ms (80% at 0.5ms + 20% at 50ms)
Database QPS (100K total) 100,000 20,000 (80% served from cache)
Database servers needed 10 2
Monthly database cost $5,000 $1,000

Caching doesn’t just make things faster. It reduces infrastructure cost by reducing load on the most expensive component: the database.

<aside>

Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn

</aside>