Prepare a Flash-Sale Platform for a 50x Traffic Surge
System DesignModel answerLast updated
Audit a small web stack ahead of a 50x traffic spike, pick the three most dangerous weaknesses, propose fixes, and plan the work for three engineers over four weeks.
Scenario
You are the lead engineer for a "Flash Sales" web service that has been in production for two years. Today it serves about 1,000 requests per second (RPS). A large marketing campaign is coming, and the business expects peak traffic of 50,000 RPS.
Current setup
- Application tier: one monolithic web application running on three EC2 instances behind an Application Load Balancer.
- Database: a single primary MySQL instance on RDS, with no read replicas.
- Product images: read from the local disk of whichever application server handles the request.
- User sessions: held in each server's process memory, in plain in-memory maps.
- Monitoring: CPU and memory alarms that send email.
Your task
- Pick the three biggest risks that would make this system fail at the new load.
- For each, propose a mitigation.
- Explain how you would sequence the work, given three engineers and four weeks before the event.
Requirements
- Your analysis must cover availability, data consistency, and latency.
- Justify why your three risks outrank the other weaknesses you noticed.
- Discuss the blast radius of each change you propose, meaning how much can go wrong if the change misbehaves and how easily it can be rolled back.
Be ready for follow-ups such as how you would protect the database with a circuit breaker, and what you would do if writes still became the bottleneck.
Hints
Hint 1
Start with assumptions: is 50k RPS a peak or an average, what is the read/write split, and is overselling acceptable? Then do quick capacity math: three servers handling 1k RPS implies roughly 150 servers at 50k RPS, which a stateful tier cannot reach.
Hint 2
Look for the components that are single points of failure or that block horizontal scaling: the lone database, state stored inside app processes, and bulky static content served by application servers.
Hint 3
Rank work by impact divided by (effort times blast radius). Config-level, reversible changes go first; changes touching correctness, such as inventory handling, go behind feature flags and need the longest soak time. Say explicitly what is out of scope, such as splitting the monolith.
Hint 4
Explain why monitoring is not in your top three: it slows detection rather than causing the outage, and it is cheap to fix in week one.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
This is a review of an existing system, not a greenfield design. The goal is to find what will actually break at 50x load, fix those things in a safe order, and avoid redesigning everything. A good answer is diagnostic, ranked, and realistic about a four-week window.
1. Clarify and size
State assumptions out loud:
- Traffic shape: treat 50k RPS as peak, with a near-vertical ramp when the sale opens. Autoscaling that reacts after the fact will be too slow, so capacity must be in place beforehand.
- Mix: roughly 90% reads (product pages, images, stock display) and 10% writes (cart, checkout). That is about 5k writes/s, concentrated on a few hot SKUs.
- Correctness bar: overselling limited stock is unacceptable. Slightly stale descriptions or prices are fine.
- Bandwidth: ten images of about 150 KB per page view means tens of GB/s of image traffic at peak. An application fleet should not carry it.
- Capacity math: 3 servers for 1k RPS is about 333 RPS each. At 50k RPS that is roughly 150 servers if nothing else changes. The current tier cannot scale out cleanly because it holds state.
2. Top three risks
Risk 1: Single MySQL primary (availability, consistency, latency)
Why it breaks:
- All reads and writes hit one node. Connection limits and CPU saturate quickly at 50x.
- Decrements on a hot SKU serialize on one row lock. Latency rises, requests time out, clients retry, and load rises further.
- Without Multi-AZ, a host failure means a total outage.
- Read-then-write inventory logic oversells under concurrency.
Mitigation:
- Enable Multi-AZ for automatic failover.
- Add a cache (Redis/ElastiCache) for catalog and price reads with short TTLs, and read replicas for queries that tolerate lag.
- Make inventory updates atomic:
UPDATE inventory SET qty = qty - 1 WHERE sku = ? AND qty > 0, then check the affected-row count. - For very hot SKUs, hold a reservation counter in Redis (atomic
DECRor a Lua script), enqueue orders through a queue such as SQS, and write them to MySQL asynchronously. A reconciliation job compares reservations with committed orders. - Add admission control, such as a waiting room or token-bucket limiter at the edge, so the database sees bounded load no matter how big the crowd is.
Risk 2: In-memory sessions on a stateful app tier (availability, scalability)
Why it breaks:
- Sessions force sticky routing, which skews load and makes autoscaling ineffective because new instances receive no existing users.
- A crash or deploy drops roughly a third of sessions and their carts mid-sale.
- Memory use grows with active users, which is exactly what spikes.
Mitigation:
- Move sessions to Redis (or DynamoDB), or use signed stateless tokens for authentication plus a server-side cart store.
- With stateless servers, use an Auto Scaling Group with scheduled pre-scaling before the event, and ask the cloud provider to pre-warm the load balancer.
Risk 3: Images served from application disks (latency, availability)
Why it breaks:
- Image bytes consume threads, network, and disk I/O that dynamic requests need.
- Each server has its own copy, so new instances may be missing files and fleets drift.
- Distant users see high latency.
Mitigation:
- Move assets to object storage plus a CDN (S3 + CloudFront), rewrite URLs, and use versioned filenames with long cache lifetimes.
- This removes most bytes and a large share of requests from the origin, and is the best return per engineering hour.
Why these three, not monitoring
Email-only CPU/RAM alerts are a genuine weakness, but they slow detection rather than cause failure, and they are cheap to fix: dashboards for p99 latency, 5xx rate, DB connections, and replica lag, plus paging alarms. Do it in week one as an enabler. Each of the three risks above would by itself guarantee failure at 50k RPS, and together they cover consistency (database and inventory), availability (single primary, stateful tier), and latency (static assets, lock contention).
3. Prioritization for 3 engineers and 4 weeks
Rank by impact / (effort x blast radius). Ship reversible, isolated changes first, and put risky code behind feature flags early enough to soak.
| Week | Edge/Infra | App tier | Data |
|---|---|---|---|
| 1 | CDN migration; dashboards and paging alarms | Stand up Redis; dual-write sessions behind a flag | Multi-AZ; baseline load test to find the current breaking point |
| 2 | Auto scaling group, scheduled scaling, LB pre-warm | Canary reads from Redis sessions (5% to 100%); remove stickiness | Cache-aside for catalog; read replicas; connection pool limits |
| 3 | Waiting room / rate limiting | Graceful degradation (static "sold out" and "high demand" pages) | Atomic inventory path, order queue, reconciliation |
| 4 | Load test at 1.5x (75k RPS); game day (kill an instance, fail over the DB) | Runbooks; rollback rehearsal | Code freeze mid-week; fixes only |
Blast-radius reasoning:
- CDN and Multi-AZ are configuration-level and easy to revert, so they go first.
- Session migration touches every request. Dual-writing lets you verify before cutting over.
- The inventory change is the riskiest because it affects correctness. Gate it behind a flag and keep the conditional-SQL path as a fallback.
- Out of scope: splitting the monolith or sharding the database. Neither can be built and safely tested in four weeks.
4. Follow-ups
Circuit breaker for the database
- Closed: normal operation, tracking rolling p99 latency and error rate.
- Open: trips when, say, over 50% of calls in a 10-second window fail or exceed 200 ms. Fail fast while open.
- Half-open: after a cooldown, allow a few probes; close if they succeed.
- Fallbacks: serve cached catalog data, queue checkouts with an "order received" message, or show a high-demand page.
- Pair it with strict timeouts, separate connection pools for browse and checkout (bulkheads), and jittered retries to avoid retry storms.
If writes remain the bottleneck
- Shard orders by
user_idhash to spread load, and inventory by SKU so a decrement stays single-shard. - A single hot SKU still lands on one shard, so split its stock into several sub-counters (for example, N buckets) and have requests pick a bucket, accepting slightly more complex reads of total stock.
- Keep the queue-based, asynchronous order write path so spikes are absorbed rather than passed directly to the database.
Common mistakes
- Proposing a microservice rewrite or full sharding within four weeks.
- Listing many risks without ranking or justifying them.
- Ignoring inventory correctness while focusing only on throughput.
- Skipping load testing, rollback plans, or a code freeze.
- Relying on reactive autoscaling for a spike that arrives in seconds.