Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would someone turn off Nagle's Algorithm?

From node redis docs:

socket_nodelay: defaults to true. Whether to call setNoDelay() on the TCP stream, which disables the Nagle algorithm on the underlying socket. Setting this option to false can result in additional throughput at the cost of more latency. Most applications will want this set to true.

Why would I want to turn off Nagle's algorithm?

like image 954
CamelCamelCamel Avatar asked Dec 16 '22 03:12

CamelCamelCamel


1 Answers

You would want to turn off the Nagle Algorithm when you're concerned about latency. My understanding of the algorithm is that it delays sending data until there is a reasonable amount to send. This in turn reduces the protocol overhead of the stream because more data is sent in a single packet (i.e. with a single header).

With the Nagle Algorithm turned off, the idea is that data is sent immediately by the protocol stack.

It was designed in the day when network resources were more constrained and so reducing the overhead was more important that expedient delivery. However these days with generally faster interconnects and more requirement for low-latency it's become less important. (Think video streaming!)

like image 113
Nick Avatar answered Jan 01 '23 15:01

Nick