Thursday, February 18, 2010

Notes on Programming WCF - Part V - Instance Management


Excerpts on a great WCF book: "Programming WCF Services- by Juval Lowy"

Instance Management

Instance management is applied by Service Behavior attribute InstanceContextMode which could hold three below values:
1.       Per Call
Pros:
1-      Highly scalable          
Cons:
1-      State overhead
2.       Per Session (WCF default) Similar to client/server model. It cannot serve more than couple of hundreds request at the same time.
1.       Session Modes: this mandates the use of a transport session, and It depends on support of session on bindings (e.g. httpBinding does not have session).
Each proxy and its channels are bound to an instance of the service.
1.       Allowed (WCF Default)
2.       Required
3.       NotAllowed
3.       Singleton

Involved elements in service instance management:
1-      Service context instance mode
2-      Session Mode: transport session mode
3-      Proxy
4-      Binding
5-      Instance deactivation : this is an optimization technique which should be avoided until it’s needed
ReleaseInstanceMode: this is a method level attribute that mandates when to re-instantiate the service instance
a.       None: no impact on instance life
b.      BeforeCall: This mode tells WCF to create a new instance before making the call, this is usually good for create() methods that are initializing
c.       AfterCall: This mode tells WCF to drop the instance after the call is completed, this is usually a good for CleanUp() methods
d.      BeforeAndAfterCall:

No comments:

Post a Comment