Instance management basically defines the binding of service instance to a request received from a client. In case of WCF, following three techniques for service instantiation are available:
Above diagram shows that all request coming from one or more clients are served by separate instance on server.
Key points about this approach are follows:
- We will prefer to use this approach when we don’t need to maintain state between requests.
- Scalability is a major concern and service holds expensive resources like communication ports, files or database connections etc.
For PerSession Instance mode, a new instance is maintained on server for one session. For separate session, another instance is created that serves the request. Normally, we use this technique, when we need to maintain session between multiple requests.
- Approach is preferable when we need to maintain state.
- Scalability is a concern but not the biggest concern.
In case of Single/Singleton Instance mode, only one instance is created to serve all the requests coming from all clients.
In this technique, service instance is not disposed off and it stays on server to serve all incoming requests.
- We want to share global data using service.
- Scalability is not a concern at all.
Top 10 Interview Questions and Answers Series:
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
- Top 10 ASP.NET AJAX Interview Questions