The entire session issue has been vastly overstated. We all strive to achieve high performance applications. However what can cause a performance problem and what is a performance problem are 2 different things entirely and directly related to bulk traffic. Sessions are a perfect example. Session variables are not bad. Yes sessions use memory and yes sessions -->can<-- be bad if not used wisely.
For starters, lets talk about where this issue comes from. Session variables use memory on the server. An overabundance of session variables -->can<-- cause performance problems -->if<-- so many are running that all memory is utilized to keep their state. But what is an overabundance?
Chances are you nor I will ever have the opportunity to work on a site that gets 100,000 hits a day or more. This is where sessions -->can<-- get costly -->if<-- they are over used or not used wisely since it will take several megabits of memory to handle all the sessions created. Bill Wilkonson explains this thoroughly in this post on the 4Guys ASP message board: http://www.aspmessageboard.com/forum/showMessage.asp?M=107966&P=1&F=20
Notice I said -->if<-- they are over used or not used wisely.
Session("LoggedIn") = true
is not something that would fall under the category of resource intensive. The amount of memory needed to maintain something like this is hardly worth mentioning. But on a high traffic site like the above mentioned you would not want to use it any more than you had to. 1 Session("LoggedIn") x 100,000 by itself would require a large amount of memory -->if<-- the session was set for all 100,000 hits. Another thing to consider.
Session("MyRecordset") = rs
Session("MyShoppingCart") = CartArray(100)
are the areas you want to avoid at any level. If your recordset returns 500 records or the cart array has 100 items in it, that is HUGE in the amount of memory it will take to handle this. A session this size will cause problems even on lite sites. Objects like these not only use memory but they also can lock threads. More info here: http://www.learnasp.com/advice/threads.asp.
So you see, sessions are only an issue -->if<-- they are 1] Misused 2] Overused on high traffic sites
The majority of people reading this will never have a performance issue due to sessions if you do what I say above. As an ecommerce developer I have several sites running that use between 5 and 10 sessions each with up to 3,000 users a day and I have yet to have a problem. And neither will you.
FAQ posted by Rob Taylor at
10/29/2000 5:18:46 PM to the
Session Object category.
This FAQ has been viewed 58,918 times.