CAS operations and locking using CouchbaseSessionStateProvider


We are experience 100% cpu on our web servers in some cases and we suspect that it may have something to do with couchbase/memcache session state provider.

We can see CAS hit persecaround 1.2k and some spikes up to 2-2,5k and then down to 0.5k and back to table 1.2 k.
We also have 10-20 CAS badval requests.

The question is what is CAS and can CAS affect our website in an negative way. If i understand correctly then CAS has something to do with securing the information between requests!?

I have seen something about an option “exclusiveAccess” in the configuration for the session state provider. Is this flag related to CAS?

We have 4 web frontend servers running IIS and using sessionstateprovider.

Glad for any answer that can give more information or exclude this as a problem.


Hi Johan -

CAS stands for “Check And Set” and is used as form of providing optimistic or pessimistic concurrency. It essentially only lets the user with the most recent key the ability to update it’s value.

Here is some more in-depth documentation:

And a few blogs discussing optimistic and pessimistic concurrency using CAS:

As for “exclusiveAccess”, yes, it looks like it using CAS as a means to provide exclusive access to a session key in the provider. Note that this can be disabled by setting it’s value to false in the Web.Config:

Hopefully this helps,


Thank you for the answer. This was most helpful, it’s now more clear how this works.