Reputation: 9763
Consider the following basic unit test code for a WCF service.
for (int i = 0; i < 10000; i++)
{
ServiceClient proxy = null;
try
{
proxy = new ServiceClient("basicHttpService"); // or netTcpService
Order[] orders = proxy.Find(Guid.Empty);
}
finally
{
if (proxy != null && proxy.State == CommunicationState.Opened)
proxy.Close();
}
}
I was quite surprised that the netTcp endpoint takes 2.5 minutes for 10k iterations and the basicHttp one takes 23 second. Keeping the connection open during the full loop makes the two endpoints perform about the same. (~20 seconds)
Is this normal that opening up a netTcp connection is so heavy compared to basicHttp?
Upvotes: 1
Views: 248
Reputation: 3297
It's hard to give an accurate answer not knowing the nature of the transport object, but I'm guessing that in this example the amount of data being passed around is small. I have seen significant gains in performance moving to tcp from http when passing around large amounts of data.
Also, don't forget that the tcp session is reliable - there is a whole bunch of WCF "kung-fu" involving hand-shaking and security to ensure that the reliable session is maintained. You could try turning off the security on the binding and seeing if that makes any appreciable difference (not necessarily a recommendation!).
Upvotes: 2