CDN TCP Optimization: Tuning the Transport Layer

· Alex Petrov · 4 min read

TCP at the CDN Edge

Despite HTTP/3's move to QUIC, TCP still carries the majority of CDN traffic (via HTTP/1.1 and HTTP/2). CDN edge servers are tuned far beyond default OS TCP settings, squeezing maximum throughput and minimum latency from every connection.

CDN Protocol Stack — Layered network architectureCDN Protocol Stack — Layered network architecture CDN Protocol Stack Application Layer HTTP/2, HTTP/3, WebSocket Layer 5 Security Layer TLS 1.3 / Certificate Pinning Layer 4 Transport Layer TCP (HTTP/2) or QUIC (HTTP/3) Layer 3 Network Layer IP / Anycast Routing Layer 2 Physical Layer Fiber / Peering / IXP Layer 1 Higher ← Abstraction → Lower
Figure 1: CDN Protocol Stack — Layered network architecture

TCP Congestion Control

Congestion control algorithms determine how fast TCP sends data. The algorithm choice affects how quickly connections reach full speed: For foundational context, read DNS Resolution in CDN: How Users Reach the Nearest Edge — FlyFish NWA.

AlgorithmBehaviorCDN Use
CUBICAggressive ramp-up after lossLinux default, widely used
BBREstimates bandwidth and RTT, paces sendingUsed by Google/Cloudflare, better for high-latency links
BBRv2Improved fairness over BBRv1Emerging standard for CDNs

BBR is particularly effective for CDNs because it performs well on high-bandwidth, high-latency paths (like edge server to distant user). CUBIC underperforms on these paths because it's loss-based — it throttles unnecessarily on links with random loss.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages

Initial Congestion Window (IW)

The initial congestion window determines how much data TCP sends before receiving the first ACK. Default: 10 segments (14.6 KB). CDNs may increase this to 20-30 segments for faster start.

# Impact on first response:
IW=10: First flight delivers ~14 KB (enough for small HTML)
IW=30: First flight delivers ~44 KB (enough for most pages + critical CSS)

The trade-off: larger IW risks overwhelming slow or congested links.

TCP Fast Open (TFO)

TCP Fast Open sends data in the SYN packet, saving one RTT on connection establishment:

Protocol Handshake Flow — Connection establishment sequenceProtocol Handshake Flow — Connection establishment sequence CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: Protocol Handshake Flow — Connection establishment sequence
Standard TCP: SYN → SYN-ACK → ACK + data (1 RTT before data)
TCP Fast Open: SYN + data → SYN-ACK + data (0 RTT for repeat connections)

CDN edge servers enable TFO for returning clients who have a cached TFO cookie. This eliminates one RTT for repeat visitors.

Connection Pooling

CDN edge servers maintain pools of persistent connections to origin servers. Benefits:

Pool sizing matters: too few connections limits throughput; too many overwhelms the origin.

Kernel-Level Optimizations

CDN edge servers use custom kernel configurations:

TLS Optimization

TLS processing is the most CPU-intensive operation on edge servers:

See SSL/TLS configuration for full details.

External References

References & Standards: OWASP CDN Security · HTTP/2 specification