开发者

WCF Services - Create multiple instances on startup?

Apologies if this has been asked before, but I've searched and can't find an answer

We have a WCF service that provides upto 100 instances - as there are 10,000 clients but the calls are very quick.

The only performance overhead we've noticed is on the first call to an instance...e.g. the first time any of the instances is called (or after recycling) there is a noticeable delay, compared to any other calls.

Is there any way to "fire up" 100 instances on IIS startup? Thus rem开发者_如何学Pythonoving this overhead?

Is there a way to find out how many instances are currently "active/insantiated" on a service?

Many thanks, Dave.


you could the service via remote interface from the server after startup.

Or perhaps you can pass an instance of the service class to the ServiceHost on server startup if you are using custom hosting.

If you are hosting within IIS then you'll need a CustomHostFactory. There is a fairly good article on how to do this here. http://msdn.microsoft.com/en-us/library/bb332338.aspx.

In terms of keeping track of instances, then the you could just increment/decrement a reference count within the service class.


If you are hosting on IIS 7.5, you should definitely check out the Application Warmup Module.


You can't fire up 100 instances when application start. It is possible only when you have singleton service = one instance for all requests. Your scenario uses per call instancing so instance is created each time the client calls the service and disposed after processing call.

To warm up your application use module Encrico suggested. If you don't use IIS 7.5 you have another option. Create custom console application to ping your service. Schedule this application in Windows Scheduler.

To track number of running instances you can use performance counters. I'm not sure if WCF provides such counter out of the box but you can always create your own counter and work with it in custom ServiceHost class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜