Job Snijders, a prominent OpenBSD developer, chair of one of the committees at IETF (Internet Engineering Task Force), author of 11 RFCs related to routing and RPKI, and creator of IRRd (Internet Routing Registry Daemon), has published a set of patches for OpenBSD that introduce a new sysctl parameter ‘net.inet.tcp.nodelay’ to disable the Nagle algorithm at the system level. This parameter relieves application developers from having to set the TCP_NODELAY flag for individual sockets.
The Nagle algorithm is used to aggregate small messages to reduce traffic. It postpones the sending of new TCP segments until an acknowledgment of previously sent data is received or a timeout occurs. For example, without aggregation, sending 1 byte also sends an additional 40 bytes with the TCP and IP headers of the packet. In contrast, with the Nagle algorithm, messages sent before receiving acknowledgment from the remote side are accumulated and sent in a single packet. Due to the 'delayed ACK' optimization, which delays the sending of ACK packets, the signaling through acknowledgment packets is virtually ineffective, and the transmission of accumulated messages occurs upon timeout.
Snijders believes that in modern conditions, the Nagle algorithm, designed at a time when multiple users competed for 1200 baud bandwidth, has become outdated and in high-speed networks it causes more harm than good. A similar position was recently expressed by Marc Brooker from Amazon Web Services (AWS). Arguments for disabling the Nagle algorithm by default can be found in a note published a few days ago.
To disable the Nagle algorithm, the TCP_NODELAY option can be set for individual network sockets. The TCP_NODELAY mode has long been set in many OpenBSD applications, including openssh, httpd, iscsid, relayd, bgpd, and unwind. According to Snijders, it is time to allow its activation for all TCP sockets at the system level. Snijders also suggests discussing the possibility of enabling TCP_NODELAY by default and relegating the Nagle algorithm to a separate optional setting.
Source: opennet.ru
