On disabling the Expect100Continue header for HttpWebRequests coming out of my WCF hosted client, by adding the following to the settings section of the config file:
ServicePointManager.Expect100Continue=false
I noticed that the client waits for about 开发者_如何学C150 milliseconds between sending the HTTP POST Request and the following TCP packet that contains the actual payload.
Any Clue why this could be happening? It is unexpected because on disabling this header I'm expecting the payload to be sent immediately after the initial request with no latency.
So it turns out that .NET by default uses the Naggle Algorithm to group chunked payload for TCP efficiency. This was causing the latency, to get rid of this latency we had to set:
ServicePointManager.UseNaggleAlgorithm=false.
This changes latency from 150 milliseconds to just a few milliseconds.
精彩评论