Sub topic 9
Estimating ingress and egress bandwidth
This chapter assumes you can convert daily active users (DAU) into queries per second (QPS), including peak versus average load, and that you can estimate record sizes. Here you turn request rates and payload sizes into network bandwidth.
Ingress and egress
Ingress is data flowing into your system, such as uploads and writes. Egress is data flowing out, such as downloads and page responses. Estimate them separately. Most read-heavy systems have egress far larger than ingress, and cloud providers often bill egress but not ingress.
The core formula is:
- bandwidth = QPS × payload size
Size the network for peak QPS, not average QPS. Links saturate at peak.
Bytes versus bits
Payload sizes are usually in bytes. Network capacity is quoted in bits per second. One byte is 8 bits. Skipping this conversion is the most common bandwidth error, and it makes your answer 8 times too small.
| Unit | Meaning |
|---|---|
| MB/s | megabytes per second |
| Mbps | megabits per second (1 MB/s = 8 Mbps) |
| Gbps | gigabits per second (1 Gbps = 1,000 Mbps) |
Worked example
Suppose a photo service has these assumptions:
- 1,000 photo uploads per second at peak, each 2 MB.
- 20 photo views per upload on average, so 20,000 views per second at peak.
- Each view returns a 200 KB resized image.
upload_qps = 1_000
upload_bytes = 2 * 1_000_000
view_qps = upload_qps * 20
view_bytes = 200 * 1_000
ingress_bytes_per_s = upload_qps * upload_bytes
egress_bytes_per_s = view_qps * view_bytes
ingress_gbps = ingress_bytes_per_s * 8 / 1e9
egress_gbps = egress_bytes_per_s * 8 / 1e9
print(round(ingress_gbps, 1)) # 16.0
print(round(egress_gbps, 1)) # 32.0Ingress is 2 GB/s, which is 16 Gbps. Egress is 4 GB/s, which is 32 Gbps. Although there are 20 times more reads than writes, egress is only twice ingress, because each view returns a much smaller image than each upload carries.
Reducing the numbers
Bandwidth estimates feed design choices. Some common effects:
- A content delivery network (CDN) serves popular images from edge locations, so less egress leaves your own data center.
- Compression shrinks text payloads such as JSON, often by a large factor. It does little for images that are already compressed.
- Returning smaller thumbnails instead of originals cuts egress directly.
Treat these as adjustments to a baseline. Compute the uncached, uncompressed number first, then state the reduction you assume.
Common errors
- Using average QPS where peak QPS is needed.
- Forgetting the factor of 8 between bytes and bits.
- Counting only response bodies and ignoring protocol overhead. Overhead is small for large payloads but can matter for many tiny requests.
- Estimating only egress, or only ingress, when the system has both.
- Forgetting that replication multiplies internal traffic. If each write is copied to three replicas, internal network traffic is about three times the ingress.
Exercise
A video service has 5,000 peak requests per second for video chunks. Each chunk is 1 MB. What peak egress is this in Gbps, and how many 10 Gbps links are needed with no headroom?
Show answer
Egress is 5,000 × 1 MB = 5,000 MB/s. Multiply by 8 to get 40,000 Mbps, which is 40 Gbps. That needs 4 links of 10 Gbps. In practice you would add headroom, for example 5 links, so no link runs at full capacity.
Exercise
A service receives 200 writes per second at 10 KB each and replicates every write to 2 additional nodes. What is the ingress in Mbps, and what is the extra internal replication traffic in Mbps?
Show answer
Ingress is 200 × 10 KB = 2,000 KB/s, which is 2 MB/s, or 16 Mbps. Replication to 2 extra nodes sends the data twice more, so internal traffic is 2 × 16 = 32 Mbps.