The Network Between Your Boxes
TCP handshakes, congestion control, head-of-line blocking, and TLS cost — why the arrows in your architecture diagram are the expensive part.
#The arrows are not free
Architecture diagrams draw services as boxes and network calls as arrows. The boxes get all the attention. But in a typical request path, most of the wall-clock time is spent in the arrows — and almost none of it is spent transmitting bytes.
Understanding what happens inside an arrow tells you why the fix for slow systems is so often "make fewer calls" rather than "make each call faster."
One unit runs through this whole page: RTT, the round trip time — how long a message takes to reach the other machine and the reply to come back. Everything below is counted in round trips, because that's what actually costs you.
#What one HTTPS request actually costs
- 1 DNS 0-100 ms · cached or not
- 2 TCP handshake 1 RTT · SYN, SYN-ACK, ACK
- 3 TLS handshake 1 RTT (1.3) or 2 (1.2)
- 4 Request + response 1 RTT + server time
- 5 Slow start more RTTs if the response is large
This is why connection pooling is not a micro-optimisation. It removes 150 ms of pure overhead from every call. It is also why HTTP keep-alive, persistent gRPC channels, and long-lived database connections exist, and why a service that opens a fresh connection per request will be inexplicably slow no matter how fast its code is.
#TCP: congestion control and slow start
TCP does not start sending at full speed. It has no idea what the network between you can carry, so it feels its way — sending a little, and doubling each round trip until something gets dropped. That ramp-up is called slow start, and it's why small responses feel instant while large ones feel sluggish even on a fast connection.
TCP counts data in segments — one packet's worth, about 1.4 KB. The amount it's allowed to send before waiting for the other side to confirm receipt is the congestion window.
TCP SLOW START (initial window = 10 segments ≈ 14 KB)
RTT 1: 10 segments ~14 KB cumulative ~14 KB
RTT 2: 20 segments ~29 KB cumulative ~43 KB
RTT 3: 40 segments ~58 KB cumulative ~101 KB
RTT 4: 80 segments ~116 KB cumulative ~217 KB
→ A 200 KB response over a 50 ms RTT link needs ~4 RTTs = 200 ms
of transfer time, even on a gigabit connection.
The bottleneck is not bandwidth. It is round trips.Bandwidth-delay product is the related idea worth carrying. TCP never sends unlimited data: after sending up to a window's worth of bytes, it stops and waits for the receiver to acknowledge them. That acknowledgement takes a full round trip to arrive. So to keep a link busy, the window must hold at least as many bytes as the link can carry during one round trip:
BDP = bandwidth × round-trip time
1 Gb/s link, 100 ms RTT:
BDP = 125 MB/s × 0.1 s = 12.5 MB
→ To saturate that link you must keep 12.5 MB of unacknowledged
data in flight. If the TCP window caps at 64 KB, you achieve
64 KB / 0.1 s = 640 KB/s — 0.5% of the link.The original TCP header can only express a window up to 64 KB; window scaling is the extension that lets it grow far larger. This is why long-distance bulk transfer needs window scaling, parallel streams, or a protocol that isn't TCP. A "slow transatlantic link" is very often a fast link where window scaling is off — the sender spends most of each round trip idle, waiting for acknowledgements.
#Head-of-line blocking, three times over
Head-of-line blocking is a queue where the item at the front is stuck, so everything behind it waits — even though those items are perfectly ready to go. One shopper arguing at the till holds up ten people with a single item each.
The same failure appears at three layers, and knowing which one you have determines the fix.
The third case is the one that bites in backend systems: head-of-line blocking in a message queue partition (a partition is one strictly ordered lane of a queue, processed in order). A single poison message — one that fails every time it's processed — sits at the front of the lane. Because messages must be handled in order, everything behind it waits, no matter how many consumers you add. The fix is not parallelism. It's a bounded retry policy (try a few times, then give up) plus a dead-letter queue — a side queue where the failing message is parked so the rest can flow. See message queues.
#Protocol choice, briefly
| Protocol | Round trips to first byte | Multiplexing | Where it fits |
|---|---|---|---|
| HTTP/1.1 | TCP + TLS + 1 | None (6 connections/origin) | Simple, universally supported |
| HTTP/2 | TCP + TLS + 1 | Yes, one TCP connection | Default for internal APIs and modern web |
| HTTP/3 (QUIC) | 1 (0 on resumption) | Yes, per-stream recovery | Lossy or mobile networks, high-RTT paths |
| gRPC (HTTP/2) | Same as HTTP/2 | Yes, plus streaming | Internal service-to-service; binary, schema'd |
| WebSocket | TCP + TLS + upgrade | One bidirectional stream | Server push, realtime |
QUIC's 0-RTT resumption is the notable one: a returning client can send application data in the first packet, eliminating handshake cost entirely. The catch is that 0-RTT data is replayable: an attacker who records that first packet can send it again, and the server will process it again. So it must only carry idempotent requests — ones where doing it twice has the same effect as doing it once, like "fetch my profile", never "charge my card". A direct application of idempotency.
#TLS is cheap now, but not free
The old advice that "TLS is expensive" is mostly obsolete. Once a connection is set up, the data itself is encrypted with symmetric encryption (both sides share one key). Modern CPUs have dedicated instructions for it (AES-NI), so it runs at gigabytes per second and costs single-digit percent CPU.
What still costs:
- The handshake. One RTT for TLS 1.3, two for 1.2. This is latency, not CPU, and it's why session resumption (a returning client skipping part of the handshake) and connection reuse matter.
- Asymmetric crypto on the handshake. During the handshake the server proves its identity with public-key maths (asymmetric crypto), which is far slower than the symmetric kind. An RSA-2048 signature is ~1 ms of CPU. At 10,000 new connections/s that is 10 cores doing nothing but handshakes. ECDSA is roughly 10× cheaper — a genuinely free win.
- Certificate validation and OCSP. OCSP is how a client checks with the certificate's issuer that the certificate hasn't been revoked. If the client stops to ask, that's an entire extra network round trip to a third party. OCSP stapling removes it: the server fetches a recent signed "still valid" answer itself and attaches it to the handshake.
#Timeouts, retries, and how they cause outages
Every network call needs a deadline, because the failure mode without one is unbounded. But naive retries turn a small problem into an outage.
RETRY AMPLIFICATION
A service is degraded; 20% of calls time out.
Every layer retries 3 times.
Client → Gateway → Service → Database
×3 ×3 ×3
One user request → up to 27 database queries
→ The retries generate more load than the original traffic,
which deepens the degradation, which triggers more retries.
This is a metastable failure: it does not recover when the
original trigger goes away.What actually works:
- Exponential backoff with full jitter. Wait longer after each failed attempt (exponential backoff), and make each wait a random amount (jitter). Without the randomness, every client that failed at the same moment also retries at the same moment — 1 s later, then 2 s, then 4 s — hitting the struggling server in synchronised waves.
sleep = random(0, min(cap, base × 2^attempt)). - Retry budgets. Cap retries at a small percentage of total requests (say 10%), globally, rather than per-call. When the budget is exhausted, fail fast.
- Circuit breakers. After N consecutive failures, stop calling for a cooldown period and fail immediately instead. This converts a slow failure into a fast one, so the caller's threads aren't all stuck waiting on calls that were going to fail anyway.
- Deadline propagation. Pass the remaining time budget down the call chain. If a request has 50 ms left, the database call should not be given a 5 second timeout — it should fail immediately.
- Retry only idempotent operations, and only on errors that indicate the work definitely did not happen.
#Where the bytes actually go
For most APIs the payload is small enough that bandwidth is irrelevant and round trips dominate. For media, bulk data, and fan-out systems, the opposite is true and egress cost becomes a line item on the bill.
Practical levers, in rough order of effect:
- Make fewer calls. Batch, pipeline, or colocate. Nothing else comes close.
- Compress. gzip is ~70% off text; brotli slightly better; zstd is faster than both at similar ratios. Never compress already-compressed media.
- Send less. Returning only the fields asked for, paginating, and sending only what changed (delta updates) beat compressing a payload you shouldn't have sent.
- Move the data closer. A CDN turns a cross-continent transfer into a local one.
- Choose a tighter encoding. Protobuf/Avro over JSON is typically 30–50% smaller and much faster to parse — worth it on internal high-volume paths, rarely worth the tooling cost on external APIs.
Reasoning to check yourself against: (1) ~4 RTTs ≈ 920 ms. (2) Parallel calls save two RTTs versus serial, so ~690 ms — multiplexing helps a lot here. (3) The two setup round trips now happen over the short link to Singapore, so they become nearly free. The edge talks to Virginia over a connection it already holds open, so no setup there either. But the actual content still has to come from Virginia, across the Pacific — so the API calls barely improve. (4) The read replica — it attacks propagation delay, which is the only irreducible term. Merging the calls is second and much cheaper to build.
#Check yourself
How many round trips does a cold HTTPS request (TLS 1.3) cost before your data moves, and what removes them?Show answer
What is TCP slow start, and what is the "14 KB rule"?Show answer
A 1 Gb/s link has a 100 ms round trip, but the TCP window is capped at 64 KB. What throughput do you get?Show answer
HTTP/2 "solved head-of-line blocking". What did it actually do?Show answer
Why must QUIC 0-RTT data only carry idempotent requests?Show answer
Each of three layers retries 3 times. How many database queries can one user request become, and why does that cause outages?Show answer
What is deadline propagation, and why is it better than a fixed timeout per call?Show answer
A service is slow because every request opens a fresh connection. What's the fix, and why is it not a micro-optimisation?Show answer
#What to carry forward
- Round trips dominate, not bytes. Count RTTs per user action; that is your latency budget.
- A cold HTTPS connection costs 3 extra round trips. Pool connections.
- Slow start means the first ~14 KB is one RTT and everything after costs more.
- BDP explains why long-distance links underperform: not enough data in flight.
- Head-of-line blocking exists at the HTTP, TCP, and queue-partition layers — identify which one you have before fixing it.
- Retries without jitter, budgets, and deadline propagation cause outages rather than preventing them.