Problems / Real world, hard
A storefront as first built: product pages read DynamoDB with no product cache, and the product, cart and checkout APIs, search, recommendations, the orders database, payments and fulfilment workers at an eighth of their real size. Shoppers arrive at real traffic and half of all requests fail, checkout included.
Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
Grow it into the real architecture: every goal must hold at 4,000 requests a second. You may add components, connect them and resize anything.
Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 6; 2 of them are hidden until then.
4,000 requests a second for 20 seconds: 70% browse (reads), 20% cart (writes), 10% checkout (writes).
What each component does in this design, and what calls it. The simulator mimics each one from these settings.
| Component | Its job here | Settings |
|---|---|---|
| DDoS protectionDDoS protection | Traffic enters here.Calls WAF.Volumetric floods are absorbed at the network edge, spread over many locations, before they reach you. | 100000 slots |
| WAFWAF | DDoS protection forwards to it.Calls API gateway.A WAF inspects HTTP requests for attacks such as SQL injection and cross-site scripting. | 100000 slots |
| API gatewayAPI gateway | WAF forwards to it.Calls Product API, Cart API, Checkout API.Gateways centralise auth, rate limits and routing so each service does not reimplement them. | 50000 slots · 1,200,000 calls/min |
| Product APIApp service | API gateway forwards to it for /browse.Calls Catalog (DynamoDB), Search (OpenSearch), Recommendations.Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Catalog (DynamoDB)Document database | Product API calls it for reads.Document databases store nested JSON-like records, so one read can fetch a whole aggregate. | 250 slots |
| Search (OpenSearch)Search index | Product API calls it on 30% of requests.Search engines build an inverted index: each word points to the documents that contain it. | 64 slots |
| RecommendationsRanking model | Product API calls it on 50% of requests.Feeds rank a few hundred candidates per load with a learned model; retrieval narrows millions of posts first. | 128 slots |
| Cart APIApp service | API gateway forwards to it for /cart.Calls Carts (session store).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Carts (session store)Session store | Cart API calls it.A shared session store lets any app server handle a user's next request. | 1250 slots |
| Checkout APIApp service | API gateway forwards to it for /checkout.Calls Orders and stock (Aurora), Payment service, Order events (publishes).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 5.0 s |
| Orders and stock (Aurora)SQL database | Checkout API calls it.Postgres runs one process per connection, which is why poolers like PgBouncer sit in front of busy databases. | 4 vCPU · 50 connections |
| Payment servicePayment gateway | Checkout API calls it.Calls Payment service (backup) (fallback).Payment providers accept an idempotency key so a retried charge is not taken twice. | 250 slots |
| Payment service (backup)Payment gateway | Payment service falls back to it on failure.Payment providers accept an idempotency key so a retried charge is not taken twice. | 250 slots |
| Order eventsMessage queue | Checkout API publishes to it.Calls Fulfilment workers.If a consumer does not finish within the visibility timeout, the message is delivered again. | – |
| Fulfilment workersWorker | Order events consumes from it.Calls Order emails.Queues deliver at least once, so a worker can see the same message twice. | 16 concurrent jobs |
| Order emailsNotification service | Fulfilment workers calls it.Email, SMS and push providers all throttle senders and can delay delivery. | 25 slots · 125,000 calls/min |