472,951 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

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 3948
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.