3

我已经实现了一个场景,它使用 netTcpBinding 和 WsHttpBinding 和传输安全(https)作为 WCF 中的通信绑定类型。然后我比较了性能结果。有趣的是,netTcpBinding 比 wsHttpBinding 慢。我已经阅读了很多关于绑定性能的文档,并且我知道 netTcpBinding 由于二进制编码而提供了最快的通信。

你能解释一下我的测试中可能导致这种情况的原因吗?谢谢。

测试环境: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;
}
4

2 回答 2

3

您的 net.tcp 绑定使用身份验证,但 ws http 绑定不使用。还使用来自单个代理的多个操作调用和更大的消息负载重复您的测试。由于通道创建和连接建立,第一次调用总是很慢。

于 2010-09-23T10:55:45.417 回答
2

您是在谈论延迟还是吞吐量。客户端是创建连接然后立即关闭它还是跨越多个调用。

NetTcp 对相同的连接进行了优化,并且有效负载大小会更小,因为它对 wshttp 使用 BinaryEncoding 与 TextEncoding。

如果您正在查看延迟 - NetTcp 执行 windows auth 会导致 AD 查找,而在 wshttp 上您正在使用 SSL auth。

于 2010-09-23T23:39:46.080 回答