It鈥檚 always TCP_NODELAY. Every damn time. It's not the 1980s anymore, thankfully. The first thing I check when debugging latency issues in distributed systems is whether TCP_NODELAY is enabled. And it鈥檚 not just me. Every distributed system builder I know has lost hours to latency issues quickly fixed by enabling this simple socket option, suggesting that the default behavior is wrong, and perhaps that the whole concept is outmoded. First, let鈥檚 be clear about what we鈥檙e talking about. There鈥檚 no better source than John Nagle鈥檚 RFC896 from 19841. First, the problem statement: There is a special problem associated with small packets. When TCP is used for the transmission of single-character messages originating at a keyboard, the typical result is that 41 byte packets (one byte of data, 40 bytes of header) are transmitted for each byte of useful data. This 4000% overhead is annoying but tolerable on lightly loaded networks. In short, Nagle was interested in better amortizing the cost of TCP headers, to get better throughput out of the network. Up to 40x better throughput! These tiny packets had two main causes: human-interactive applications like shells, where folks were typing a byte at a time, and poorly implemented programs that dribbled messages out to the kernel through many write calls. Nagle鈥檚 proposal for fixing this was simple and smart: A simple and elegant solution has been discovered. The solution is to inhibit the sending of new TCP segments when new outgoing data arrives from the user if any previously transmitted data on the connection remains unacknowledged. When many people talk about Nagle鈥檚 algorithm, they talk about timers, but RFC896 doesn鈥檛 use any kind of timer other than the round-trip time on the network. Nagle鈥檚 Algorithm and Delayed Acks Nagle鈥檚 nice, clean, proposal interacted poorly with another TCP feature: delayed ACK. The idea behind delayed ACK is to delay sending the acknowledgement of a packet at least until there鈥檚 some data to sen...
First seen: 2025-12-22 22:36
Last seen: 2025-12-23 20:42