这里是否可以改善WCF传输性能?

时间:2018-06-05 15:22:50

标签: c# performance wcf wcf-binding

我测量了WCF调用的性能,发现大部分时间都是通过线路发送结果。

'2018-06-05 11:09:08,053' Getting Data

================= Call to WCF =====================

'2018-06-05 11:09:08,075' Getting view results
'2018-06-05 11:09:09,092' Getting Session
'2018-06-05 11:09:09,093' Checking visibility
'2018-06-05 11:09:09,094' Returning via WCF

============ 2.6 seconds in transit ===============

'2018-06-05 11:09:11,624' Got data from WCF
'2018-06-05 11:09:11,643' Done

使用以下绑定设置在WCF边界上获取我的结果(大约1900年)大约需要2.5秒。

TcpTransportBindingElement transport = new TcpTransportBindingElement();
transport.TransferMode = TransferMode.Streamed;
BinaryMessageEncodingBindingElement encoder = new BinaryMessageEncodingBindingElement();
CustomBinding binding = new CustomBinding(encoder, transport);
host.AddServiceEndpoint(interfaceType, binding, endpoint.EndpointAddress);

使用看起来像这样的客户端配置

<bindings>
    <customBinding>
        <binding name="streamingBinding">
            <binaryMessageEncoding />
            <tcpTransport transferMode="Streamed" maxReceivedMessageSize="10524288" />
         </binding>
    </customBinding>
</bindings>

我的理解是使用tcp和binaryEncoding进行流式传输将尽可能快。这是正确的还是我还能做些什么来提高运输性能?

0 个答案:

没有答案