WCF session Mode behavior

In WCF you’ve got three Concurency Mode :

  • Single
  • Multiple
  • Reentrant
Here is the MSDN definition :
Member name Description
Single The service instance is single-threaded and does not accept reentrant calls. If the InstanceContextMode property is Single, and additional messages arrive while the instance services a call, these messages must wait until the service is available or until the messages time out.
Reentrant The service instance is single-threaded and accepts reentrant calls. The reentrant service accepts calls when you call another service; it is therefore your responsibility to leave your object state consistent before callouts and you must confirm that operation-local data is valid after callouts. Note that the service instance is unlocked only by calling another service over a channel. In this case, the called service can reenter the first service via a callback. If the first service is not reentrant, the sequence of calls results in a deadlock. For details, see ConcurrencyMode.
Multiple The service instance is multi-threaded. No synchronization guarantees are made. Because other threads can change your service object at any time, you must handle synchronization and state consistency at all times.
To explain all mode, let me introduce the environment. You’ve got one client which call a WCF service. This first WCF call a second one which wait 30 secondes before send a response :
The concurencyMode is set up on the first WCF.
Now we call the WCF 1 with two clients




The last one is very interesting, it’s a mix of the single one and the multiple one. It work with one thread which can treat a new call if the present one is in stand by.

By default WCF is set up to Single. If you’ve got performance issue, a way to get better performance is just to set to Reentrant, you get the same variable access and don’t need to manage multiple call for a same object. You’ll have no code modification, it’s quick and efficiently


Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )


Connexion à %s