Socket “Flush” by temporarily enabling NoDelay

前端 未结 4 1249
萌比男神i
萌比男神i 2020-12-17 02:14

Background

I have an implementation of an HTTP server in C#. Using ab I discovered a weird performance issue. Each request took 5 ms with Keep-Alive Off but 40 ms w

4条回答
  •  半阙折子戏
    2020-12-17 02:45

    There is no such thing as flushing in TCP. TCP is a stream based protocol which groups/ungroups/splits/joins your data. By disabling nagle it will only do that less frequent.

    Do not disable nagle.

    The Nagle TCP/IP algorithm was designed to avoid problems with small packets, called tinygrams, on slow networks. The algorithm says that a TCP/IP connection can have only one outstanding small segment that has not yet been acknowledged. The definition of "small" varies but usually it is defined as "less than the segment size" which on ethernet is about 1500 bytes.

    Take a look at here: Disabling TCP/IP Nagle Algorithm Improves Speed on Slow Nets

提交回复
热议问题