473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQLServer session state performance issues

I'm trying to find out some of the details behind OOP
state management with SQL Server. For instance
- how long does the session object live on any server? Is
it created and destoyed with each page request?
- will each reading of a session variable cause a round
trip to the DB server? or does the complete session live
within the HttpContext object?
- when asp.net session state is enabled (in any mode),
after a session has been created, will it always be called
up into the HttpContext object with every page request,
even when no reads or writes to session variables occur?
- I've read that both OOP options must
serialize/deserialize the session data, so is the only
performance difference between stateServer and SQLServer
the overhead involved with accessing/reading/locking the
DB?

thanks for any info provided
- John
Nov 18 '05 #1
4 3988
okay will try and answer some of the questions...
1. Any data saved into session object is by default bound to what you
specify in you web.config file...
if you dont specify any values... it will take the default values from
machine.config file.
if your application's web.config has session to 30 mins and your
machine.config has a setting of 10 mins...
the objects in session will be kept alive till 30 mins from last request
handled by aspnet worker process

2. if you are using sql server to maintain session state.. any read write
would cause a round trip to the db.

3. The way i think its relation with HttpContext is by the session id cookie
passed by the browser or from the header if you are using cookie-less
session
4. Yes you need to serialize / deserialize data if you need to write to
State server / SQL server based session state storage.
And the only difference is you can have State Server as a local process
on one of the web boxes or you can specify a dedicated server
And with SQL Server... the round trips to read and write any data...

--
Regards,

HD

"John Q. Smith" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
I'm trying to find out some of the details behind OOP
state management with SQL Server. For instance
- how long does the session object live on any server? Is
it created and destoyed with each page request?
- will each reading of a session variable cause a round
trip to the DB server? or does the complete session live
within the HttpContext object?
- when asp.net session state is enabled (in any mode),
after a session has been created, will it always be called
up into the HttpContext object with every page request,
even when no reads or writes to session variables occur?
- I've read that both OOP options must
serialize/deserialize the session data, so is the only
performance difference between stateServer and SQLServer
the overhead involved with accessing/reading/locking the
DB?

thanks for any info provided
- John

Nov 18 '05 #2

session state is maintained by a httpmodule. All HttpModules used for a page
request are created and destroyed on each page request. HttpModules
implement two methods: Init & Dispose

the default sql session handler is very simple. on each page request, a new
Session object is created,

Init- this is when the session data is read from the sqlserver and
serialized back into objects
Dispose - this is when it serializes the data out to the sqlserver.

with sqlserver session state, the objectes are serialized to to a table,
and deleted by a stored proc that is run on a schedule.

the stateServer works as above, but rather than storing the xml in a table,
its stored in a hashtable on the shared server.

the inproc session manager stores a reference to the actual object in a
static hash table and thus requires no serialization. it runs a timer to
know when to free up session objects, and fire on session end event, when
this happens.
-- bruce (sqlwork.com)

"John Q. Smith" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
I'm trying to find out some of the details behind OOP
state management with SQL Server. For instance
- how long does the session object live on any server? Is
it created and destoyed with each page request?
- will each reading of a session variable cause a round
trip to the DB server? or does the complete session live
within the HttpContext object?
- when asp.net session state is enabled (in any mode),
after a session has been created, will it always be called
up into the HttpContext object with every page request,
even when no reads or writes to session variables occur?
- I've read that both OOP options must
serialize/deserialize the session data, so is the only
performance difference between stateServer and SQLServer
the overhead involved with accessing/reading/locking the
DB?

thanks for any info provided
- John

Nov 18 '05 #3
you might want to have a look at this one

http://msdn.microsoft.com/library/de...ssionstate.asp

--
Regards,

HD

"John Q. Smith" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
I'm trying to find out some of the details behind OOP
state management with SQL Server. For instance
- how long does the session object live on any server? Is
it created and destoyed with each page request?
- will each reading of a session variable cause a round
trip to the DB server? or does the complete session live
within the HttpContext object?
- when asp.net session state is enabled (in any mode),
after a session has been created, will it always be called
up into the HttpContext object with every page request,
even when no reads or writes to session variables occur?
- I've read that both OOP options must
serialize/deserialize the session data, so is the only
performance difference between stateServer and SQLServer
the overhead involved with accessing/reading/locking the
DB?

thanks for any info provided
- John

Nov 18 '05 #4
Thanks to both of you for your feedback. That is a very helpful link Dave. To summarize the answers to my questions:
1. The session state is part of HttpContext. Once a session exists, the session data is retrieved from the state provider with every page request. The data is loaded into local memory and exists only as long as it takes to process the request. This means that session data is not cached on local web servers, it is retrieved fresh from the remote provider every time.
2. There are 2 round trips to the DB with every page request: a read (update) and a write. While a page is processing you can access one, some, all, or none of the session variables without affecting the hits on the DB server. Session variable reads and writes are done in local memory.
3. Yes, the entire session data set is loaded into the HttpContext object whether the page uses those data or not.
4. As far as I can tell, the only performance difference (between the two OOP options) is the overhead involved with SQL Server itself - establishing a connection, reading and writing (via stored procs).

John
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2452
by: quique | last post by:
Hi all, I want to know the advantages and disadvantages of the methods of maintain session state, obviously if i choose sqlserver is the most robust but the less performace.. If wan't to...
1
2671
by: Julie Barnet | last post by:
Hi, I am having a problem with my session state through sql server. This used to work, then all of a sudden (the only change was setting up replication in the sqlserver database) it stopped...
8
8394
by: karahan celikel | last post by:
I realized that when SqlServer mode is used for session management Session_End event is not fired in global.asax. What can I do if I want to do something when a user's session end? Thanks
5
2191
by: ASP.Confused | last post by:
As you can tell from my previous posts on this issue...I'm really confused :-/ I have a few ASP.NET web applications on my web host's "https" server. Our web host has a single "bin" folder for...
18
3401
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
26
3579
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
11
7885
by: Joseph Geretz | last post by:
I've been looking at two approaches for the maintenance of Session state for a Web Service application. One approach uses the old familiar Session object which I've used in the past for Web...
1
1465
by: =?Utf-8?B?TmVpbGUgQmVybXVkZXM=?= | last post by:
Hi there My team is responsible for designing the architecture of the web hosting environment in my orgnaisation. We plan to implement an IIS web farm, load balanced by a couple of industry...
3
3441
by: Moe Sisko | last post by:
Using dotnet 2.0 sp1, I've got ASP.NET session state working ok in SQLServer mode, but the sessions never seem to expire. e.g if I add a timeout attribute like so : <sessionState...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.