WCF - 网络成本 [英] WCF - Network Cost

查看:136
本文介绍了WCF - 网络成本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS上部署与basicHttpBinding的和WCF服务aspNetCompatibilityEnabled =真

我有一个测试客户端,以及它同时调用多个服务功能。要检查服务调用的性能上的客户端,我计算了完​​成对客户的服务请求(在代理code)和服务器,以及在平均时间服务器。

后的8小时(服务器和客户端是在同一台机器上)一个测试我来知道,平均响应时间在客户端是围绕34ms其中作为平均执行时间上的服务器是周围的3ms这样的区别是31毫秒。

我想知道为什么每次调用正在为31毫秒有正当理由?我怎么能减少呢?

编辑:由马克Gravell

回答后门柱
  1. 在SSL上的周转基金水平在IIS中没有启用其他安全
  2. 服务进行小型的数据库操作,您可以通过给3ms的平均执行时间估计运营成本。 (如果这就是你所谓的有效载荷)
  3. 在没有斑点,无MTOM
  4. 在发送和接收消息都没有大的可能是大约100字节到500字节,简单邮件合约
  5. 请让我知道如果别的需要诊断这种
  6. 其实我更关心的是TCP连接建立的成本,如果你能解释一下WCF如何做TCP连接的工作,如果没有在它针对不同的绑定任何区别可用
解决方案

经过长期的研究和测试执行我来这是由于发生在线程调用时间服务器的结论,因为WCF使用I / O完成端口(一个高效的线程模型。详细这里

和你需要设置你的服务器启动的最低并发需求可能像下面做

  ThreadPool.SetMinThreads(100,100);
 

否则你会吃亏由于2,2和任何新的线程都需要创建线程的成本池最小尺寸的默认值(每个开发人员都知道这是最昂贵的过程)。通过这样做上面的线程池将维持在-至少100线准备工作,你的服务将晃动。

因为我已经减少了高腰至31毫秒6ms的。

I have a wcf service deployed on IIS with basicHttpBinding and aspNetCompatibilityEnabled=true

I have a test client as well which invokes multiple service functions simultaneously. To check the performance of service call on client and server I calculated the Avg time it takes to complete a service request on client(in proxy code) and on server as well.

after a test of 8 hrs (server and client were on the same machine) i came to know that average response time on client is around 34ms where as the Avg execution time on server is around 3ms so the difference is 31ms.

I would like to know why every call is taking 31ms is it justified? and how can i reduce this?

EDIT: After Answer Post by "Marc Gravell"

  1. SSL Enabled within IIS no other security on WCF level
  2. Service perform minor database operation you can estimate operation cost by given 3ms average execution time. (if this is what you call payload)
  3. There is no Blob, no MTOM
  4. Send and Receive Messages are not big may be around 100 byte to 500 byte, Simple Message Contracts
  5. Please let me know if anything else required to diagnose this
  6. Actually i am more concerned about the cost of TCP Connection establishment if you can explain how WCF does the TCP connection job and if there is any difference in it against different bindings available

解决方案

After a long research and test executions i came to the conclusion that it is happening due to the Thread Invocation time on server, As WCF uses I/O completion Ports(an efficient threading model. Detail here)

and you need to set the minimum concurrency requirements in the start of your server that may be done like follows

ThreadPool.SetMinThreads(100, 100);

Otherwise you will be suffer due to the default values of pool minimum size that is 2,2 and any new thread will require a cost of creation of thread (that every developer knows that is most costly process). By doing above Threadpool will maintain the at-least 100 thread ready to work and your service will rock.

As i have reduce the the waisted 31ms to 6ms.

这篇关于WCF - 网络成本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆