Sub topic 3
Estimating ingress and egress bandwidth
Assume you know basic client-server architecture, including requests, responses, caches, databases, and load balancers. This chapter uses rough estimates rather than benchmark results.
Estimating ingress and egress bandwidth
Ingress is data entering your service. Egress is data leaving it. Estimate each direction separately:
bandwidth = requests per second × bytes per requestConvert bytes per second to bits per second by multiplying by 8. Divide by 1,000,000 for megabits per second (Mbps).
Suppose a service handles 2,000 requests per second. Each request is 2 KB, and each response is 20 KB:
- Ingress:
2,000 × 2 KB = 4 MB/s, or about 32 Mbps - Egress:
2,000 × 20 KB = 40 MB/s, or about 320 Mbps
Include protocol headers, retries, and peak traffic by adding headroom.
Sizing a cache and working set in memory
A working set is the data that must be quickly available. Estimate cache memory as:
cache memory = cached items × average item size × overhead factorFor 10 million cached items averaging 1 KB, an overhead factor of 1.5 gives about 15 GB. The factor covers keys, metadata, allocator overhead, and fragmentation.
How many servers do you need
First estimate peak load. Then divide by the tested capacity of one server:
servers = ceil(peak requests per second / safe capacity per server)If peak traffic is 10,000 requests per second and one server safely handles 2,000, you need five servers. Add redundancy and headroom. Six or seven servers may be more appropriate than exactly five.
Availability targets and allowed downtime
Availability is the percentage of time a service is usable. The yearly downtime budget is:
| Target | Approximate downtime per year |
|---|---|
| 99.9% | 525.6 minutes |
| 99.99% | 52.56 minutes |
| 99.999% | 5.26 minutes |
Higher targets require more failure isolation, monitoring, and operational effort.
Worked example: estimating a URL shortener
Assume 1 million daily active users, 10 short-URL reads per user each day, a 2 KB response, and a peak factor of 3.
users = 1_000_000
reads_per_user = 10
seconds_per_day = 86_400
peak_factor = 3
response_bytes = 2_000
average_qps = users * reads_per_user / seconds_per_day
peak_qps = average_qps * peak_factor
egress_mbps = peak_qps * response_bytes * 8 / 1_000_000
print(round(average_qps), round(peak_qps), round(egress_mbps))
# 116 347 6A design might begin with capacity for at least 347 requests per second and more than 6 Mbps of peak egress.
Sanity checks and common pitfalls
- Keep units visible. Bytes and bits differ by a factor of eight.
- Distinguish average from peak values.
- Check whether decimal or binary units are being used.
- Add overhead, retries, replication, and safety margin.
- Compare the result with a familiar scale. A few hundred requests per second should not produce terabytes per second without a clear reason.
Exercise
A service receives 5,000 requests per second. Each response is 10 KB. What is approximate peak egress?
Show answer
5,000 × 10 KB = 50 MB/s. Multiplying by 8 gives about 400 Mbps, before protocol overhead.