I have spent a large portion of the last three weeks attempting to resolve a slow TCP Socket communication slowness problem.
This particular problem was between a Windows Service and multiple Windows Forms Applications.
Lots of network troubleshooting revealed nothing – neither did code reviews, gobs of debug, multi-threading research, and so forth. I finally worked my way down to about the lowest level possible and happened to notice that my the buffer that I was passing to the System.Net.Sockets.TcpClient.GetStream.BeginRead method was rather small. 1024 BYTES to be exact.
Finally, it dawned on me that this was BYTES.
I am passing some fairly large serialized objects around (hundreds of kilobytes and sometimes megabytes large). I could easily imagine that this would be a performance issue so I increased the buffer size and ta-da! SPEED!!!
So, my tip for today?? Do not be stingy with your receive buffer size.
Leave a Reply