优化WCF NetTcp开放时间

时间:2012-06-04 10:41:42

标签: c# wcf nettcpbinding

我正在使用WCF进行IPC。

我有非常严格的性能需求,因此整个操作只需几毫秒。 (阻塞3-4ms我会说...) 但是,WCF打开大约需要10毫秒。我看了一些性能测试,我看到我可以得到更好的结果,虽然我无法做到。 我可以保存一个开放的连接,但我真的想避免它。

我已经尝试在发布版中进行编译,并删除了安全性等等(仅将其降低了一点......)

这是我的配置(由代码定义):

NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.Message, false)
        {
            SendTimeout = TimeSpan.FromSeconds(1),
            ReceiveTimeout = TimeSpan.FromSeconds(1),
            OpenTimeout = TimeSpan.FromMilliseconds(500),// FromMinutes(1),
            TransactionFlow = false,
            TransferMode = TransferMode.Buffered,
            TransactionProtocol = TransactionProtocol.OleTransactions,
            HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
            ListenBacklog = ushort.MaxValue,
            MaxBufferPoolSize = 20 * 1024 * 1024,
            MaxBufferSize = 20 * 1024 * 1024,
            MaxConnections = ushort.MaxValue,
            MaxReceivedMessageSize = 20 * 1024 * 1024,
        };

        // Windows authentication
        tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
        tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;

        return tcpBinding;

有人建议改进此配置吗? 感谢。

0 个答案:

没有答案