Highlights

Contents

Part III
03

IOPS, bandwidth and storage

We count the resources carrying each operation. Request rate alone cannot size a disk or a network link. We will connect operation size to IOPS, payload rate to bandwidth, and logical records to retained storage.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Latency, throughput andLittle's law2p50, p95 and p99 latency3IOPS, bandwidth andstorage4CPU-bound, I/O-bound andbottlenecks5Scaling and Amdahl's law6Queueing and backpressure7Case study: capacityestimation

#Section 11IOPS and operation size

A disk copies a long file efficiently but stalls when Heron requests unrelated pages. IOPS means input/output operations completed per second. Bandwidth means bytes transferred per second. They describe different limits, connected by how much data each operation transfers.

Assume an illustrative device completes 2,000 reads per second and each read transfers 4 KiB. A KiB is 1,024 bytes, so each read is 4,096 bytes. The transferred data rate is 2,000×4,096=8,192,0002,000\times4,096=8,192,000 bytes per second. This is 8.192 decimal MB per second, before any extra work outside those reads.

B=I×bB=I\times b

Read this as: byte rate BB equals operation rate II times bytes per operation bb. The relationship only describes the counted operations. It does not predict a device's capacity without operation size, read/write mix, locality, queue depth, and durability behavior.

A database query is not one I/O by definition. Its pages may already be in memory, it may read several pages, or it may initiate additional work to maintain indexes and logs. Measure physical operations at the storage boundary. Translate application queries into that work before comparing the workload with a device limit.

OPERATIONS TIMES THEIR SIZE GIVES A BYTE RATEdevice: 2,000 reads/sone read = one operation4 KiB4 KiB4 KiB4 KiB4 KiB4 KiB4 KiB4 KiBeach read moves 4 KiB = 4,096 bytes2,000 × 4,096 B = 8,192,000 B/s8.192 decimal MB/s of counted readsa query may need zero, one or several of these reads: count at the device
Figure 2.12Illustrative 2,000 operations/s at 4,096 bytes each produce 8,192,000 bytes/s.

#Section 12Locality, caching, and durable writes

Heron's recent match events sit near each other, while unrelated profile lookups touch scattered pages. Locality means work reuses nearby or recently accessed data. Sequential access can combine requests into larger transfers; random access makes the system locate different regions more often.

An illustrative 64 KiB contiguous region contains 16 pages of 4 KiB. Reading it in one larger operation changes the operation count while transferring the same payload. It can also read bytes the caller never uses, so fewer operations do not always mean less total work. The access pattern determines whether that trade helps.

A cache hit means the requested data is already available in the measured cache. Suppose each query references four pages and 90% of those page references hit memory. At 1,000 queries per second, the expected physical read demand is 1,000×4×0.1=4001,000\times4\times0.1=400 pages per second. This simple model assumes the given hit ratio remains valid under the workload.

Durable writes add a different requirement. The caller may need acknowledgement after data reaches the chosen persistence boundary, rather than after it enters a volatile buffer. Grouping writes can reduce flush operations, but it introduces waiting and recovery rules. Keep read misses, log writes, data writes, and background compaction as separate demands.

LOCALITY AND HIT RATIO CHANGE PHYSICAL WORKa contiguous 64 KiB region holds 16 pages of 4 KiB1 read × 64 KiBor 16 reads × 4 KiBsame 65,536 bytes, different operation count1,000 queries/s× 4 pages each4,000 refs/s90% hit: 3,600 refs/s from memory10% miss400/s1,000 × 4 × 0.1 = 400 page reads/s400 × 4,096 B = 1,638,400 B/s (1.6384 MB/s)
Figure 2.13Illustrative 64 KiB region contains 16 pages; the query model produces 400 physical page reads/s.

#Section 13Bandwidth and fan-out bytes

Heron's API responses are small, but a live event must reach many viewers. Bandwidth demand depends on payload size and recipient count as well as event production. Count bytes at the actual transfer boundary before comparing that demand with a link's capacity.

At 1,000 requests per second and 2,000 payload bytes per response, API payload is 2,000,000 bytes per second. Multiplying by eight gives 16,000,000 bits per second. These counts exclude request bodies, headers, TLS records, acknowledgements, retransmissions, and any inter-service copies of the response.

The live path produces 20 events per second for 50,000 viewers. That is 1,000,000 deliveries per second. Each carries an illustrative 200-byte payload, yielding 200,000,000 bytes per second, or 1,600,000,000 bits per second. Payload alone exceeds an illustrative 1,000,000,000-bit-per-second link by a factor of 1.6.

Sending each event to five gateways costs only 20×5×200=20,00020\times5\times200=20,000 payload bytes per second on that particular upstream path. The gateways then perform the large viewer fan-out. Draw both boundaries before sizing them. Moving the fan-out changes which machines pay the delivery cost; it does not eliminate those deliveries.

ILLUSTRATIVE PAYLOAD BY PATHAPI responses: 1,000/s × 2,000 B = 2,000,000 B/s (16 Mbit/s)live delivery: 1,000,000 sends/s × 200 B = 200,000,000 B/s (1.6 Gbit/s)link 1 Gbit/s = 125,000,000 B/spayload alone is 1.6 × the link, before headers or retransmitsdelivery count is notAPI request count
Figure 2.14Computed illustrative payload rates are 2 MB/s for API responses and 200 MB/s for live delivery.
THE GATEWAY INPUT AND OUTPUT HAVE DIFFERENT MULTIPLIERSin: 20 events/s × 5 copies × 200 B = 20,000 B/sscorer10,00010,00010,00010,00010,000gatewaysout: 20 × 50,000 viewers × 200 B = 200,000,000 B/sone dot = 100 viewers; 10,000 per gatewaysmall upstream,large delivery
Figure 2.15Illustrative gateway input is 20,000 bytes/s; viewer output is 200,000,000 bytes/s.

#Section 14Retained storage and physical overhead

Suppose a separate illustrative write workload stores a 500-byte record for every daily request. A score read does not necessarily do this; we introduce the assumption to practice storage accounting. Daily logical data is 8,640,000×500=4,320,000,0008,640,000\times500=4,320,000,000 bytes.

With 30 days retained, one logical copy contains 129,600,000,000 bytes. With three replicas, the payload occupies 388,800,000,000 bytes, or 388.8 decimal GB. This is approximately 362.0982 GiB, rounded to four decimals. The unit conversion changes the reported number, not the actual bytes.

Now assume index data adds 20% of logical record bytes and uses the same replication factor. Records plus indexes occupy 129,600,000,000×1.2×3=466,560,000,000129,600,000,000\times1.2\times3=466,560,000,000 bytes. The index ratio is illustrative. Real indexes depend on keys, pointers, page layout, compression, and update behavior.

Add logs, backups, temporary rebuild space, compaction overlap, page slack, and deletion delay using explicit measurements or assumptions. A retention policy states when data becomes eligible for removal; it may not reclaim physical bytes immediately. Recovery also needs free space. A disk filled to the exact retained-data total cannot safely perform every maintenance operation.

ILLUSTRATIVE LOGICAL AND REPLICATED STORAGE30 retained days, 4.32 GB each123456789101112131415161718192021222324252627282930129.6 GBone logical copycopy 1copy 2copy 3388.8 GB, about 362.0982 GiB8,640,000 records/day × 500 B = 4,320,000,000 B/day× 30 days = 129,600,000,000 B; × 3 copies = 388,800,000,000 Bcount the physical work, not just rows
Figure 2.16Computed illustrative retained payload is 129.6 GB logical and 388.8 GB with three copies.
ADD INDEX BYTES BEFORE COUNTING REPLICASlogs, rebuild spacerows 129.6 GBindex 25.92 GBcopy 1: 155.52 GBlogs, rebuild spacerows 129.6 GBindex 25.92 GBcopy 2: 155.52 GBlogs, rebuild spacerows 129.6 GBindex 25.92 GBcopy 3: 155.52 GB3 copies × 155.52 GB = 466.56 GB129.6 GB × 1.2 = 155.52 GB per copy; dashed space stays extra
Figure 2.17With illustrative index overhead of 20%, replicated records plus indexes total 466.56 GB.

#Section 15Cache size and the working set

A cache containing Heron’s latest scores does not need every historical database record. The working set is the data actively needed during the workload’s relevant interval. A cache budget begins with which keys are useful, how many exist, and how long they remain useful.

Assume 100,000 entries, each with a 2,000-byte payload and 100 bytes of combined key and bookkeeping overhead. Payload alone is 200,000,000 bytes. The entries together occupy 210,000,000 bytes. An additional identical replica doubles that counted storage to 420,000,000 bytes before allocator slack and process overhead.

A server also stores connection buffers, executable code, temporary objects, and housekeeping structures. Cache entry bytes are not the whole process footprint. Use measured resident memory under a representative key distribution, including deletion and replacement activity. Large values or unusually long keys can invalidate an average-entry assumption.

Eviction bounds memory but changes hit rate. If the hottest keys stay resident, a modest cache can remove much database work. If a burst cycles through previously unseen keys, the same memory budget yields many misses. Measure distinct keys, value-size distribution, and miss traffic together instead of treating cache capacity as a hit-rate guarantee.

ENTRY OVERHEAD IS PART OF THE MEMORY BUDGETone cache entry, drawn to scalepayload 2,000 B100 B key + bookkeeping2,100 B per entryprimary100,000 × 2,100 B= 210,000,000 Breplica100,000 × 2,100 B= 210,000,000 Bthe process also holds buffers, code, temporary objects2 copies × 210 MB = 420 MB before allocator slack
Figure 2.18Illustrative entry budget adds payload and overhead before counting copies.