views:

600

answers:

3

One of my applications uses sql session state, the timeout is currently set to 20 minutes. My question is, since this is stored in the database and not in server memory, I should be able to increase the timeout without any significant performance issues right?

I dont really understand the importance of the timeout for the database session state scenario, since the database should easily be able to handle a lot of sessions.

Am I missing something?

A: 

As long as you make sure you close your connections after using them - e.g.

using (SqlConnection conn = new SqlConnection("connectionstring")) {
    // do stuff here
    // conn will be automatically closed & disposed when this block completes
}

then the timeout should not matter.

Fritz H
.NET manages this for you in the SQLServer Session-State mode.
Yuriy Faktorovich
+1  A: 

I think the timeout's relevance is more for public-facing websites where you could potentially get a lot of hits and fill up your database fairly quickly. That being said, infinite isn't exactly what you want either...

Dave Markle
+1  A: 

I was looking for confirmation of your opinion, too-- that if harddrive space is cheap, I should be able to have 8 hour sessions in SqlSessionState without noticable performance issues (beyond what 20 minute sql server session cause), given a medium sized office level intranet application.

Just try to keep in mind that the advice about session deals with how many users you can deal with at once, how likely it is that users will start some work, get interrupted for a long time, and need to continue.

And finally if you are storing authentication tokens or roles in session, then you may want to expire those more often to check the user still is a user and still has those roles.

MatthewMartin