codequest / system design
Like a concert ticket drop or a Big Billion Days sale

🛒 Flash sale system design

A simplified, healthy design: 13 app servers behind a load balancer, a cache (90% hit rate), an async write queue, a CDN for static files, a primary database. At 5,500 requests per second it runs at p95 46 ms with 0.0% errors for about $730/month.

Healthy at 5,500 req/s
p95 latency (server)
46 ms
Error rate
0.0%
Est. cost / month
$730
excl. bandwidth
App servers
400 req/s each · $40/mo
13
Hit rate
DB read replicas
+1,250 reads/s each · also applies every write · $120/mo
0

Primary DB: 1,250 queries/s (1 query per request). How the numbers work

How it works

  • Everyone arrives at the same second, and many of them try to buy (write) at once.
  • A queue turns the stampede into an orderly line: users get a fast "you are in line" while orders are written in the background, as long as the database keeps up on average.
  • Product pages and images are cached and served from the CDN so browsing stays fast.
Try this

Drop the cache hit rate to 50%. Every miss lands on the one primary database.

Use the Build and Traffic tabs above. The overloaded part turns red and starts dropping requests.

More systems