Estimation is the step that turns “a big system” into “100 writes and 10K reads per second, 50 TB over 4 years”. This post collects the numbers worth memorising, mental-math tricks, and redoes the URL shortener step by step to show which decision each number leads to. Read the system design interview process first.
At a glance:
flowchart LR
A["State your assumptions"] --> B["Convert to per second"]
B --> C["Apply peak factor"]
C --> D["Little's Law: threads, connections"]
C --> E["Storage, RAM, bandwidth"]
D --> F["Decide: servers, cache, sharding"]
E --> F
1. What estimation is for
Key idea: you estimate to know the system’s size, evaluate the design, find bottlenecks and decide on expensive things like sharding. It doesn’t give the right number; it gives the right order of magnitude.
The four goals of the estimation step:
- Set the design’s target (how many QPS it must handle).
- Evaluate the design (can one database cope?).
- Find potential bottlenecks (reads, writes, bandwidth or storage).
- Decide whether the database needs partitioning or sharding.
Principles:
- Real-world estimates are never exact. The goal is the size, not the last digit.
- Lean on experience and reference systems. You can only estimate how many PostgreSQL nodes you need if you know what one usually handles.
- Break down, then add up: split by operation type and by data type.
- The 80/20 rule: 20% of the data gets 80% of the reads, so caching that 20% absorbs most of the load.
- Mind the resources you have: with spare resources, overestimate by ~20%; with tight resources, prepare a fallback (fail-safe, plan B).
2. Numbers to know
Key idea: a few groups of numbers (time, sizes, availability, latency) are enough to do any estimate in your head. The rest is multiplying powers of ten.
| Quantity | Real value | For mental math |
|---|---|---|
| Seconds in a day | 86,400 | 10⁵ |
| Seconds in a month | ~2.6 million | 2.5 × 10⁶ |
| Seconds in a year | ~31.5 million | 3 × 10⁷ |
| 1 million events/day | 11.6/second | ~12/second |
| 1 billion events/day | 11,600/second | ~12K/second |
| Data type | Size |
|---|---|
int |
4 B |
bigint/long, double |
8 B |
boolean |
1 B |
timestamp (PostgreSQL) |
8 B |
| UUID | 16 B |
| UTF-8 character | 1 B (ASCII) up to 4 B; accented Vietnamese is usually 2–3 B |
| Availability | Downtime per year | Per month |
|---|---|---|
| 99% | ~3.65 days | ~7.2 hours |
| 99.9% | ~8.8 hours | ~43 minutes |
| 99.95% | ~4.4 hours | ~22 minutes |
| 99.99% | ~52 minutes | ~4.3 minutes |
| 99.999% | ~5.3 minutes | ~26 seconds |
| 99.9999% | ~31 seconds | ~2.6 seconds |
Units: K = 10³, M = 10⁶, G = 10⁹, T = 10¹², P = 10¹⁵. The course’s trick: M × K = G (a million records of 1 KB each is 1 GB).
Latency and capacity: reference numbers
Latency numbers worth knowing (orders of magnitude, modern hardware):
| Operation | Time |
|---|---|
| L1 cache read | ~1 ns |
| RAM read | ~100 ns |
| 4 KB random read from NVMe SSD | ~20–100 µs |
| 1 MB sequential read from SSD | ~0.1–0.3 ms |
| Round trip within a datacenter | ~0.5 ms |
A Redis GET over the internal network |
~0.2–0.5 ms |
| PostgreSQL primary-key lookup (data in RAM) | ~0.5–1 ms |
| HDD seek | ~5–10 ms |
| Round trip Vietnam – US | ~150–250 ms |
Per-node capacity (rough, benchmark your real load):
- One Spring Boot instance doing simple CRUD: around 1K–5K RPS, depending on CPU and how heavy the logic is.
- One PostgreSQL or MySQL node: tens of thousands of QPS for simple indexed reads; a few thousand TPS for writes with an fsync per commit (group commit helps a lot).
- One Redis node: around 100K commands/second for O(1) commands; much more with pipelining.
- One Kafka broker: hundreds of MB/second of sequential writes.
That gives a quick rule: below a few thousand write TPS, one primary database with replicas is usually enough; above that, or once data passes a few TB, sharding comes up.
3. Quick calculation tricks
Key idea: round, group the powers of ten, convert to “per second” first, multiply by a peak factor, and when information is missing, assume and say so.
- Write the unit next to every number. Mixing up KB and MB is the most common mistake.
- Round to powers of 2 or 10. 86,400 becomes 10⁵; keep 1.1 KB’s coefficient and group the exponents.
- Group exponents: 10⁶ ÷ 10² × 10³ = 10^(6 − 2 + 3) = 10⁷.
- Convert to operations per second (OPS) first, then multiply out to storage and bandwidth.
- Apply a peak factor: peak hours are usually 2–3× the average; a flash sale can be 10–100×.
- Assume when missing: “I’ll assume 1 KB per record” and keep going instead of stalling.
Rule of 72: time for a quantity to double ≈ 72 ÷ (growth rate in %). Data growing 20%/year doubles in about 3.6 years (the exact answer is ~3.8). Use it to answer “how long will current capacity last”.
4. Worked example: URL shortener
Key idea: from four numbers (10 million writes/day, 100:1 read:write, short code at most 8 characters, kept for 4 years) you derive QPS, storage, cache memory, bandwidth, and even the code length.
Questions and answers (the prompt’s assumptions):
- Average writes per day? 10 million.
- Read:write ratio? 100:1.
- Length of a short URL? At most 8 characters.
- How long are links kept? 4 years.
Traffic. 10⁷ writes/day ÷ 10⁵ seconds = 10² = 100 write TPS. Reads are 100× → 10K read QPS. With a peak factor of 3: ~300 write TPS, ~30K read QPS.
One record. Long URL 1 KB, short code 10 B, user_id 16 B, created_at, expires_at, updated_at 8 B each → ~1.1 KB.
Storage for 4 years. 1.1 KB × 10⁷ × 400 days × 4 years = (1.1 × 4 × 4) × 10^(3 + 7 + 2) = 17.6 × 10¹² = 17.6 TB. The slide rounds a year to 400 days to make the multiplication easy (the real figure is ~16 TB). With a replication factor of 3 → ~53 TB.
Cache memory. Apply 80/20 to one day of new links with a 1-day TTL: 10⁷ × 1.1 KB × 0.2 = 0.22 × 10¹⁰ = 2.2 GB. One Redis node handles it easily.
Bandwidth. Ignore writes; they’re 1% of reads. A GET request is about 1 KB (no cookies or tokens): ingress 10K × 1 KB = 10 MB/s. The slide computes egress as 10K × (1 + 1.1) KB = 21 MB/s.
Code length (added). 4 years needs 10⁷ × 365 × 4 ≈ 1.5 × 10¹⁰ codes. With base62: 62⁶ ≈ 5.7 × 10¹⁰ (~4× headroom), 62⁷ ≈ 3.5 × 10¹² (~240× headroom). 7 characters is the comfortable choice and still under the 8-character limit.
| Quantity | Result |
|---|---|
| Writes | 100 TPS (peak ~300) |
| Reads | 10K QPS (peak ~30K) |
| Storage for 4 years | ~17.6 TB, ×3 replicas ≈ 53 TB |
| Cache | ~2.2 GB |
| Bandwidth in / out | ~10 MB/s / ~15–21 MB/s |
| Code length | 7 base62 characters |
5. From numbers to decisions
Key idea: a number is only worth something if it leads to a decision: how many servers, whether to cache, whether to shard. State the decision right after each calculation.
For the URL shortener:
- 30K read QPS at peak: one PostgreSQL shouldn’t take that directly. A Redis cache with a 90% hit ratio leaves ~3K QPS for the database; one primary with 1–2 replicas covers the reads.
- 300 write TPS: one primary easily handles it, no sharding needed for writes.
- 53 TB after 4 years: this is the real reason to split data. A single PostgreSQL node is comfortable at a few TB. Options: partition by time and drop expired partitions, or use a distributed key-value store (Cassandra, DynamoDB), since access is by key only.
- Application servers (Little’s Law): 30K QPS × 20 ms = 600 requests in flight. With 200 Tomcat threads per instance kept under 50% → 100 requests/instance → 6 instances, plus spare capacity for one node failing → 7–8 instances. This number is still a hypothesis to confirm with a capacity test, as in Performance testing.
Sizing a thread pool from wait time and compute time
The two formulas on the performance slide follow directly from Little’s Law for a CPU:
- CPU-bound work: threads ≈ number of cores (+1 to cover a thread stalled on a page fault). More threads only add context switches.
- I/O-bound work: threads ≈ cores × (1 + wait time ÷ CPU time).
Example: 8 cores, each request uses 5 ms of CPU and waits 45 ms on the database and other APIs → 8 × (1 + 45/5) = 80 threads to keep the CPU busy. More just queues requests in RAM; fewer leaves the CPU idle while requests wait.
With virtual threads (Java 21) the thread limit mostly disappears, but the limit moves to the resource behind it: the database connection pool is still sized with Little’s Law, as in section 3. Details in ExecutorService and virtual threads.
Exercises
Exercise 1: Estimating driver location updates
Task (my own): a food delivery app has 500K drivers online at peak, each sending a location every 4 seconds (latitude, longitude, timestamp, driver id). Compute write QPS, ingress bandwidth, and storage for 30 days of history. Should this go straight into PostgreSQL?
Solution to exercise 1
- Write QPS: 5 × 10⁵ ÷ 4 = 125K writes/second at peak.
- One record: lat and lng 8 B each, timestamp 8 B, id 8 B → 32 B of data; the real packet with headers is about 200 B.
- Ingress: 125K × 200 B = 25 MB/s.
- 30 days of history: assume the average is a third of peak → ~40K/second × 10⁵ seconds × 30 days × 32 B ≈ 3.5–4 TB of raw data, before indexes and replicas.
Decision: 125K writes/second is far beyond one PostgreSQL. Split two needs: current location only needs the latest value, so keep it in Redis (GEO or a hash per driver) and overwrite; history goes through Kafka and is batch-written to an analytics store (ClickHouse, object storage). The transactional database only gets business events like “picked up”.
Exercise 2: How long will the disk last
Task (my own): a database uses 4 TB on a 10 TB disk and grows 25% a year. When does it hit 80% of the disk?
Solution to exercise 2
80% is 8 TB, i.e. double today. Rule of 72: 72 ÷ 25 ≈ 2.9 years. Exactly: ln 2 ÷ ln 1.25 ≈ 3.1 years. Conclusion: about two and a half years to plan, since moving data (partitioning, archiving, new disks) also takes months.
Exercise 3: Connection pool size
Task (my own): a service gets 1,500 requests/second at peak, each running 2 queries, with query p50 = 4 ms and p99 = 40 ms. What pool size per instance is reasonable across 6 instances?
Solution to exercise 3
- λ = 1,500 × 2 = 3,000 queries/second across the cluster.
- At p50: L = 3,000 × 0.004 = 12 busy connections. At bad moments (p99): 3,000 × 0.04 = 120.
- Across 6 instances: 2 to 20 per instance. Pick about 10–15, with a short connection-acquire timeout (a few hundred ms) so requests fail fast when the database slows down instead of tying up every thread.
- Check the database side: 6 × 15 = 90 connections, under PostgreSQL’s default
max_connectionsof 100 but close; more instances will need PgBouncer.
Remember
- Convert 10 million/day to per second in your head, and remember the peak factor.
- Read the nines table: how many minutes of downtime a year 99.9% and 99.99% allow.
- Use Little’s Law to get connections, threads or servers from QPS and latency.
- Redo the URL shortener: QPS, storage, cache, bandwidth, code length.
- Say which decision each number leads to (cache, replicas, sharding, instance count).
Interview questions
Junior
How many requests per second is 1 million requests a day?
About 12 requests/second, since a day has ~86,400 ≈ 10⁵ seconds.
That’s the average; peak hours are usually 2–3×, so design for about 30–40 RPS.
How much downtime does 99.99% availability allow?
About 52 minutes a year, or 4.3 minutes a month.
Short enough that manual recovery is out: you need automatic failover and zero-downtime deployments.
Mid
What is Little’s Law and how do you use it?
L = λ × W: requests in flight equal arrival rate times time in the system. I use it to size connection pools, thread pools and server counts.
Example: 3,000 queries/second at 5 ms each → 15 busy connections. The important consequence: if latency goes up 10×, you need 10× the connections, which is how a slow database drains the pools of the whole application cluster.
Estimate 4 years of storage for a URL shortener with 10 million links a day.
About 1.1 KB per record × 10⁷ × 365 × 4 ≈ 16 TB, times 3 replicas ≈ 50 TB.
Conclusion: writes are only 100 TPS, so no sharding for writes, but 50 TB means planning time-based partitioning or a distributed key-value store.
How long should the URL shortener’s code be?
7 base62 characters: 62⁷ ≈ 3.5 trillion codes, about 240× the 15 billion links needed over 4 years.
6 characters (~57 billion) still fits but with only ~4× headroom, which gets tight if load grows or if codes are random (collisions rise as the space fills up).
Senior
You’ve estimated 30K read QPS. What do you decide next?
Put a cache in front of the database and recompute what still reaches the database, then choose replica and application instance counts.
At a 90% hit ratio the database sees only ~3K QPS, so one primary with 1–2 replicas is enough. Application instances come from Little’s Law with the target latency, plus spare capacity for losing a zone.
When do you overestimate and when do you size tightly?
Overestimate what’s hard to change (shard key, schema, ID length), size tightly what’s easy to add (stateless instances, cache nodes).
Underestimating something hard to change means migrating data while live, which is very expensive. Easy-to-add things are handled by autoscaling, so overestimating them only costs money.
Useful phrases for interviews
- “Let me do a quick back-of-the-envelope estimate before choosing components.”
- “A day is roughly ten to the fifth seconds, so ten million writes a day is about a hundred per second.”
- “I’ll assume peak traffic is about three times the average.”
- “With a 100 to 1 read-to-write ratio, this is a read-heavy system.”
- “I only need the right order of magnitude here, not an exact number.”
- “With a replication factor of three, we’re looking at roughly fifty terabytes.”
- “By Little’s Law, 30K QPS at 20 milliseconds means about 600 requests in flight.”
- “Seven base62 characters give us plenty of headroom.”
- “Writes alone don’t justify sharding; storage growth does.”
- “As a rule of thumb, one Redis node handles about a hundred thousand operations per second.”
Notes based on the System Design course (Ronin Engineer), rewritten in my own words.