
2/8/2024 · Frederick Lawler
What this post added
This post investigates the performance implications of reducing the number of source IPv4 addresses used by Cloudflare's cache service for egress connections. It identifies a performance bottleneck in the TCP connect() syscall, specifically within the `__inet_hash_connect()` function, which is exacerbated when using a single IPv4 address due to port exhaustion. The analysis reveals that the Linux kernel's port selection algorithm, which prioritizes even or odd ports in separate passes, leads to significant latency when even ports are exhausted. This research directly contributes to Cloudflare's strategy of deprecating IPv4 and moving towards IPv6 by understanding and mitigating the performance challenges associated with reduced IPv4 address allocation.