Scale Lab
Back-of-the-envelope calculators and reference tables for systems design estimation.
Calculators
Availability Calculator
Convert availability percentage (nines) into allowed downtime per year, month, and day. Includes planned maintenance windows. Essential for SLA discussions in system design.
Bandwidth Calculator
Estimate network bandwidth requirements from QPS and response payload size. Critical for CDN planning, load balancer sizing, and network capacity design.
Caching Impact Calculator
Quantify how caching reduces database load and improves response latency. Demonstrates the power of caching in system design trade-off discussions.
Latency Budget Calculator
Break down an end-to-end latency target into component budgets. Helps identify where time is spent and how much room remains for application logic.
QPS Calculator
Estimate queries per second (QPS) from daily active users and usage patterns. A foundational calculation for capacity planning in system design interviews.
Storage Estimator
Estimate storage requirements over time based on data ingestion rate, record size, and retention policy. Essential for database and object storage capacity planning.
Reference Tables
Latency Numbers Every Programmer Should Know
Key latency figures for reasoning about system performance. Originally compiled by Jeff Dean and updated for modern hardware. Invaluable for back-of-envelope calculations in system design interviews.
| Operation | Latency | Nanoseconds(ns) | Category | Notes |
|---|---|---|---|---|
| L1 cache reference | 0.5 ns | 0.5 | CPU | Fastest memory access; data already in the CPU core's local cache |
| Branch mispredict | 5 ns | 5 | CPU | Pipeline flush and restart cost when CPU predicts wrong branch |
| L2 cache reference | 7 ns | 7 | CPU | ~14x L1 cache; shared between cores on most architectures |
| L3 cache reference | 20 ns | 20 | CPU | Shared across all cores; last level before main memory |
| Mutex lock/unlock | 25 ns | 25 | OS | Uncontended; contended locks can be orders of magnitude slower |
| Main memory reference (DRAM) | 100 ns | 100 | Memory | ~200x L1 cache; DDR5 typical latency |
| Compress 1 KB with Snappy | 3,000 ns (3 us) | 3000 | CPU | Snappy prioritizes speed over compression ratio |
| Send 1 KB over 1 Gbps network | 10,000 ns (10 us) | 10000 | Network | Raw bandwidth cost; does not include round-trip overhead |
| Read 4 KB randomly from SSD | 16,000 ns (16 us) | 16000 | Storage | NVMe SSD; SATA SSD is ~100 us |
| Read 1 MB sequentially from memory | 250,000 ns (250 us) | 250000 | Memory | ~62.5 GB/s effective bandwidth for sequential read |
| Round trip within same datacenter | 500,000 ns (500 us) | 500000 | Network | ~0.5 ms; typical for service-to-service calls within a region |
| Read 1 MB sequentially from SSD | 1,000,000 ns (1 ms) | 1000000 | Storage | NVMe SSD; ~1 GB/s effective sequential throughput |
| HDD seek | 4,000,000 ns (4 ms) | 4000000 | Storage | Mechanical disk; seek time dominates random I/O |
| Read 1 MB sequentially from HDD | 5,000,000 ns (5 ms) | 5000000 | Storage | ~200 MB/s sequential; good for throughput, bad for random I/O |
| Read 1 MB sequentially from network (1 Gbps) | 10,000,000 ns (10 ms) | 10000000 | Network | Dominated by bandwidth limit of 1 Gbps link |
| Redis GET (in-memory, local datacenter) | 500,000 ns (0.5 ms) | 500000 | Data Store | Typical for a cache hit; includes network round trip |
| Simple database query (indexed) | 5,000,000 ns (5 ms) | 5000000 | Data Store | Simple key lookup on indexed column; varies widely by engine |
| Send packet CA -> Netherlands -> CA | 150,000,000 ns (150 ms) | 150000000 | Network | Transatlantic round trip; limited by speed of light in fiber |
| TLS handshake | 250,000,000 ns (250 ms) | 250000000 | Network | TLS 1.2 full handshake (2 round trips); TLS 1.3 is ~1 RTT |
| Retry with exponential backoff (1st retry) | 1,000,000,000 ns (1 s) | 1000000000 | Application | Common starting point for retry delays; doubles each attempt |
Powers of 2
Essential reference for back-of-envelope calculations. Every systems designer should know these by heart: how many bytes in a kilobyte, megabyte, gigabyte, and beyond.
| Power | Exact Value | Approx Value | Common Name |
|---|---|---|---|
| 2^0 | 1 | 1 | |
| 2^1 | 2 | 2 | |
| 2^2 | 4 | 4 | |
| 2^3 | 8 | 8 | |
| 2^4 | 16 | 16 | |
| 2^5 | 32 | 32 | |
| 2^6 | 64 | 64 | |
| 2^7 | 128 | 128 | |
| 2^8 | 256 | 256 | |
| 2^9 | 512 | 512 | |
| 2^10 | 1,024 | ~1 Thousand | 1 KB (Kilobyte) |
| 2^11 | 2,048 | ~2 Thousand | 2 KB |
| 2^12 | 4,096 | ~4 Thousand | 4 KB |
| 2^13 | 8,192 | ~8 Thousand | 8 KB |
| 2^14 | 16,384 | ~16 Thousand | 16 KB |
| 2^15 | 32,768 | ~32 Thousand | 32 KB |
| 2^16 | 65,536 | ~64 Thousand | 64 KB |
| 2^17 | 131,072 | ~128 Thousand | 128 KB |
| 2^18 | 262,144 | ~256 Thousand | 256 KB |
| 2^19 | 524,288 | ~512 Thousand | 512 KB |
| 2^20 | 1,048,576 | ~1 Million | 1 MB (Megabyte) |
| 2^21 | 2,097,152 | ~2 Million | 2 MB |
| 2^22 | 4,194,304 | ~4 Million | 4 MB |
| 2^23 | 8,388,608 | ~8 Million | 8 MB |
| 2^24 | 16,777,216 | ~16 Million | 16 MB |
| 2^25 | 33,554,432 | ~32 Million | 32 MB |
| 2^26 | 67,108,864 | ~64 Million | 64 MB |
| 2^27 | 134,217,728 | ~128 Million | 128 MB |
| 2^28 | 268,435,456 | ~256 Million | 256 MB |
| 2^29 | 536,870,912 | ~512 Million | 512 MB |
| 2^30 | 1,073,741,824 | ~1 Billion | 1 GB (Gigabyte) |
| 2^31 | 2,147,483,648 | ~2 Billion | 2 GB (max signed 32-bit int) |
| 2^32 | 4,294,967,296 | ~4 Billion | 4 GB (max unsigned 32-bit int) |
| 2^33 | 8,589,934,592 | ~8 Billion | 8 GB |
| 2^34 | 17,179,869,184 | ~16 Billion | 16 GB |
| 2^35 | 34,359,738,368 | ~32 Billion | 32 GB |
| 2^36 | 68,719,476,736 | ~64 Billion | 64 GB |
| 2^37 | 137,438,953,472 | ~128 Billion | 128 GB |
| 2^38 | 274,877,906,944 | ~256 Billion | 256 GB |
| 2^39 | 549,755,813,888 | ~512 Billion | 512 GB |
| 2^40 | 1,099,511,627,776 | ~1 Trillion | 1 TB (Terabyte) |