Sub topic 2
Estimating storage, bandwidth and compute
This chapter assumes you know basic web architecture, can read short Python snippets, and have met the idea of a bitrate ladder (several renditions of one video at different quality levels). The goal is to turn a few usage assumptions into rough numbers for storage, delivery bandwidth and transcoding workers.
Start from assumptions
Estimates are only as good as their inputs. Write the inputs down and keep them visible.
- 10,000 uploads per day, each 10 minutes long.
- Source files at 10 Mbps.
- A ladder of 0.8, 3 and 6 Mbps (360p, 720p, 1080p).
- 1 million daily viewers, each watching 1 hour per day.
- Average delivered bitrate of 3 Mbps.
- Peak traffic of 3 times the average.
- One worker encodes one rendition at real-time speed (1 minute of video per minute).
The formulas
- Storage: bitrate (bits per second) × duration (seconds) ÷ 8 gives bytes. Add up the source file and every rendition.
- Bandwidth: average concurrent viewers × average bitrate. Concurrent viewers = total viewing seconds per day ÷ 86,400.
- Compute: video minutes × renditions ÷ encode speed gives worker-hours. Divide by 24 for the average worker count, then multiply by the peak factor.
import math
# Assumptions
uploads_per_day = 10_000
video_seconds = 600
source_mbps = 10
ladder_mbps = [0.8, 3, 6]
viewers = 1_000_000
watch_hours = 1
avg_mbps = 3
peak_factor = 3
# Storage
rendition_gb = sum(ladder_mbps) * 1e6 * video_seconds / 8 / 1e9
source_gb = source_mbps * 1e6 * video_seconds / 8 / 1e9
storage_tb_day = uploads_per_day * (rendition_gb + source_gb) / 1000
print(f"Storage: {storage_tb_day:.2f} TB/day, {storage_tb_day * 365 / 1000:.2f} PB/year")
# Bandwidth
viewing_seconds = viewers * watch_hours * 3600
concurrent = viewing_seconds / 86_400
avg_gbps = concurrent * avg_mbps / 1000
egress_pb_day = viewing_seconds * avg_mbps * 1e6 / 8 / 1e15
print(f"Concurrent: {concurrent:.0f}, average {avg_gbps:.1f} Gbps, peak {avg_gbps * peak_factor:.1f} Gbps")
print(f"Egress: {egress_pb_day:.2f} PB/day")
# Compute
worker_hours = uploads_per_day * (video_seconds / 60) * len(ladder_mbps) / 60
print(f"Workers: {math.ceil(worker_hours / 24)} average, {math.ceil(worker_hours * peak_factor / 24)} peak")Running it prints:
Storage: 14.85 TB/day, 5.42 PB/year
Concurrent: 41667, average 125.0 Gbps, peak 375.0 Gbps
Egress: 1.35 PB/day
Workers: 209 average, 625 peakWhat the numbers tell you
| Resource | Estimate | Design consequence |
|---|---|---|
| Storage | about 5.4 PB per year | Use object storage and lifecycle rules, not a database or file server. |
| Bandwidth | 375 Gbps at peak | A single origin cannot serve this. A CDN must absorb it. |
| Compute | 625 workers at peak | Use a queue and autoscaled workers. |
Delivery dominates. Viewers pull about 1.35 PB per day, while uploads add under 15 TB per day. This read-heavy shape is why caching at the edge matters more than almost any other decision.
Common mistakes
- Storing only the source file and forgetting that every rendition is stored too.
- Using average load for sizing. Evening peaks can be several times the daily average.
- Ignoring that popular videos are watched far more than unpopular ones, so a CDN cache hit rate is high and origin traffic is much lower than total egress.
Exercise
Keep every assumption above, but the average delivered bitrate drops to 2 Mbps. What are the new average and peak bandwidth?
Show answer
Concurrent viewers stay at about 41,667. Average bandwidth is 41,667 × 2 Mbps ≈ 83.3 Gbps. Peak is 3 × 83.3 ≈ 250 Gbps.