WCF throttles requests

那年仲夏 提交于 2020-12-15 05:16:00

问题


I need to maintain an older service that's written in WCF. The issue is that when load testing the service, the requests appear to be throttled. On average each call takes around 250 ms on the server side. If I send one request, it completes in a little over 250 ms. If I send 10 requests, the first few complete right away and other requests are complete in seconds, where the number of seconds increases with the number of requests.

I reproduced the issue in a simple project here https://github.com/popsovy/TestWcfService

The service sleeps for 250 ms in Service1.svc.cs:

    async public Task<string> ExecuteMethod()
    {
        await Task.Delay(250);
        return "Done";
    }

And, the client creates 100 threads calling for that method. The calls appear to be NOT executing in parallel. All threads start at the same time but some of the threads finish in more than 20 seconds.

Interestingly, I created a similar project using WebApi available here https://github.com/popsovy/TestWebApi, and the behavior is what I would expect -- all 100 threads fire up almost immediately and ALL of the threads complete in about 260 ms -- the expected behavior.

It appears that the WCF service is throttled or held back from executing many concurrent requests. Is there a way to make WCF version to behave like the WebApi version -- to process all the requests at the same time?

Thank you.


回答1:


This was a client side issue -- I had to call client.Open() before executing multi-threaded calls to the service.



来源:https://stackoverflow.com/questions/64951170/wcf-throttles-requests

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!