Part 5 of 7 · 2 min read
Prompts 21-30
Money, scale and reliability.
| # | Prompt | Level | Ask and estimate | Core idea |
|---|---|---|---|---|
| 21 | Design an online ticket booking system for concerts. | H | Seats, peak buyers, hold time | Seat hold with a lease, atomic reservation, a waiting room for the peak. |
| 22 | Design a flash sale for a limited stock item. | H | Requests a second, stock | Pre-check in cache, atomic decrement, a queue, reject early. |
| 23 | Design a hotel booking system. | M | Hotels, rooms, searches | Search index apart from the booking store, inventory per room per night. |
| 24 | Design a coupon and discount engine. | M | Rules, orders a second | Rule evaluation order, usage counters, idempotent redemption. |
| 25 | Design an A/B testing platform. | M | Experiments, users, events | Stable assignment by hash of user id, event logging, daily analysis jobs. |
| 26 | Design a log aggregation and search system. | H | Servers, lines a second, retention | Agents, queue, partitioned index by time, hot and cold storage. |
| 27 | Design a metrics and alerting system. | H | Series, points a second | Time-series store, downsampling, alert rules evaluated on streams. |
| 28 | Design an API gateway with rate limits and auth. | M | Requests a second, clients | Token bucket per key, central config, a local cache of auth. |
| 29 | Design a recommendation service for an online shop. | H | Products, users, freshness | Offline model plus online lookup of candidate lists, a feedback loop. |
| 30 | Design a fraud check for card payments. | H | Payments a second, latency | A fast rules and model path under 100 ms, a slow review path, feedback. |
What a good answer adds.
- For 21 and 22: show the sequence of one purchase, and say what happens when a payment fails (the seat or stock returns after the hold expires).
- A flash sale of 1,000 items with 500,000 requests in the first second: a design that sends everything to the database fails. Check stock in a cache, reject the rest at once, and send about 1,000 to 2,000 into a queue.
- For 26 and 27: size the data. 20,000 servers each logging 100 lines of 200 bytes a second is 400 MB/s, or 34.6 TB a day before compression.
Check yourself: 1. What stops two buyers from taking the last ticket? 2. In prompt 22, why reject early? 3. Check the log arithmetic: 20,000 × 100 × 200 bytes.