Guided Lab Brief

Supercharge with Caching

Add a Redis cache to reduce database load and dramatically improve response times.

Overview

Add a Redis cache to reduce database load and dramatically improve response times.

Your 3-tier system works, but every request hits the database.

You will build 4 architecture steps that model production dependencies.

You will run 2 failure experiments to observe bottlenecks and recovery behavior.

Success target: Cache hit rate ≥ 80%, database receives <100 rps, overall latency <20ms.

Learning Objectives

  • Understand the cache-aside pattern (check cache → miss → read DB → write cache)
  • Know how hit rate dramatically affects database load
  • Learned about TTL trade-offs (freshness vs. performance)
  • Understand LRU eviction and cache sizing

Experiments

  1. Set the cache hit rate to 10% to see what happens when caching doesn't work well
  2. Set the TTL to 5 seconds to see the effect of aggressive cache expiration

Failure Modes to Trigger

  • Trigger: Set the cache hit rate to 10% to see what happens when caching doesn't work well

    Observe: At 10% hit rate, 450 of 500 rps still hit the database. The cache exists but provides almost no benefit. Your database is just as overloaded as without a cache, plus you're paying for Redis infrastructure.

  • Trigger: Set the TTL to 5 seconds to see the effect of aggressive cache expiration

    Observe: With 5-second TTL, cached data expires almost immediately. The cache is constantly being rebuilt, sending a flood of requests to the database. Your effective hit rate drops dramatically.