How does caching reduce database load?
caching as a read-offload layer.
cache-aside reads, RAM-speed lookups, TTL plus invalidation.
treating the cache as durable source of truth or ignoring stale-data and invalidation.
WHAT THIS TESTS The interviewer wants to know whether you understand why an in-memory store sits in front of a database and how it changes the load profile. It is a fundamentals check on latency, hit ratios, and consistency.
A GOOD ANSWER COVERS A database read, especially a complex join, costs disk I/O and CPU. An in-memory store like Redis serves data from RAM in well under a millisecond. The dominant pattern is cache-aside: the application looks in the cache first, and on a hit returns immediately. On a miss it queries the database, writes the result into the cache with a time-to-live, and returns it. Repeated reads of hot keys then bypass the database, so query volume and connection pressure drop sharply. Good answers also name write strategies: write-through updates the cache and database together, while write-around or explicit invalidation deletes the cached key on a write so the next read repopulates fresh data.
COMMON WRONG ANSWERS Treating the cache as a primary store rather than a volatile speed layer. Forgetting invalidation, which leads to stale reads after updates. Assuming caching always helps; it only helps when reads repeat and data is reused. Caching highly volatile or per-request-unique data wastes memory and lowers the hit ratio.
LIKELY FOLLOW-UPS How do you pick a TTL? How do you handle a cache stampede when a popular key expires? What is the difference between Redis and Memcached? How do you size the cache and what eviction policy do you choose, such as LRU?
ONE CONCRETE EXAMPLE A product page is viewed thousands of times per minute but changes rarely. You cache the rendered product object under the key product:123 with a sixty-second TTL. The first request misses and hits Postgres; the next thousands of requests hit Redis and never touch the database. When an admin edits the product, the write handler deletes product:123 so the following read fetches and caches the updated record.
Read the original → docs.aws.amazon.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.