Skip to content
System Designer

Scale the front · 3 minutes

Remembering answers

A cache keeps recent answers in memory so the database is asked less.

Open this lesson
A cache keeps recent answers in memory so the database is asked less.

The same question again

Most people ask for the same few things: today's top stories, a popular profile. Asking the database each time repeats work. A cache keeps the last answer in fast memory and hands it back.

Fresh versus fast

Fill the cache, change the original, then read again. A TTL bounds how long this cached answer can survive without invalidation.

Try the idea

The database is nearly full. Repeated answers may be at most 60 seconds old. Reduce its load while keeping that freshness limit.

Key numbers

Memory read
≈ 0.5 ms. in-zone cache, approx.
Database read
≈ 5 ms. approx.
Typical hit rate
≈ 85 to 95 percent. for read-heavy data, approx.

Check your reasoning

Think through these questions before opening the lesson. In the game you can test the idea and compare your reasoning.

  • A cache answers 90 percent of questions. How much work reaches the database?
  • What is the cost of a long TTL?
  • Which data suits caching best?

The key point

A cache trades a little freshness for a lot of speed and a calmer database.

Practise this idea

Continue through the lesson tracks