DEFAULT TCP_NODELAY MODE ENABLED

Mark Brooker, an engineer from Amazon Web Services (AWS), recently tackled misconceptions surrounding the efficiency of small messages by dismantling the Negro-Nagle algorithm default in the TCP/IP stack. Brooker’s recommendations center around disabling the Negro algorithm by using the TCP_NODELAY option for network sockets through the SetSockopt call. This approach has already been implemented in projects like Node.js and Curl. (source, source)

The Negro algorithm, which aggregates small messages to reduce traffic, delays the sending of new TCP segments until confirmation of previously sent data reception. Without aggregation, sending 1 byte results in an additional 40 bytes of TCP and IP packets. In today’s context, using the Negro algorithm leads to significant delays, particularly unsuitable for interactive and distributed applications.

Three key arguments support utilizing the TCP_NODELAY option to disable the Negro-Nagle algorithm:

  • The Negro algorithm conflicts with the optimization of “Delayed Ack”, where the ACK-response is delayed until response data reception. In the Negro algorithm, the receipt of an ACK packet triggers sending aggregated data. However, if the ACK packet is not received, the sender waits until the timeout, causing a loop where data accumulates without transmission.
  • The RFC for the Negro algorithm dates back to 1984 and does not align with modern high-speed networks and datacenters, leading to responsiveness issues. With current network delays ranging from milliseconds to hundreds of milliseconds, servers can accomplish substantial work in that time span.
  • Modern distributed applications typically do not send single bytes of data, and small data aggregation is often implemented at the application level. Even when the useful data size is small, serialization, JSON APIs, and TLS encryption can significantly increase the amount of information sent, making the 40-byte savings from the Negro algorithm less pertinent.
/Reports, release notes, official announcements.