Challenge 6: Flash-sale catalog with a cold cache
The situation
A flash sale sends shoppers to the product catalog, most of them to the same few hundred products. The catalog reads through a cache in front of one relational database. Even with the cache warm the database cannot keep up, and every deploy empties the cache, so far more misses reach it while the cache fills again.
Traffic
20,000 requests a second. Of the extra misses after a cold start or a lost cache node, 95% are for the same keys at the same moment.
| Operation | Share | Steps |
|---|---|---|
| Read | 98% | Read data |
| Write | 2% | Write data |
- Read98%Read data
- Write2%Write data
Data
A cache answers 95% of the reads that reach it.
What you are proving
A cache you can restart in the middle of a sale: the database behind it survives the moment the cache is empty, not only the hours when it is full.
Rules
- A CDN cannot answer these requests.Every response carries live stock and the shopper's cart.
- Orders stay in the relational database, and every write is stored in it.Taking stock for an order needs a transaction, so two shoppers cannot buy the last one.
- While the cache is cold, most of the extra misses are for the same hot products at the same moment.The sale sends everyone to the same few hundred products at once.
Builds on
Targets
- Serve all 20,000 requests a second
- At least 99.99% available, with no single point of failure
- At most 3,500 USD a month
- Every write kept in a relational database
- Any tier loses one instance: nothing dropped, no tier over 80% busy
- Caches start cold, at a hit ratio of 50%: nothing dropped