I've been thinking about this and it is blowing my mind...

How does a session state provider properly works internally?

I mean, I tried to write a custom session state provider based on Azure Tables or Blobs, but quickly I realized that because there is no way to ensure an atomic operation or establish a lock, race conditions are suitable to happen when several web servers do operation on that shared information.

I know that there is a SQL Server Session State Provider (SQLS-SSP) and people is happy with it, so I guess that it's using some kind of transaction isolation level in order to accomplish some degree of concurrent safety, like checking is the data is lock (a simple column), locking it if not and returning the data in an atomic operation, but is that so? what does happen if the data is lock? does it returns an error? block the call for a while? returns it in read-only fashion?

Cloud computing paradigms could be somehow new, but webfarms have been here for a while, so as I'm pretty new on it... do you recommend any good lecture about the topic?


1 Answer 1


SQL Server Session State Provider uses locking based on columns. It has several columns including: Locked, LockDate, etc.

When the session record is locked the request waits in queue until the session is accessible (provider should handle this) or until client timeouts.

The situation is actually the same even if you use inprocess session mamangement. Default session provider allows only single request to be concurrently processed when the page has write "permission" to the session.

  • And how SQL server ensures that between it checks that a row is not locked and lock it... another thread is not gonna lock it? e.g.: Thread 1 check if the row is locked; Thread 2 check if the row is locked; Thread 1 lock the row; Thread 2 lock the row; Thread 1 modify and release; Thread 2 modify and release: The changes made by Thread 1 are lost. Commented Feb 27, 2011 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.