I recently debugged a performance issue with how I was using SslStream.
The client is C#/.NET and had the following Stream configuration
- Raw Socket/NetStream
- Wrapped by BufferedStream
- Wrapped by SslStream
- Wrapped by "protocol" stream (which sends bytes/ints/strings etc)
I was seeing extremely slow performance when sending data from a client to a server, across the internet where it was taking a long time to serialise information on the client side.
Removing SSL stream and the connection sped up to expected levels.
Then I changed the above stream configuration to be..
- Raw Socket/NetStream
- Wrapped by SslStream
- Wrapped by BufferedStream <-- moved this
- Wrapped by "protocol" stream (which sends bytes/ints/strings etc)
And the connection sped up to expected levels.
Can someone explain why changing the stream configuration helps the performance so much?Particularly as I tested the original configuration with the client on the same machine as the server at it ran very quickly?