开发者

Limit WCF service resources usage

I'm developing a web application that needs to perform a task that consumes a lot CPU and Memory, and that also may last several minutes. In order to get a better user experience, I also developed a windows service that hosts a WCF service that performs this "high cost" task and that comunicates with the web app using msmq (message queues).

This worked great until I tried to make a load test... The windows service starts consuming a lot of 开发者_运维百科resource, puttin the CPU to work at 100% and more than 1GB of memory. I've looked for optimizations and I've done a lot of tweaks to the code and I think that it is very efficient, but the task just requires a lot of resources.

The problem is that while the WCF service is working, the CPU gets used at 100% and the web app turns INCREDIBLY SLOW! I don't mind if the task that the WCF service does takes a couple of minutes more, but I want the web app to perform well for users.

So I'm wondering if there is a way to limit the resources that the WCF service can consume, giving priority to the web app.

Thanks in advance.

Juan


The easy solution would be to place the WCF service on a different machine.

The fact that the service is using alot of CPU is probably not related to you using WCF.

There are some ways that you may be able to improve the performance of your web app:

  • Process only one message at a time.
  • Break the jobs into smaller parts.
  • Set priority of the windows service to below normal in the task manager
  • Install more RAM on the server


I guess this is a problem of your Windows service design. When you decide to host WCF in Windows service you have to control resource utilization = you have to control throttling. You have to create configurable control over internal service processing so that you can change the load based on available resources. If you host WCF in IIS it already provides such control on AppPool level.

There are some freeware tools which allow limiting CPU usage for given process but that is not something I would recommend for production usage.

Best regards, Ladislav

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜