Sub topic 9
Estimating ingress and egress bandwidth
This chapter assumes you can convert daily active users (DAU) into queries per second (QPS), and that you know the difference between average and peak load from earlier chapters. You should also be comfortable with decimal and binary data units, and with estimating storage from record size. Here you will turn request rates and payload sizes into network bandwidth, and learn where the usual mistakes occur.
What bandwidth means in an estimate
Bandwidth is the amount of data that crosses a network link per unit of time. In system design discussions it answers a practical question: will the network links, load balancers, and servers keep up, and what will the traffic cost?
Two directions matter, and you should estimate them separately.
- Ingress is data flowing into your system. Examples are uploads, API request bodies, and log shipping from clients.
- Egress is data flowing out of your system. Examples are API responses, page downloads, images, and video.
Many systems are lopsided. A video service has small requests and huge responses, so egress dominates. A telemetry collector is the opposite, so ingress dominates. Cloud providers often charge for egress but not ingress, so the egress figure also drives cost.
The core formula
Bandwidth is the request rate multiplied by the bytes per request.
bandwidth (bytes/s) = QPS x bytes per requestUse the peak QPS, not the average, when you size links. Links must survive the busy period. Use the average QPS when you estimate monthly transfer volume for billing.
Separate the payloads by direction:
- Ingress bandwidth = write QPS x average request size
- Egress bandwidth = read QPS x average response size
Reads and writes usually have different rates, so do not use one QPS figure for both.
Bytes versus bits
Storage is quoted in bytes. Network links are quoted in bits per second. One byte is 8 bits, so you multiply by 8 when you compare your estimate with a link speed.
| Quantity | Typical unit | Conversion |
|---|---|---|
| Payload size | bytes (B, KB, MB) | 1 B = 8 bits |
| Throughput estimate | bytes per second (MB/s) | multiply by 8 for Mbps |
| Network link speed | bits per second (Mbps, Gbps) | divide by 8 for MB/s |
A 1 Gbps link carries at most about 125 MB/s. In practice you will not reach that figure, because protocol headers, retransmissions, and bursts take a share. Planning for 50 to 70 percent utilization of a link is a common rule of thumb.
A worked ingress and egress estimate
Consider a photo-sharing service. State the assumptions first.
- 10 million DAU.
- Each user views 50 photos per day and uploads 0.5 photos per day on average.
- A viewed photo averages 200 KB after compression.
- An uploaded photo averages 2 MB.
- Peak traffic is 2 times the average.
Compute the rates, then the bandwidth.
dau = 10_000_000
seconds_per_day = 86_400
peak_factor = 2
views_per_user = 50
uploads_per_user = 0.5
view_bytes = 200 * 1_000 # 200 KB
upload_bytes = 2 * 1_000_000 # 2 MB
avg_view_qps = dau * views_per_user / seconds_per_day
avg_upload_qps = dau * uploads_per_user / seconds_per_day
peak_egress_bytes = avg_view_qps * view_bytes * peak_factor
peak_ingress_bytes = avg_upload_qps * upload_bytes * peak_factor
print(round(avg_view_qps)) # 5787
print(round(avg_upload_qps)) # 58
print(round(peak_egress_bytes * 8 / 1e9, 2)) # 18.52 (Gbps)
print(round(peak_ingress_bytes * 8 / 1e9, 2)) # 1.85 (Gbps)The results are about 5,800 view requests per second and 58 uploads per second on average. Peak egress is about 18.5 Gbps, and peak ingress is about 1.9 Gbps. Egress is roughly ten times ingress, which matches the intuition that people view far more than they upload.
In a real design review you would round as you go: 10 million x 50 is 500 million views a day, divided by roughly 100,000 seconds is 5,000 per second. At 200 KB each that is 1 GB/s, so about 8 Gbps average and about 16 Gbps at peak. This is close to the precise answer and takes ten seconds.
Why this does not all reach your servers
A single figure for egress hides how the traffic is actually served. Several effects change the number your origin must handle.
- A content delivery network (CDN) caches static content near users. If 90 percent of photo views are served from the CDN, only 10 percent of the egress comes from your origin. The total delivered to users stays the same, but the load on your data center falls by a factor of ten.
- Compression shrinks text responses such as JSON and HTML, often by a factor of three to ten. It does little for images and video, which are already compressed.
- Internal traffic also exists. Replication, cache fills, and calls between services can exceed the user-facing traffic. Include them when you size internal links.
Replication multiplies internal bandwidth
Ingress at the edge is not the only write traffic. If every upload is stored in three replicas, the storage network carries three times the upload volume. With the earlier figure of 1.9 Gbps of peak ingress, the replication fan-out is about 5.7 Gbps of internal traffic. Mention this when the design uses synchronous replication across data centers, because cross-region links are scarcer and more expensive.
Estimating monthly transfer volume
Cost estimates use total volume, not peak rate. Use the average rate and multiply by the time period.
avg_egress_bytes_per_s = 1_000_000_000 # 1 GB/s average, from the example
seconds_per_month = 30 * 86_400
monthly_bytes = avg_egress_bytes_per_s * seconds_per_month
print(monthly_bytes / 1e15) # 2.592 (petabytes per month)About 2.6 PB per month. If the CDN serves 90 percent of it, the origin ships about 0.26 PB. This is why cache hit ratio features so heavily in cost discussions.
Estimating payload size
The weakest input in most bandwidth estimates is the bytes-per-request figure. Some reference sizes help:
| Payload | Rough size |
|---|---|
| Small JSON API response | 1 to 5 KB |
| Typical web page HTML (compressed) | 30 to 100 KB |
| Compressed photo for a feed | 100 to 500 KB |
| Short video clip, one minute at moderate quality | 10 to 30 MB |
| Log line or metric event | 100 to 500 B |
Include protocol overhead for small payloads. A 200-byte message carried over HTTP with headers and TLS can cost several hundred extra bytes. For large payloads the overhead is a small percentage and you can ignore it.
Common errors
- Using average QPS to size links. The link must handle the peak. Apply the peak factor before you convert to bandwidth.
- Mixing bytes and bits. Convert once, at the end, and label the unit.
- Forgetting the read-to-write ratio. If reads are 100 times writes, egress is far larger than ingress, and a single shared QPS figure produces nonsense.
- Ignoring caching. Without a CDN or cache, your origin bandwidth equals user bandwidth. With one, it is much lower. State which case you are assuming.
- Ignoring internal fan-out. Replication, search indexing, and analytics pipelines add traffic that never reaches the user.
- Using decimal and binary units inconsistently. The difference between 1,000 and 1,024 is about 2.4 percent per step, and it is small enough to ignore in an order-of-magnitude estimate. Pick one and stay with it.
Putting it together
Follow the same sequence each time.
- State the assumptions: DAU, actions per user, payload sizes, peak factor, read and write split.
- Compute average QPS for reads and writes separately.
- Apply the peak factor.
- Multiply by payload size to get bytes per second in each direction.
- Convert to bits per second to compare with link speeds.
- Adjust for caching, compression, and replication.
- Round, and compare against hardware limits.
Exercise
A chat service has 20 million DAU. Each user sends 40 messages a day, and each message averages 1 KB on the wire. Each message is delivered to 4 recipients on average, and each delivery is also 1 KB. Peak traffic is 3 times the average. Estimate peak ingress and peak egress in Mbps. Use 86,400 seconds per day, rounded to 100,000 for speed.
Show answer
Messages per day = 20 million x 40 = 800 million. Average send rate = 800 million / 100,000 = 8,000 per second. Peak = 8,000 x 3 = 24,000 per second. Ingress = 24,000 x 1 KB = 24 MB/s, which is 24 x 8 = 192 Mbps. Egress is 4 times larger, because each message is delivered to 4 recipients: 96 MB/s, which is about 768 Mbps. Egress is about 4 times ingress, and both fit within a single 1 Gbps link in principle, though you would spread the load over several servers for headroom and availability.
Exercise
Your estimate says peak egress is 40 MB/s. A teammate says a 250 Mbps link is enough. Are they right? What utilization would the link run at, and is that acceptable?
Show answer
40 MB/s is 40 x 8 = 320 Mbps, which is more than 250 Mbps, so the teammate is wrong. The link would be at 128 percent of capacity, meaning it cannot carry the load. Even a 400 Mbps link would run at 80 percent, which is above the 50 to 70 percent planning guideline. A 1 Gbps link would run at 32 percent, which leaves comfortable headroom.