Capacity Estimation/

Calculations

Lesson overview

Calculations

Worked examples of capacity calculations for real systems.

-- Example 1 — ToDo App (Easy) -- Requirements: -- Total users = 100,000 (10^5) -- DAU = 20% = 20,000 (2 × 10^4) -- Tasks per user per day = 10 -- Task size = 1 KB (10^3 bytes) -- Retention = 1 year -- Peak factor = 5x -- Requests: Daily_requests = 2 * 10^4 * 10 = 2 * 10^5 Average_RPS = 2 * 10^5 / 86400 ≈ 2.3 RPS Peak_RPS = 2.3 * 5 ≈ 12 RPS -- Storage: Daily_storage_bytes = 2 * 10^5 * 10^3 = 2 * 10^8 bytes = 200 MB/day Yearly_storage_GB = 200 * 365 / 1024 ≈ 73 GB Storage_with_replication_GB = 73 * 3 ≈ 220 GB -- Bandwidth: Writes_per_day_MB = 200 Average_bandwidth = negligible -- Memory: Hot_data_7days_GB = 200 * 7 / 1024 ≈ 1.4 GB Cache_size_GB ≈ 2

Calculations

-- Example 2 — URL Shortener (Medium) -- Requirements: -- Total users = 1,000,000 (10^6) -- DAU = 30% = 300,000 (3 × 10^5) -- URLs created per user per day = 1 -- Redirects per user per day = 10 -- Record size = 500 bytes -- Retention = 5 years -- Peak factor = 10x -- Requests: Writes_per_day = 3 * 10^5 Reads_per_day = 3 * 10^5 * 10 = 3 * 10^6 Total_requests_day = 3.3 * 10^6 Average_RPS = 3.3 * 10^6 / 86400 ≈ 38 RPS Peak_RPS = 38 * 10 ≈ 380 RPS -- Storage: Daily_storage_bytes = 3 * 10^5 * 500 = 1.5 * 10^8 bytes = 150 MB/day Yearly_storage_GB = 150 * 365 / 1024 ≈ 55 GB Storage_5yr_with_replication_GB = 55 * 5 * 3 ≈ 825 GB ≈ 1 TB -- Bandwidth: Redirect_payload_KB = 1 Daily_bandwidth_GB = 3 * 10^6 * 1 / 1024 ≈ 3 GB/day -- Memory: Hot_URLs_20percent_MB = 150 * 0.2 = 30 MB/day Hot_window_30days_MB = 30 * 30 = 900 MB Cache_size_GB ≈ 1 - 2

-- Example 3 — Chat Application (Hard) -- Requirements: -- Total users = 10,000,000 (10^7) -- DAU = 20% = 2,000,000 (2 × 10^6) -- Messages per user per day = 50 -- Message size = 1 KB (10^3 bytes) -- Retention = 2 years -- Peak factor = 8x -- Requests: Messages_per_day = 2 * 10^6 * 50 = 1 * 10^8 Average_RPS = 1 * 10^8 / 86400 ≈ 1157 RPS Peak_RPS = 1157 * 8 ≈ 9300 RPS -- Storage: Daily_storage_bytes = 1 * 10^8 * 10^3 = 1 * 10^11 bytes = 100 GB/day Yearly_storage_TB = 100 * 365 / 1024 ≈ 36.5 TB/year Storage_2yr_with_replication_TB = 36.5 * 2 * 3 ≈ 219 TB -- Bandwidth: Daily_bandwidth_GB = 100 Average_bandwidth_MBps = 100 * 1024 / 86400 ≈ 1.2 MB/sec Peak_bandwidth_MBps = ~10+ -- Memory: Hot_data_3days_GB = 100 * 3 = 300 GB Cache_subset_10percent_GB = 30

-- Example 4 — Netflix-Like Video Platform (Tough) -- Requirements: -- Total users = 50,000,000 (5 × 10^7) -- DAU = 20% = 10,000,000 (10^7) -- Avg watch time = 1 hour/day -- Video bitrate = 5 Mbps -- Uploads/day = 100,000 (10^5) -- Avg video size = 1 GB -- Retention = 5 years -- Peak factor = 5x -- Requests (Control Plane): Stream_start_requests_day = 10^7 Average_RPS = 10^7 / 86400 ≈ 115 RPS Peak_RPS = 115 * 5 ≈ 575 RPS -- Storage: Uploads_per_day_TB = 10^5 * 1 = 100 TB/day Yearly_storage_PB = 100 * 365 / 1024 ≈ 36.5 PB/year Storage_5yr_with_replication_PB = 36.5 * 5 * 3 ≈ 547.5 PB -- Bandwidth: Bitrate_MBps = 5 / 8 = 0.625 MB/sec Concurrent_users_10percent = 10^7 * 0.1 = 1,000,000 Total_bandwidth_MBps = 1,000,000 * 0.625 = 625,000 MB/sec = 610 GB/sec Peak_bandwidth_TBps = ~3 TB/sec (handled by CDN) -- Memory: Hot_videos_count = 10^7 Metadata_per_video_KB = 10 Memory_GB = 10^7 * 10 / 1024 ≈ 100 GB Cache_size_GB ≈ 100 - 200

Loading Calculations