In single-machine computing, reading from L1 cache takes and reading from RAM takes . In distributed systems, communication is bounded by the speed of light in fiber optics and the physical constraints of networking hardware.
To design low-latency, high-throughput distributed systems, you must understand the mathematical relationships governing Latency, Bandwidth, and Throughput.
1. The Three Fundamental Dimensions
| Metric | Definition | Units | Physical Constraint |
|---|---|---|---|
| Latency () | The time required for a packet or byte of data to travel from source to destination. | Milliseconds () or Microseconds () | Bound by speed of light in optical fiber and queuing. |
| Bandwidth () | The theoretical maximum rate at which data can be transferred across a link. | Bits per second (, ) | Bound by physical cable modulation and transceiver electronics. |
| Throughput () | The actual measured rate of successful data delivery over time. | Requests per second () or Megabytes per second () | Bound by latency, packet loss, congestion control, and TCP windows. |
[!IMPORTANT] Analogy:
If a network is a highway:
- Latency is the time it takes for a single car to drive from City A to City B (speed limit).
- Bandwidth is the number of lanes on the highway (width).
- Throughput is the actual number of cars that arrive per minute (flow rate).
2. Deconstructing Latency: The Four Component Delays
The end-to-end latency of a packet is the sum of four distinct physical delays:
1. Propagation Delay ()
The time taken for a bit of signal to travel along the physical medium (copper cable or silica fiber).
- Light in a vacuum travels at .
- Light in fiber glass travels at ( per kilometer).
- For a round-trip between New York and London ( fiber path), the theoretical minimum physical RTT is: No software optimization or caching algorithm can ever reduce this physical constant.
2. Transmission (Serialization) Delay ()
The time required for the network interface card (NIC) to push all bits of a packet onto the physical wire:
- Pushing a MTU packet onto a link takes .
- Pushing the same packet onto a datacenter link takes only ().
3. Processing Delay ()
The time taken by intermediate routers and destination hosts to inspect the packet header, verify the IP/TCP checksum, and determine the output routing interface (typically ).
4. Queuing Delay ()
The time a packet spends waiting in router buffer queues before being serialized onto the outgoing link. If incoming traffic exceeds the link rate, buffer queues fill up, causing queuing delay to spike exponentially from microseconds to hundreds of milliseconds.
3. The Bandwidth-Delay Product (BDP)
The Bandwidth-Delay Product (BDP) defines the maximum amount of data that can be in flight across the network at any given instant:
Real-World Example:
Consider a high-speed fiber link between San Francisco and Frankfurt ():
If your TCP socket buffer (Receive Window) is configured to the default of , the sender can only transmit before pausing and waiting for an ACK:
To achieve the full throughput over high-latency links, TCP Window Scaling (SO_RCVBUF and SO_SNDBUF) must be configured to match or exceed the BDP.
4. Little's Law in Distributed Systems
In queueing theory and distributed systems architecture, Little's Law relates concurrency, throughput, and latency:
Where:
- = Number of concurrent in-flight requests (System Concurrency / In-Flight Load)
- = Arrival rate / Throughput (Requests Per Second)
- = Average response time / Latency (Seconds per Request)
Architectural Implications:
- If latency doubles () while incoming traffic () remains constant at , the number of concurrent open connections () doubles from to .
- If connection pool limits are fixed (), an increase in downstream service latency immediately throttles system throughput (), dropping throughput from to and generating errors.
5. Code Deep-Dive: Measuring RTT vs. Server Execution Time
In distributed tracing and RPC debugging, client-measured latency includes both network transit time and server execution time. To detect network degradation, instruments must isolate transit delay:
6. Production Failure Postmortem: Tail Latency Amplification
When a single user request fans out to downstream services in parallel, system latency is bounded by the slowest response:
If individual service requests have a percentile () latency of (a probability of being slow):
| Downstream Fanout () | Probability of Hitting a Delay () |
|---|---|
| 1 Service | |
| 10 Services | |
| 50 Services | |
| 100 Services |
Mitigation Techniques:
- Hedged Requests: Send a duplicate request to a second replica if the first has not responded within the threshold (), accepting whichever returns first.
- Tied Requests: Enqueue requests on multiple replicas simultaneously and cancel redundant executions once one begins processing.