Web apps · SDE-2 · Size the database for a cold cache
The Stampede system design, running live
With a warm cache the database sees only 10% of reads. When the cache is flushed, every read hits the database for a few seconds; three read replicas give it the room to absorb that while the cache refills.
An illustrative teaching design, not a verified diagram of any company's internal architecture. Traffic, capacity and cost are simulator estimates. Model and assumptions.
- Traffic
- 2,500 req/sMedium scale
- AWS bill
- $1,110/mo
- p99
- 73 ms
- Components
- 3
2,500 requests a second while the cache is warm; the challenge separately flushes it mid-run.
How it works
- The API checks the cache before reading the database.
- When the cache is cold, the database receives the reads until entries refill.
- The reference graph uses four database instances to absorb that temporary load.
What each part does
- Users
- 2,500 requests a second.
- API Server
- Four API servers read through the cache.
- Cache
- Answers 90% of reads while warm.
- Database
- Four database instances carry reads when the cache is cold.
What breaks first
The API tier reaches its capacity as requests rise.
A cache flush sends the read load to the database. The graph shows the reference capacity, but the blueprint traffic ramp does not flush the cache; test that event in the challenge.
The simulator checks this every build: it runs the design at 2,500 req/s, then ramps traffic to 4x (10,000 req/s) and records which part fails first. In the playground, press Break it to watch the same thing happen.
Trade-offs
What it gets right
- The warm cache keeps routine read pressure low.
- Database capacity is considered against the cold-cache case.
What it costs you
- Replicas increase cost even when the cache is warm.
- A static graph cannot show cache refill timing or request coalescing.
In the real world
- Read-heavy services often combine a cache with database replicas.
- Cache expiration and coordinated misses are common causes of temporary database overload.
In the interview
- Estimate database reads in both warm-cache and cold-cache states.
- Discuss request coalescing, jittered expiration, and the acceptable refill delay.
Run it yourself
The playground opens this design with 2,500 requests a second already flowing. Press Break it, or change one part yourself, and watch which number goes first.
Questions people ask
How does The Stampede work at the system design level?
The API checks the cache before reading the database. When the cache is cold, the database receives the reads until entries refill. The reference graph uses four database instances to absorb that temporary load.
What breaks first in a The Stampede design?
The API tier reaches its capacity as requests rise. A cache flush sends the read load to the database. The graph shows the reference capacity, but the blueprint traffic ramp does not flush the cache; test that event in the challenge.
What are the trade-offs of this The Stampede architecture?
The warm cache keeps routine read pressure low. Database capacity is considered against the cold-cache case. Replicas increase cost even when the cache is warm. A static graph cannot show cache refill timing or request coalescing.
What do interviewers look for in a The Stampede system design answer?
Estimate database reads in both warm-cache and cold-cache states. Discuss request coalescing, jittered expiration, and the acceptable refill delay.