简体   繁体   中英

How does WAS/IIS manage ServiceHost instances?

It appears that WAS will call ServiceHostFactory.CreateHost() once per each service implementation. How does WAS manage the lifetime of the ServiceHost/ServiceHostFactory? We have a custom factory/host that is occasionally being re-initialized. I'm wondering if WAS is recycling itself or it has some other reason to re-create the ServiceHostFactory/ServiceHost. I'm guessing the ServiceHostFactory gets fired up for the AppDomain and is a singleton, can someone confirm?

After instrumenting WCF, it appears that IIS/WAS will create a ServiceHostFactory per endpoint. From there it will spin up ServiceHosts as it sees fit, as this depends on your configuration.

The WAS manages the activation and lifetime of the worker processes. It manages the message-based activation and worker process recycling, to maintain the app resources. Reading your case, this affirmative is true.

You can use the Single InstanceContext, to handle all client request. Add the following attribute in the contract implementation:

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

Also, take a look at the ServiceHost start operation, if is under a static method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM