Challenge 8: Checkout with a slow dependency
The situation
Shoppers browse a store’s catalog and check out. Browsing reads through a catalog cache, and each checkout calls a separate inventory service, which sometimes slows down badly. When it does, the storefront runs out of threads and browsing stops as well.
Traffic
3,000 requests a second.
| Operation | Share | Steps |
|---|---|---|
| Read | 70% | Read data |
| Write | 30% | Write data |
- Read70%Read data
- Write30%Write data
Data
A cache answers 85% of the reads that reach it.
What you are proving
A failure stays where it starts: when one service slows down, only the requests that need it fail, and everything else keeps working.
Rules
- A CDN cannot answer these requests.Every page is made for the shopper viewing it.
- Orders stay in the relational database, and every write is stored in it.The orders and the stock counts are already there.
- Browsing only reads; a checkout is the write, and only a checkout calls the inventory service.Checking out takes stock, and the inventory service owns the stock counts.
- The inventory service stays a separate service, called over the network.It has its own database, which no other service writes to directly.
Builds on
Targets
- Serve all 3,000 requests a second
- At least 99.99% available, with no single point of failure
- At most 1,350 USD a month
- One service calls another
- Every write kept in a relational database
- Any tier loses one instance: nothing dropped, no tier over 80% busy
- A called service slows to 2,000 ms: requests that do not need it still succeed