Chapter 2 Flashcards - Back-of-Envelope Estimation
flashcards volume1 estimation math interview-critical
What is the power of 2 table (bytes)?
?
2^10 = 1 KB (thousand), 2^20 = 1 MB (million), 2^30 = 1 GB (billion), 2^40 = 1 TB (trillion), 2^50 = 1 PB (quadrillion). For interviews use 1000 instead of 1024 for easier math!
What are the key latency numbers every programmer should know?
?
Memory reference: 100 ns. SSD read 1 MB: 1 ms. Disk seek: 10 ms. Disk read 1 MB: 30 ms. Network within datacenter: 0.5 ms (500 μs). Network cross-continent: 150 ms. Mnemonic: Memory, SSD, Disk = Fast, Slow, Slower.
What is 99.9% availability in hours of downtime per year?
?
8.76 hours per year (or ~9 hours). Also: 99% = 3.65 days/year, 99.99% = 52.6 minutes/year, 99.999% = 5.26 minutes/year. Each extra “nine” is exponentially more expensive!
How many seconds are in a day (for interview math)?
?
Exact: 86,400 seconds. For interviews: Use 100,000 seconds (100K). Much easier math and close enough! Also remember: 1 day = 100K seconds, 1 year = 30M seconds (not 31.5M).
What is the formula for calculating QPS from daily active users?
?
QPS = (DAU × actions per user per day) / seconds per day. Use 100K seconds for easy math. Don’t forget to multiply by 2-3x for peak QPS! Example: 100M DAU × 10 actions / 100K seconds = 10K QPS average, 20-30K peak.
How do you calculate storage requirements?
?
Storage = (Number of items per day) × (Size per item) × (Time period in days). Don’t forget to multiply by replication factor (usually 3x) for redundancy. Example: 1B photos/day × 2 MB × 365 days × 3 replicas = 2.2 PB/year.
How do you calculate bandwidth requirements?
?
Bandwidth = Data Size / Time. Convert to MB/s or GB/s. Example: 300 TB/day = 300 × 10^12 bytes / 86,400 sec = 3.5 GB/second. Remember: 1 Gbps = 125 MB/s, 10 Gbps = 1.25 GB/s.
What is the 80/20 rule for caching?
?
Cache the 20% most accessed data to get 80% cache hit rate. For cache size estimation: Calculate daily active data, then cache top 10-20%. Example: If 1 TB of data accessed daily, cache 100-200 GB of hottest data.
What are the 3 steps of the estimation process?
?
Step 1: Understand the problem (ask clarifying questions). Step 2: Write down assumptions clearly (DAU, actions per user, sizes, ratios). Step 3: Do the math (show your work step-by-step, calculate QPS, storage, bandwidth). Always state assumptions and show calculations!
How do you estimate Twitter’s write QPS?
?
Given: 300M DAU, 2 tweets per user per day. Total tweets = 300M × 2 = 600M/day. Write QPS = 600M / 100K seconds = 6,000 QPS average. Peak = 6K × 2 = 12,000 QPS. Always mention peak!
How do you estimate Twitter’s storage (5 years)?
?
600M tweets/day × 500 bytes (text + metadata) = 300 GB/day for text. Add media: 600M × 10% have images × 5 MB = 300 TB/day. Total: ~300 TB/day. 5 years: 300 TB × 365 × 5 = 548 PB. With 3x replication: ~1.6 EB total.
What is a typical read/write ratio for social media?
?
Usually 10:1 to 100:1 (read-heavy). Twitter: ~5:1, Instagram: ~25:1, YouTube: ~1000:1 (watch vs upload). This tells you caching is critical and CDN is needed for serving reads.
How do you know if you need a CDN?
?
Calculate download bandwidth. If > 10 GB/second, definitely need CDN. Example: Instagram downloads = 25B views/day × 2 MB / 86,400 sec = 575 GB/second. No way to serve from origin servers - CDN mandatory!
What is the formula for availability downtime?
?
Downtime = (1 - availability) × time period. Example: 99.9% availability per year = (1 - 0.999) × 365 × 24 hours = 0.001 × 8,760 = 8.76 hours downtime per year.
When estimating cache size, what’s a good rule of thumb?
?
Cache 10-20% of daily active data, focusing on hottest items. If 1 TB data accessed daily, cache 100-200 GB. Also consider: Cache recent data (last 24 hours), cache by popularity (top 5-10%), cache user-specific data (sessions).
What are common mistakes in estimation?
?
Not doing estimation at all (biggest mistake!), being too precise (86,431.2 seconds), not stating assumptions, forgetting peak traffic (2-3x average), not showing work (just stating final answer), unrealistic numbers (10 PB/day for small app).
What should you always do after calculating?
?
Sanity check: Does this number make sense? Compare to known systems. Discuss implications: “This 575 GB/s download means we need CDN” or “100K QPS means we need database sharding”. Show you understand what the numbers mean!
How do you estimate Instagram’s requirements?
?
500M DAU, 2 photos/day = 1B photos/day = 10K write QPS. 50 views/day = 25B views/day = 250K read QPS (25:1 ratio). Storage: 1B × 2 MB = 2 PB/day. Bandwidth: Upload 23 GB/s, Download 575 GB/s. Need: CDN (mandatory), cache (100 TB for hot photos), database sharding.
What is a reasonable cache hit rate to assume?
?
80-90% is typical for well-designed cache. If 90% cache hit rate with 10K QPS, only 1K QPS hits database (10x reduction!). Lower hit rate (50-60%) means cache strategy needs improvement or data is too diverse to cache effectively.
How many servers can handle X QPS?
?
Rule of thumb: 1 server handles 1K-10K QPS depending on complexity. Simple reads: ~10K QPS/server. Complex queries: ~1K QPS/server. Always add redundancy (2x) so if one fails, others can handle load. For 50K QPS: Need 5-10 servers + redundancy = 10-20 servers total.
What is write amplification in storage estimation?
?
One logical write results in multiple physical writes. Examples: Replication (3x for redundancy), multiple formats (video: 360p, 720p, 1080p, 4K = 4x), indexes (every write updates multiple indexes). Always factor this in! Twitter: 300 GB text/day becomes 300 TB with media.
How do you estimate for video streaming (YouTube)?
?
Massive scale! 500M uploads/day × 100 MB = 50 PB/day. Multiple formats (4x) = 200 PB/day. 1000:1 watch-to-upload ratio = 200,000 PB/day views. Absolutely requires: CDN (mandatory), aggressive compression, adaptive bitrate streaming, edge caching.
What numbers should you memorize for interviews?
?
Time: 1 day = 100K seconds, 1 year = 30M seconds. Latency: Memory 100 ns, SSD 1 ms, Disk 10 ms. Bytes: KB (thousand), MB (million), GB (billion), TB (trillion), PB (quadrillion). Availability: 99.9% = 9 hours downtime/year. Peak traffic: 2-3x average.
How do you show your work effectively?
?
Write it down step-by-step. Example: “Step 1: DAU = 100M. Step 2: Actions per user = 10. Step 3: Total actions = 100M × 10 = 1B. Step 4: QPS = 1B / 100K = 10K. Step 5: Peak = 10K × 2 = 20K.” Always label each step and explain reasoning!
What is a good template for estimation?
?
Traffic: Calculate QPS (write and read separately), mention peak (2-3x). Storage: Calculate per day, per year, with replication. Bandwidth: Upload and download in GB/s. Cache: 10-20% of daily active data. Implications: What does this mean for design (need CDN? sharding? etc.)?
Total Cards: 25
Review Time: 15-20 minutes
Priority: HIGHEST - Critical for all interviews!
Practice: Do 2-3 calculations daily
Last Updated: 2026-04-08