将NetHttpBinding移植到.NET 4.0

时间:2014-03-26 09:15:20

标签: c# wcf wcf-binding

我在Windows 7上,因此我没有使用WebSockets。我试图通过CustomBinding将.NET 4.5的NetHttpBinding模仿到.NET 4.0。

但是,使用我当前的CustomBinding,我无法接近性能。

你能帮助我获得正确的配置以获得最快的速度吗?

注意:传输必须是HTTP,编码应该是二进制(无压缩)

<customBinding>
    <binding name="netHttp" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00">
      <reliableSession />
      <compositeDuplex />
      <oneWay />
      <binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647">
        <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="1024"/>
      </binaryMessageEncoding>
      <httpTransport 
          maxReceivedMessageSize="2147483647" 
          maxBufferPoolSize="2147483647" 
          maxBufferSize="2147483647" 
          keepAliveEnabled="true"
          allowCookies="false"
          useDefaultWebProxy="false"
          unsafeConnectionNtlmAuthentication="false"/>
    </binding>
  </customBinding>

表现比较:

NetHttpBinding(.NET 4.5)

Wcf.GetSimpleMessage
- Average: 332173.2 ticks [33.21732ms]
- Min: 22066 ticks [2ms]
- Max: 641235 ticks [64ms]
- [10] Instances
- Output:
A simple message for Marc.

Wcf.GetObjectMessage
- Average: 60384.4 ticks [6.03844ms]
- Min: 35128 ticks [3ms]
- Max: 95546 ticks [9ms]
- [10] Instances
- Output:
Request: [ LastID: 0, PageSize: 1000, Name: Any, ID: 0 ]

Wcf.GetFiles
- Average: 487740.7 ticks [48.77407ms]
- Min: 47447 ticks [4ms]
- Max: 939283 ticks [93ms]
- [10] Instances
- Output:
Result: [ FileName: css.pdf, Size: 1163024 bytes ]

CustomBinding(.NET 4.0)

Wcf.GetSimpleMessage
- Average: 2722518.8 ticks [272.25188ms]
- Min: 1118405 ticks [111ms]
- Max: 4545144 ticks [454ms]
- [10] Instances
- Output:
A simple message for Marc.

Wcf.GetObjectMessage
- Average: 1230078.4 ticks [123.00784ms]
- Min: 567742 ticks [56ms]
- Max: 1825263 ticks [182ms]
- [10] Instances
- Output:
Request: [ LastID: 0, PageSize: 1000, Name: Any, ID: 0 ]

Wcf.GetFiles
- Average: 1509024.3 ticks [150.90243ms]
- Min: 753773 ticks [75ms]
- Max: 2063954 ticks [206ms]
- [10] Instances
- Output:
Result: [ FileName: css.pdf, Size: 1163024 bytes ]

0 个答案:

没有答案
相关问题