InstanceContextMode can be set to PerCall, Single or PerSession.
InstanceContextMode.PerCall
|
|
Description
|
New service instance for each call.
|
To enable set
|
InstanceContextMode.PerCall
|
Service Instance created when
|
The instance is created when a
request is received from the client
|
Service Instance disposed when
|
Disposed after servicing a single call.
|
Benefits
|
Scalable, Service instance disposed
after each call.
|
Issues
|
Stateless, lowers performance, Clients not aware of
multiple instances created during session.
|
InstanceContextMode.Single
|
|
Description
|
Single instance is used to serve
all calls.
|
To enable set
|
InstanceContextMode.Single
|
Service Instance created when
|
The instance is created when the
service host is created
|
Service Instance disposed when
|
Disposed when service host is closed.
|
Benefits
|
Easy to manage global state,
|
Issues
|
Less Scalable, need additional coding to manage
concurrency and session state.
|
InstanceContextMode.PerSession
(default)
|
|
Description
|
A new service instance is created
for each client channel. A unique session ID is used when servicing request
from a single client channel.
|
To enable set
|
InstanceContextMode.PerSession
|
Service Instance created when
|
The instance is created when a
request is received from a client
|
Service Instance disposed when
|
Disposed when the session ends.
|
Benefits
|
Easy to manage state for each
client.
|
Issues
|
Less scalable, client is tightly coupled to a service
instance
|
Comments
Post a Comment