I am making a lot of requests to a remote webservice with RestSharp, and I wanted to parallelize them. I used the Tasks framework to do so.
What I'm seeing is that when my client is busy and the remote service is a little slow, the time I measure for each request goes up and up. Yet when I look in Wireshark, the requests take much less time than I'm measuring.
Adding more parallel threads doesn't help - if anything it seems to make things worse. I switched my code back to the generic Execute() so that I could measure the request separately from the deserialization (just in case) but still the same result.
I don't share any instances of any objects between my threads.
One thing I noticed in Wireshark was that there only seemed to be one TCP connection active per process. From my reading, I believe what's happening is that connection pooling the HttpWebRequest uses is causing all the threads to share a single underlying connection. I believe they are contending and blocking on the connection, which can only process one call/response at a time in series.
Is my hypothesis reasonable, and if so, how do I make each thread use its own TCP connection?
Thanks!