Size the system from numbers
How many servers, how much storage, how big a cache?
Say it like this
Before I draw boxes I turn the product numbers into QPS, bytes and a hot set, size for peak with one zone down, and let those numbers decide whether I need sharding and a cache at all.
Basic solution
Start from DAU and actions per user, derive QPS (× peak multiplier), bytes per record × retention, and the hot fraction for cache; then add headroom.
From product numbers to instance counts
Each box is a multiplication. Demand becomes rates and bytes; the hot set sizes the cache; a load test gives per-instance capacity; peak and zone-loss headroom give the fleet size.
How it works
- Start from demand the product can state in plain terms: daily active users, actions per user per day, and the size of each action's payload in bytes.
- Convert demand to rates. Actions per day divided by 86,400 seconds gives the average per second; multiply by a peak factor of 3 to 10, depending on how bursty the product is, to get the rate you must actually serve.
- Convert demand to storage. Records per day multiplied by bytes per record and by the retention period gives the size of the store; then add indexes (often 50 to 100% on top of the data) and replication (usually three copies).
- Derive the hot set, the part of the data that is read in a typical day. The 80/20 rule is the usual starting point: 20% of records take 80% of reads. That fraction multiplied by record size is the cache you need for a high hit rate.
- Add bandwidth. Requests per second multiplied by response size gives egress; uploads per second multiplied by upload size gives ingress.
- Add headroom. Design for peak, then assume one availability zone of three is down, so the remaining two must still serve peak on their own. That works out to 1.5 times the peak instance count.
- Validate with a load test against one instance to learn its real capacity under your request mix, then divide peak by that number to get the fleet size. The Estimator page in this app does steps 2 to 5 from your inputs.
Why do this in the interview
- The numbers decide the design: 3 TB fits one sharded database and 300 TB does not; 4K reads per second is one replica and 400K is a cache tier.
Worked example
Notification system, full walk
- Demand: 50M users × 5 notifications per day = 250M per day. Average 250M / 86,400 ≈ 2,900 per second. Peak: a marketing campaign to 20M users in 10 minutes is 33K per second, 11× average; that is the number to size the queues and routers for.
- Channels: 60% push, 30% email, 10% SMS. Peak SMS is 3.3K per second, but the provider accepts 1,000 per second, so the SMS queue must absorb a backlog: 10 minutes × (3,300 − 1,000) ≈ 1.4M messages, drained over 23 minutes. Marketing SMS therefore cannot promise sub-minute delivery; transactional gets its own queue and quota.
- Storage: one notification row of 300 bytes plus one delivery row per channel at 200 bytes: 250M × 500 B ≈ 125 GB per day. Keep 30 days hot: 3.75 TB, ×3 replicas ≈ 11 TB. Archive older rows to object storage.
- Hot set: the dedup keys for 24 hours: 250M × 60 B ≈ 15 GB in Redis, plus device tokens for 50M users × 2 devices × 200 B ≈ 20 GB. Two Redis nodes with replicas.
- Compute: a router instance handles about 2K notifications per second in a load test (template rendering dominates). Peak 33K needs 17 instances; with one zone of three down, 25 instances; round to 27 across three zones.
- Bandwidth: 33K per second × 2 KB per provider call ≈ 66 MB/s egress at peak. Fine for a region.
- Cost sanity: SMS at $0.01 × 25M per day = $250K per day, which is the number that drives the whole preferences and frequency-cap design, far more than any server cost.
Variants and when each wins
Back-of-envelope only
- Powers of ten and rules of thumb, done in minutes. It wins in the interview and the first design review, because being wrong by 2 to 3× does not change decisions that are about orders of magnitude.
Load-test derived
- One instance is measured under a representative request mix and the fleet size is peak divided by that number. It wins before launch, because the real per-instance capacity is usually 3 to 10× lower than a naive estimate.
Trend-based forecasting
- Growth is fitted on existing metrics and projected a quarter ahead with a safety margin. It wins once the system is live and has history.
Capacity modelling (queueing theory)
- Utilisation and queueing delay are modelled explicitly, because latency rises sharply past about 70% utilisation. It wins where tail latency matters more than raw throughput.
Recommendation: back-of-envelope in the interview and design doc, load test before launch, trend forecasting every quarter after, and never run steady state above 60 to 70% utilisation.
Failure modes
Sizing for average instead of peak
- The system falls over every evening or during every campaign. It happens because instance counts were derived from the average rate. Size for the peak factor you measured, plus the headroom for losing a zone.
Forgetting indexes and replicas in storage
- The disk is full at a third of the planned data volume. It happens because the estimate used the raw record size only. Multiply by the index overhead and the replication factor, and measure the actual bytes per row after loading a sample.
Compute estimated from a benchmark, not your workload
- 17 instances were planned and 60 turn out to be needed. It happens because per-instance capacity came from a vendor number or a hello-world test. Load test with the real request mix, payload sizes and dependency latencies.
No headroom for the dependency's limit
- Queues grow without bound during a campaign. It happens because the provider's rate limit was never part of the model. Model every external limit and the backlog drain time it implies; that number may change the product promise.
Ignoring cost as a constraint
- The design is technically sound and three times over budget. It happens because the estimate covered capacity but not money. Put the dominant cost line (SMS, egress, GPU hours) into the estimate; it often reshapes the design more than any latency target.
Interviewer follow-ups
Answer out loud before you open each one.
What peak factor do you use and why?
Three for products with smooth daily cycles like a URL shortener, up to ten for event-driven ones like a notification system with campaigns or a ride platform on New Year’s Eve. State the assumption and size the burst absorbers, queues and caches, for the worst case you expect.
How do you size a cache from the numbers?
Estimate the fraction of data touched in a day, usually 10 to 20%, multiply by record size, and add 20 to 30% for keys and overhead. Then check the implied hit rate against the database read capacity you have; if the database can take the misses, the cache can be smaller.
When do the numbers say you need sharding?
When a single primary cannot hold the data with headroom, roughly beyond a few terabytes, or cannot take the write rate, roughly beyond 10 to 20K writes per second for a relational store, or when one node’s failure blast radius is too large. Below that, replicas and a cache are simpler.
How do you account for a zone outage?
Spread instances over three zones and provision so any two zones can serve peak, which means 1.5× the peak instance count. The same applies to cache and queue capacity; a zone loss during a campaign is the scenario that pages people.
Connections
The same parts on other clouds
The diagrams above name AWS services as one concrete example. Every part has a close equivalent elsewhere. In an interview, name the role first, such as “a managed Redis cache”, then the product you would pick.
| AWS | Used here as | Google Cloud | Microsoft Azure | Open source and others |
|---|---|---|---|---|
| Amazon ElastiCache | Hot set | Memorystore | Azure Managed Redis | Redis, Valkey, Memcached |