2
votes

If I set a WCF ServiceBehavior to ConcurrencyMode = Single and host it on Azure Cloud Service as a Worker Role with 2 VM's, this service will be Single per VM or Single at all VM's?

This is important to know cause my DB has Identity Ints as PK's, and it should be a serious problem if concurrency occur: the replicated DB's might take the same increment key, causing a Violation of Primary Key on table, in my understanding.

1

1 Answers

1
votes

Neither. Setting ConcurrencyMode to Single just means your service is single-threaded (which is the default). You could still end up with multiple instances though. What you are looking for instead is InstanceContextMode and setting it to Single. This will give you the Singleton behavior per VM. However, if you have 2 Worker Roles/VM's running this service, you will have 2 instances of your WCF service running (one on each VM).

If your architecture is one that requires only one instance of your WCF service processing messages serially, then you will need to either set your Worker Role count to 1 or change your messaging pattern.