Appendix — Back-of-the-Envelope Estimates & References¶
Useful when asked to estimate by hand (e.g., "how long to generate 100 image thumbnails?" or "how much memory does this data structure use?").
Powers of Two Table¶
| Power | Exact Value | Approx Value | Bytes |
|---|---|---|---|
| 7 | 128 | — | — |
| 8 | 256 | — | — |
| 10 | 1,024 | 1 thousand | 1 KB |
| 16 | 65,536 | — | 64 KB |
| 20 | 1,048,576 | 1 million | 1 MB |
| 30 | 1,073,741,824 | 1 billion | 1 GB |
| 32 | 4,294,967,296 | — | 4 GB |
| 40 | 1,099,511,627,776 | 1 trillion | 1 TB |
Latency Numbers Every Programmer Should Know¶
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2, 200x L1
Compress 1K bytes with Zippy 10,000 ns = 10 us
Send 1 KB over 1 Gbps network 10,000 ns = 10 us
Read 4 KB randomly from SSD* 150,000 ns = 150 us
Read 1 MB sequentially from memory 250,000 ns = 250 us
Round trip within same datacenter 500,000 ns = 500 us
Read 1 MB sequentially from SSD* 1,000,000 ns = 1 ms
HDD seek 10,000,000 ns = 10 ms
Read 1 MB sequentially from 1 Gbps 10,000,000 ns = 10 ms
Read 1 MB sequentially from HDD 30,000,000 ns = 30 ms
Send packet CA -> Netherlands -> CA 150,000,000 ns = 150 ms
Notes: 1 ns = 10^-9 s, 1 us = 10^-6 s = 1,000 ns, 1 ms = 10^-3 s = 1,000 us.
Handy derived metrics¶
- Read sequentially from HDD at 30 MB/s
- Read sequentially from 1 Gbps Ethernet at 100 MB/s
- Read sequentially from SSD at 1 GB/s
- Read sequentially from main memory at 4 GB/s
- 6–7 world-wide round trips per second
- 2,000 round trips per second within a data center
Mental model (round numbers)¶
- L1 cache ≈ 1 ns; main memory ≈ 100 ns (100x); SSD random read ≈ 100 us (1000x memory); HDD seek ≈ 10 ms; cross-continent packet ≈ 150 ms.
Additional System Design Interview Questions¶
Practice these with resources you find online:
- Design a file sync service (Dropbox)
- Design a search engine (Google)
- Design a scalable web crawler
- Design Google Docs
- Design a key-value store (Redis)
- Design a cache system (Memcached)
- Design a recommendation system (Amazon)
- Design a URL shortener (Bitly)
- Design a chat app (WhatsApp)
- Design a photo-sharing system (Instagram)
- Design a news feed / timeline (Facebook)
- Design a graph search (Facebook)
- Design a CDN (Cloudflare)
- Design a trending-topics system (Twitter)
- Design a random ID generator (Snowflake)
- Return the top-k requests during a time interval
- Design multi-data-center data serving
- Design an online multiplayer card game
- Design a garbage collection system
- Design an API rate limiter
- Design a stock exchange (NASDAQ/Binance)
Real-World Architectures (study list)¶
Identify shared principles and patterns rather than memorizing details:
- Data processing: MapReduce (Google), Spark, Storm
-
Data stores: Bigtable, HBase, Cassandra, DynamoDB, MongoDB, Spanner, Memcached, Redis
-
File systems: Google File System (GFS), Hadoop File System (HDFS)
- Misc: Chubby (lock service), Dapper (tracing), Kafka (pub/sub), ZooKeeper (coordination)
Company Engineering Blogs & Architectures¶
Great sources for real-world patterns: Amazon, Dropbox, Google, Instagram, Facebook, Flickr, Netflix, Twitter, and others via High Scalability.
Question → Topic Map¶
Each common interview question is walked through as a collapsible on its topic page. Use this to find them.
Data, caching, and databases
| Question | Topic page |
|---|---|
| Design a URL shortener | Full walkthrough, 11 RDBMS, 16 Security |
| Design a key-value store (Redis) | 12 NoSQL |
| Design a cache (Memcached) | 13 Cache |
| Design a search-engine query cache | 13 Cache |
| Design a social network graph | 12 NoSQL |
| Design a recommendation system | 12 NoSQL |
| Design Amazon's sales ranking | 11 RDBMS |
| Design a news feed / timeline | 11 RDBMS, 13 Cache |
Networking, routing, and delivery
| Question | Topic page |
|---|---|
| Design a CDN (Cloudflare) | 06 DNS, 07 CDN |
| Design Instagram (media) | 07 CDN |
| Design a globally available service | 06 DNS |
| Design an API gateway | 09 Reverse Proxy |
| Design an API rate limiter | 02 Latency vs Throughput |
Application, communication, and async
| Question | Topic page |
|---|---|
| Design a chat app (WhatsApp) | 10 App Layer, 15 Communication |
| Design Google Docs | 04 Consistency, 15 Communication |
| Design a ride-hailing service (Uber) | 10 App Layer |
| Design a web crawler | 14 Asynchronism |
| Design a notification system | 14 Asynchronism |
| Design Mint.com | 14 Asynchronism |
| Design a multiplayer game | 15 Communication |
Scale, availability, and consistency
| Question | Topic page |
|---|---|
| Design a system that scales to millions of users | 01 Performance vs Scalability |
| Design a multi-data-center system | 01 Performance vs Scalability |
| Design a globally distributed database | 03 CAP |
| Design a 99.99% available system | 05 Availability Patterns |
| Design a key-value store (consistency) | 03 CAP, 04 Consistency |