How to disable Nagle algorithm in ServiceStack?

We are using ServiceStack 3.9.71.0, and we are currently experiencing unexplained latency issues with clients over a WAN connection.

After 200 ms +, a response was received with a very small payload (<100 bytes).

The round-off time (RTT) on the link is about 40 ms due to geographical distance. This was verified by checking a different host and using a simple echo service to check the delay of a TCP connection.

Both ping and echo tests show delays that match expectations. Getting a response from our ServiceStack node takes much longer than expected.

We have verified that:

  • WAN link only works at 25% capacity (no congestion)
  • WAN channel does not use QOS
  • the same host gives a quick response to the same request from another host on the local network
  • Delay not caused by our request processing code

Now we stumbled upon the Nagle algorithm and this could mean delays for small requests on WAN networks ( http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not- friendly-towards-small-requests.aspx ).

In .NET, you can disable it by installing TcpClient.NoDelay = true( https://msdn.microsoft.com/en-us/en-US/library/system.net.sockets.tcpclient.nodelay(v=vs.110).aspx ).

How can this be disabled to handle ServiceStack TCP?

EDIT: , HttpWebRequest . HttpWebRequest, ServiceStack. ServiceStack HttpListener, / ServicePointManager. , , ServicePointManager.UseNagleAlgorithm = false .

+4
1

, UseNagleAlgorithm = false, . , ServicePointManager.UseNagleAlgorithm = false; , , . ( , ) , . ServicePoint, :

ServicePoint sp = ServicePointManager.FindServicePoint(<uri>);
sp.UseNagleAlgorithm = false;

: https://blogs.msdn.microsoft.com/windowsazurestorage/2010/06/25/nagles-algorithm-is-not-friendly-towards-small-requests/

+1

Source: https://habr.com/ru/post/1585066/


All Articles