开发者

WCF service stalling to spawn threads

I have a WCF service hosted in a windows service, InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple

The nettcp binding is configured with listenbacklog="512" and service behavior is configured with maxConcurrentCalls="512"

Both server and client are running on quad processor boxes doing nothing else.

My test client uses an auto-generated proxy and makes 25 async calls on 25 threadpool threads. Although the thread count is slow to ramp up to all 25, it immediately spawns 10 threads and then starts an additional thread every second or so. The WCF Server spawns 2-3 threads to service the requests. The work done by the service's function takes a few hundred milliseconds. It takes about 20 seconds of w开发者_如何学JAVAall-clock time for all of the client calls to complete.

I've profiled the WCF server and it spends most of its time in ThreadStart_Context calling waitone()

Can somebody tell me why its so slow?


I think that the reason for this behaviour is the ThreadPool that WCF is using. It does not spawn threads too often (2 per second after reaching minimum). So you can try increasing the minimum size of the ThreadPool (please read about the consequences of this step first though). Or you can check if it's possible to use a replacement for ThreadPool in this case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜