Ask a questionAsk a question
 

AnswernetTCP Binding slower than basicHttpBinding

  • Sunday, March 19, 2006 10:43 AMjfkrueger2 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am new to WCF and am looking forward to using it for many reasons.  I wanted to compare times it took to return a large DataSet from a WCF service using basicHttpBinding, netTCPBinding, & wsHttpBinding.  I assumed that the netTcpBinding would be the fastest due to the binary serialization etc. but to my dismay the basicHttpBinding seems to always return the results faster with the netTcpBinding coming in second.  This makes no sense to me and is kind of dissappointing actually.  Could I be doing something wrong that is causing this to be slower than it should be?  Is my assumption correct that the netTcpBinding with binary serialization should be much quicker than basicHttpBinding?

    Any light that can be shed on this for me will be a great help, thanks for reading this question. 

Answers

  • Monday, March 20, 2006 4:29 AMJohn Justice - MSFTMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Did you run your tests with the default binding configurations, or did you change the settings?  By default, the basicHttpBinding has security turned off, whereas the netTcpBinding and wsHttpBinding have security enabled.  Additionally, the WsHttpBinding has ReliableSessions turned on by default, a feature which isn't  available on the basicHttpBinding.  Try running all three with similar security and ReliableSession settings for more of an "apples to apples" comparison.

    Cheers,

    JJustice [MSFT]

  • Monday, March 20, 2006 5:49 AMjfkrueger2 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    John,

    Thanks for giving me some more info on the subject.  I used custom bindings so that I could set the maxMessageSize property on the Host side, but that and the maxBufferSize are the only properties I altered.  All the rest are the same as the svcutil created for the client.  For basicHTTPBinding, security is obviously disabled and it is being used for wsHttpBinding along with netTcpBinding.  It looks like the security is different on the netTcpBinding than on the wsHttpBinding but that makes sense.  I don't see anything about reliable sessions in the wsHttpBinding, but I am not too worried about that one because I expected it to be the slowest.  I would still think that the netTcpBinding would be faster even with the overhead of the security, but I think I just need to do more testing in a more realistic environment.  You are right about comparing using similar security, ie apples to apples for comparing raw speed, but I guess that is not what I am interested in when I think about it.  It doesn't really make sense to strip the security off of the wsHttpBinding, because I would think you are pretty much just left with the basicHttpBinding.  So, I was thinking that the netTcpBinding should be faster than the other two regardless of the security simply because it is tcp, but like I said I think I just need to do better tests...

    Thanks again for the info!

All Replies

  • Monday, March 20, 2006 4:29 AMJohn Justice - MSFTMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Did you run your tests with the default binding configurations, or did you change the settings?  By default, the basicHttpBinding has security turned off, whereas the netTcpBinding and wsHttpBinding have security enabled.  Additionally, the WsHttpBinding has ReliableSessions turned on by default, a feature which isn't  available on the basicHttpBinding.  Try running all three with similar security and ReliableSession settings for more of an "apples to apples" comparison.

    Cheers,

    JJustice [MSFT]

  • Monday, March 20, 2006 5:49 AMjfkrueger2 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    John,

    Thanks for giving me some more info on the subject.  I used custom bindings so that I could set the maxMessageSize property on the Host side, but that and the maxBufferSize are the only properties I altered.  All the rest are the same as the svcutil created for the client.  For basicHTTPBinding, security is obviously disabled and it is being used for wsHttpBinding along with netTcpBinding.  It looks like the security is different on the netTcpBinding than on the wsHttpBinding but that makes sense.  I don't see anything about reliable sessions in the wsHttpBinding, but I am not too worried about that one because I expected it to be the slowest.  I would still think that the netTcpBinding would be faster even with the overhead of the security, but I think I just need to do more testing in a more realistic environment.  You are right about comparing using similar security, ie apples to apples for comparing raw speed, but I guess that is not what I am interested in when I think about it.  It doesn't really make sense to strip the security off of the wsHttpBinding, because I would think you are pretty much just left with the basicHttpBinding.  So, I was thinking that the netTcpBinding should be faster than the other two regardless of the security simply because it is tcp, but like I said I think I just need to do better tests...

    Thanks again for the info!

  • Thursday, March 23, 2006 1:47 PMBenK3 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dont under estimate the cost of security ... In my testing tcp for a simple call is much faster than basic , but a few security settings can really kill it.  there is also a Nagle like setting Hold output buffer or something which can delay tcp messages.

    Ben