SQLServer vs StateServer for ASP.NET Session State Performance

Darko Z picture Darko Z · Sep 19, 2009 · Viewed 37k times · Source

I'm studying for a MS certification and one of the practice tests I'm doing has a question where the point of contention is the performance between storing the session in SQL Server as opposed to StateServer.

Given the app is running in a web farm, which solution for session state gives the best performance (SQL Server or StateServer) and most importantly, why?

Answer

Mark picture Mark · Sep 20, 2009

State Server is faster because it stores session data in an in-memory dictionary. SQL Server is slower because it's stored in a database which persists data to disk.

SQL server is also slower because everything is stored in one table which leads to contention as more and more clients access/update the session data.

SQL server is more reliable because it is persisted to disk and can be set up as a cluster with failover capability.

See the preamble in this article for an indepth explanation.