WCF services. Create multiple instances at startup?

Sorry if this was asked before, but I searched and cannot find the answer

We have a WCF service that provides up to 100 instances, since there are 10,000 clients, but the calls are very fast.

The only overhead we noticed was the first call to the instance ... for example. the first call to any of the instances (or after repeated use) there is a noticeable delay compared to any other calls.

Is there a way to "start" 100 instances when IIS starts? So deleting this overhead?

Is there a way to find out how many instances are currently “actively / insighted” in the service?

Thanks a lot, Dave.

+3
source share
3 answers

You can use the service through a remote interface from the server after launch.

Or, perhaps you can pass an instance of the service class to ServiceHost when the server starts, if you use your own hosting.

If you host in IIS, you will need CustomHostFactory. There is a pretty good article on how to do this here. http://msdn.microsoft.com/en-us/library/bb332338.aspx .

In terms of instance tracking, you can simply increase or decrease the reference count in the service class.

+2
source

If you host on IIS 7.5 , you should definitely check out the Warmup Module for Applications .

+1
source

100 . , singleton service = . , , .

To defrost your application, the Encrico module is used. If you are not using IIS 7.5, you have another option. Create a custom console application to submit your service. Schedule this application in Windows Scheduler.

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

0
source

Source: https://habr.com/ru/post/1763431/


All Articles