# The Stampede system design, running live

Source: https://systemdesignsim.com/blueprints/cache-stampede

Web apps · SDE-2 · Size the database for a cold cache

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](https://systemdesignsim.com/methodology).

* 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.

[Open it running](https://systemdesignsim.com/playground?blueprint=cache-stampede)[Or build it yourself first](https://systemdesignsim.com/challenges/the-stampede)

![The Stampede architecture on AWS at 2,500 requests a second](https://systemdesignsim.com/blueprints/cache-stampede.svg)

The Stampede architecture on AWS at 2,500 requests a second. Scroll the diagram to see every component. The small text under a box is its traffic, instance count or shard count.

## How it works

1. The API checks the cache before reading the database.
2. When the cache is cold, the database receives the reads until entries refill.
3. 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.

[Open it running](https://systemdesignsim.com/playground?blueprint=cache-stampede)[Take the challenge: The Stampede](https://systemdesignsim.com/challenges/the-stampede)

## 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.

## More in web apps

* [Airbnb search and booking](https://systemdesignsim.com/blueprints/airbnb)
* [Amazon product page and checkout](https://systemdesignsim.com/blueprints/amazon)
* [Black Friday](https://systemdesignsim.com/blueprints/black-friday-budget)
* [BookMyShow ticket booking](https://systemdesignsim.com/blueprints/bookmyshow)
* [Dropbox file sync](https://systemdesignsim.com/blueprints/dropbox-sync)
* [Flipkart Big Billion Days](https://systemdesignsim.com/blueprints/flipkart-bbd)
* [Gmail](https://systemdesignsim.com/blueprints/gmail)
* [Google Search](https://systemdesignsim.com/blueprints/google-search)
* [Hello, Load Balancer](https://systemdesignsim.com/blueprints/hello-load-balancer-reference)
* [IRCTC Tatkal booking](https://systemdesignsim.com/blueprints/irctc-tatkal)
* [Pastebin](https://systemdesignsim.com/blueprints/pastebin)
* [Search autocomplete](https://systemdesignsim.com/blueprints/autocomplete)
* [The CTO Budget Cut](https://systemdesignsim.com/blueprints/cto-budget-reduction)
* [The Retry Storm](https://systemdesignsim.com/blueprints/retry-storm-resilience)
* [Three-tier web app](https://systemdesignsim.com/blueprints/three-tier-web-app)
* [URL shortener](https://systemdesignsim.com/blueprints/url-shortener)
* [All blueprints](https://systemdesignsim.com/blueprints)

## One system design problem a week

A real scenario, its constraints, and where the obvious design breaks.

## Now break one yourself.

The first challenge takes about two minutes. No signup.

[Design your first system](https://systemdesignsim.com/challenges/hello-load-balancer)
