3

I have implemented a scenario which uses netTcpBinding and WsHttpBinding with Transport Security(https) as communication binding type in WCF. Then I compared the performance results. Interestingly, netTcpBinding was slower than wsHttpBinding. I have read a a lot of documents about binding performance and I know that the netTcpBinding provides the fastest communication because of binary encoding.

Can you explain what may cause this situation in my tests? Thanks.

Test environment: IIS 7

public static WSHttpBinding GetWSHttpForSSLBinding()
{
   WSHttpBinding binding = new WSHttpBinding();
   binding.TransactionFlow = true;
   binding.MaxReceivedMessageSize = 2147483647;
   binding.MessageEncoding = WSMessageEncoding.Text;
   binding.Security.Mode = SecurityMode.Transport;
   binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
   binding.ReaderQuotas.MaxStringContentLength = 2147483647;
   binding.OpenTimeout = TimeSpan.MaxValue;
   binding.CloseTimeout = TimeSpan.MaxValue;
   binding.SendTimeout = TimeSpan.MaxValue;
   binding.ReceiveTimeout = TimeSpan.MaxValue;
   return binding;
}

public static NetTcpBinding GetTcpBinding()
{
   NetTcpBinding binding = new NetTcpBinding();
   binding.TransactionFlow = true;
   binding.MaxReceivedMessageSize = 2147483647;
   binding.PortSharingEnabled = true;
   binding.Security.Mode = SecurityMode.Transport;
   binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
   binding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
   binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
   binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.TripleDesSha256;
   binding.ReaderQuotas.MaxStringContentLength = 2147483647;
   binding.ReaderQuotas.MaxArrayLength = 2147483647;
   binding.OpenTimeout = TimeSpan.MaxValue;
   binding.CloseTimeout = TimeSpan.MaxValue;
   binding.SendTimeout = TimeSpan.MaxValue;
   binding.ReceiveTimeout = TimeSpan.MaxValue;
   return binding;
}
mkus
  • 3,357
  • 6
  • 37
  • 45

2 Answers2

3

Your net.tcp binding uses authentication but ws http binding doesn't. Alse repeat your test with several operation calls from single proxy and with bigger message load. First call is always slow because of channel creation and connection establishment.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • thanks for your quick response. When returning object from my Wcf Service gets bigger as size, netTcpBinding has advantage over WsHttpBinding. – mkus Sep 23 '10 at 11:36
2

Are you talking about latency or throughput. Does a client create a connection and then immediately close it or does it span over multiple calls.

NetTcp has optimization over a same connection and payload size would be smaller since it uses BinaryEncoding vs TextEncoding for wshttp.

If you are looking at latency - NetTcp does windows auth with causes an AD lookup vs on wshttp you are using SSL auth.

Sajay
  • 444
  • 2
  • 6
  • thanks for your response. let me answer your questions. In these tests, client creates a connection and then close it. Interestingly, in these tests I found that when the service's return type gets bigger in terms of size, netTcpBinding has advantage otherwise wsHttpBinding. – mkus Sep 24 '10 at 06:11
  • SSL also allows connection pooling but NetTcp doesn't since it needs to restablish the security context each time even if you use nettcp with SSL the channels don't get pooled since NetTCP doesn't use the http.sys's optimization for SSL pooling. – Sajay Oct 07 '10 at 21:27