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

Home Posts Topics Members FAQ

Context Switches, Web Gardens and InProc Session State

Hi there,

We have an ASP.Net application that is generating huge numbers of Context
Switches when a certain number of active users are present. We tried changing
the configuration of the Application Pool to use a Web Garden and the number
of Context Switches decreased by more than 95% (that's the good news).

Our problem is that we have something in our session state that cannot be
serialized and therefore we cannot use StateServer for the Session mode.

We have been trying to find a way to get all requests associated with a
specific session to be dispatched to the one worker process. The Microsoft KB
article at http://support.microsoft.com/default.aspx/kb/822171 says:

"If an application keeps a connection alive and uses the same source port,
the requests are routed back to the same worker process."

We cannot seem to get this to occur for us. Does this apply to http requests
or is it only referring to ftp and other protocols served by IIS?

We have found plenty of places that state categorically that InProc session
state cannot be used with Web Gardens but we are hoping that the KB article
above knows something that they don't. Can anyone help us to tie particular
sessions to particular worker processes?

Thanks,

Brendan
Jul 29 '08 #1
6 1938
"Brendan Kay" <Br********@dis cussions.micros oft.comwrote in message
news:FA******** *************** ***********@mic rosoft.com...
Hi there,

We have an ASP.Net application that is generating huge numbers of Context
Switches when a certain number of active users are present. We tried
changing
the configuration of the Application Pool to use a Web Garden and the
number
of Context Switches decreased by more than 95% (that's the good news).
Define 'Huge'. Are you sure that it was a problem? How many CPU cores do
you have and can you add more? I'm not sure how using a Web Garden actually
resolves the problem. What is the CPU usage rate like?

Our problem is that we have something in our session state that cannot be
serialized and therefore we cannot use StateServer for the Session mode.

We have been trying to find a way to get all requests associated with a
specific session to be dispatched to the one worker process. The Microsoft
KB
article at http://support.microsoft.com/default.aspx/kb/822171 says:

"If an application keeps a connection alive and uses the same source port,
the requests are routed back to the same worker process."

We cannot seem to get this to occur for us. Does this apply to http
requests
or is it only referring to ftp and other protocols served by IIS?
Are your clients connecting via a proxy or firewall, (even if they are
internal clients I've often seen configurations which unintentionaly route
HTTP through a firewall/proxy to an internal server)?

That said its not possible to guarantee a fixed connection. Additionally
browser will use more than one connection, the likely hood is then that the
browser will have one connection on one process and another to the other
process.

>
We have found plenty of places that state categorically that InProc
session
state cannot be used with Web Gardens but we are hoping that the KB
article
above knows something that they don't. Can anyone help us to tie
particular
sessions to particular worker processes?
Web Gardens are not compatible with inproc session state. There is no good
mechanism in place that can affiliate a session with a process.
Load balancing and a Web Farm is more intelligent its able to affiliate a
client with a server.
Other options would be:-

Divide the site into separate applications what each run in their own pool

Allow commonly request chunks of dynamically generated HTML that don't often
differ from one request to the next to be cached.

--
Anthony Jones - MVP ASP/ASP.NET
Jul 29 '08 #2
"Anthony Jones" <An*@yadayadaya da.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Web Gardens are not compatible with inproc session state. There is no
good
mechanism in place that can affiliate a session with a process.
Correct.
Load balancing and a Web Farm is more intelligent its able to affiliate a
client with a server.
I would suggest that this is probably the best solution for the OP,
budgetary constraints notwithstanding ...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '08 #3
"Anthony Jones" wrote:
Define 'Huge'. Are you sure that it was a problem? How many CPU cores do
you have and can you add more? I'm not sure how using a Web Garden actually
resolves the problem. What is the CPU usage rate like?
Hi Anthony, thanks for your reply.

You are quite right that I should have provided more details - sorry about
the vagueness of the first post.

When running on a single worker process the Context Switches per second gets
up to 300K+. This is on a dual quad core machine so it a lot of context
switches per core.

When the application pool is configured to use 8 worker processes (one per
core) the context switches fall to less than 10K.

In both cases the CPU utilization stays around 30-50%. It seems to be pretty
clear that the context switches are the problem for us (unless I am missing
something else ;-).

I am not really sure why there would be such a big difference in context
switches because of the number of worker process (for exactly the same load)
but it is dramatic. The average response time per page goes from about 1.3s
to 12s.
Are your clients connecting via a proxy or firewall, (even if they are
internal clients I've often seen configurations which unintentionaly route
HTTP through a firewall/proxy to an internal server)?
No, the clients are connecting directly (we have done tests that go through
a firewall and the results are the same).
That said its not possible to guarantee a fixed connection. Additionally
browser will use more than one connection, the likely hood is then that the
browser will have one connection on one process and another to the other
process.

Web Gardens are not compatible with inproc session state. There is no good
mechanism in place that can affiliate a session with a process.
That is a shame (but not a huge surprise). We were hoping the knowledge base
article 822171 might be referring to some technique for keeping the
connection alive and having all the requests for a particular session routed
to the same worker process.
Load balancing and a Web Farm is more intelligent its able to affiliate a
client with a server.
We are looking into that now.
Other options would be:-

Divide the site into separate applications what each run in their own pool
This is another option we are looking at. We are seeing whether the
application can be run as several IIS applications and we may put our own
dispatcher in front of it.
Allow commonly request chunks of dynamically generated HTML that don't often
differ from one request to the next to be cached.
Unfortunately all our pages are generated dynamically so caching is not an
option but we do believe we will find an alternate solution.

Thanks again for your thoughts.
>
--
Anthony Jones - MVP ASP/ASP.NET
Jul 29 '08 #4
Hi Mark,

Thanks for the reply. We will look into the web farm option as well as
options for inserting our own dispatcher.

Brendan

"Mark Rae [MVP]" wrote:
"Anthony Jones" <An*@yadayadaya da.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Web Gardens are not compatible with inproc session state. There is no
good
mechanism in place that can affiliate a session with a process.

Correct.
Load balancing and a Web Farm is more intelligent its able to affiliate a
client with a server.

I would suggest that this is probably the best solution for the OP,
budgetary constraints notwithstanding ...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '08 #5
"Brendan Kay" <Br********@dis cussions.micros oft.comwrote in message
news:17******** *************** ***********@mic rosoft.com...
"Anthony Jones" wrote:
Define 'Huge'. Are you sure that it was a problem? How many CPU cores
do
you have and can you add more? I'm not sure how using a Web Garden
actually
resolves the problem. What is the CPU usage rate like?

Hi Anthony, thanks for your reply.

You are quite right that I should have provided more details - sorry about
the vagueness of the first post.

When running on a single worker process the Context Switches per second
gets
up to 300K+. This is on a dual quad core machine so it a lot of context
switches per core.

When the application pool is configured to use 8 worker processes (one per
core) the context switches fall to less than 10K.

In both cases the CPU utilization stays around 30-50%. It seems to be
pretty
clear that the context switches are the problem for us (unless I am
missing
something else ;-).

I am not really sure why there would be such a big difference in context
switches because of the number of worker process (for exactly the same
load)
but it is dramatic. The average response time per page goes from about
1.3s
to 12s.
Did you mean from 12s prior to using a web garden to 1.3s using a web
garden?
Do the worker processes run in 64bit?
How much memory do you have on the box?
Are your clients connecting via a proxy or firewall, (even if they are
internal clients I've often seen configurations which unintentionaly
route
HTTP through a firewall/proxy to an internal server)?

No, the clients are connecting directly (we have done tests that go
through
a firewall and the results are the same).
That said its not possible to guarantee a fixed connection.
Additionally
browser will use more than one connection, the likely hood is then that
the
browser will have one connection on one process and another to the other
process.

Web Gardens are not compatible with inproc session state. There is no
good
mechanism in place that can affiliate a session with a process.

That is a shame (but not a huge surprise). We were hoping the knowledge
base
article 822171 might be referring to some technique for keeping the
connection alive and having all the requests for a particular session
routed
to the same worker process.
Load balancing and a Web Farm is more intelligent its able to affiliate
a
client with a server.

We are looking into that now.
Other options would be:-

Divide the site into separate applications what each run in their own
pool
>
This is another option we are looking at. We are seeing whether the
application can be run as several IIS applications and we may put our own
dispatcher in front of it.
I'm not sure what you mean by dispatcher or why you would need one?

The problem would be if there is some state in one sub application or
session thereof, that is needed in another sub application. Typically this
would be user authentication data. You would need to handle this yourself
and would probably need to form an umbrella session cookie that has a
path="/" (the sub application session cookies will be rooted in their
directories). It can get a bit hairy, and ultimately more costly that
installing a Web Farm. OTH, if most access is anonymous and you have
significant independant parts to your site then its fairly straightforward .
>
Allow commonly request chunks of dynamically generated HTML that don't
often
differ from one request to the next to be cached.

Unfortunately all our pages are generated dynamically so caching is not an
option but we do believe we will find an alternate solution.
They may be generated dynamically but is the underlying data so volatile
that the same URL is unlikely to generate the same markup even when hit
several times a second. Just because something is generated dynamically
does not mean it can't be cached. Even for data that some would consider
quite volatile a 2 minute cache period for a high frequency URL could have a
significant impact.

--
Anthony Jones - MVP ASP/ASP.NET
Jul 29 '08 #6
Hi Anthony,

Thanks again for your continuing help.
Did you mean from 12s prior to using a web garden to 1.3s using a web
garden?
Do the worker processes run in 64bit?
How much memory do you have on the box?
Yep, avarage page response time is about 1.3s when configured as a web
garden and about 12s when configured as a single worker thread.

The server has 4Gb of memory and the actual memory used by each worker
process is only about 100Mb. The server is running 32bit (and we can't change
that right now).
I'm not sure what you mean by dispatcher or why you would need one?

The problem would be if there is some state in one sub application or
session thereof, that is needed in another sub application. Typically this
would be user authentication data. You would need to handle this yourself
and would probably need to form an umbrella session cookie that has a
path="/" (the sub application session cookies will be rooted in their
directories). It can get a bit hairy, and ultimately more costly that
installing a Web Farm. OTH, if most access is anonymous and you have
significant independant parts to your site then its fairly straightforward .
If we do go with the dispatcher it will be a front end application that
receives the request and creates an outer session for it. This session would
simply remember which URL it is passed on to and store the appropriate
session id/cookie to pass on. For any requests that come in from the same
outer session it would pass them on to the inner session with the appropriate
cookie (or URL).

In theory we believe it will work and we think the performance impact will
be much less than the context switches we are currently getting but we have
not actually coded it yet so there may be something that stops it being used.
They may be generated dynamically but is the underlying data so volatile
that the same URL is unlikely to generate the same markup even when hit
several times a second. Just because something is generated dynamically
does not mean it can't be cached. Even for data that some would consider
quite volatile a 2 minute cache period for a high frequency URL could have a
significant impact.
In our case the dynamically generated pages use data from another source
that cannot be cached and must always display the current version (this is
ultimately the data and state that actually stops us from serializing the
session state). We can't see a way to use caching but we hope the web farm or
dispatcher will give us what we need.
--
Anthony Jones - MVP ASP/ASP.NET
Thanks again for your help.

Brendan
Jul 29 '08 #7

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

Similar topics

3
15406
by: Andrew Durstewitz | last post by:
I'm working with a Windows 2003 IIS 6.0 Server with 2 2.8Ghz HT processors (4 Proc to the server because of the HT). My problem I that I have web garden turned on and can't get the sessions to stay. I am new to IIS 6.0 so I don't know much about the whole web garden thing. However, my entire site is written around ASP using Sessions. ...
2
2203
by: Alan Partridge | last post by:
We are hosting our ASP.NET application on a multi-proc (4) machine but we're using InProc session state. Machine.Config has webGarden=false at the moment and only one ASP.NET worker process in running. Therefore, my guess is that running on a multi-proc box is wasted because only 1 CPU is being used - is this correct My understanding is that...
1
1849
by: ciaran | last post by:
I have a web app. running on a dual processor with 1GB RAM and SQL 200 Database At any one time there can be around 20/30 users accessing it through the web interfac performing tasks such as searching through DataSets, and a further 20/30 users performin Replication using HandHeld Devices with SQL CE From a web app. point of view I tend to...
4
1225
by: | last post by:
I'm not sure what to think of this. In the appliacation, upon postback, users screens will get mixed up. Meaning... Perhaps on my screen im working with a particular set of data. I click a button to cause a post back, then all of the sudden someone elses data comes up. If I hit the refresh button, my data comes back again. Here are the...
13
2434
by: James Hunter Ross | last post by:
We love the ASP.NET "Session" concept and make good use of it. But, getting close to deployment we find we lose sessions far too often, probably due to application restarts, etc. We hope to eliminate these restarts, but we're not sure that can be achieved. (We are exploring who/what might be touching web.config or assemblies or other files...
2
2808
by: teo | last post by:
I need to use the 'Session_End' event in the 'Global.asax' file. It only works if in the 'Web.config' file the 'sessionState mode' Tag is present and its value is set to "InProc" 1) I thought it was a default setting, wasn't it?
4
2151
by: Alex | last post by:
Hello, This is a follow-up to my earlier post about having issues with our application pool recycling. We currently use Session State InProc, but if I were to choose to move the existing application to SQL instead, would the only change in the application be the SessionState setting within web.config? I know I'd also need to setup our MS...
2
1427
by: =?Utf-8?B?VW1lc2huYXRo?= | last post by:
Hi, My application is running with two web server let say W1 & W2 and load balance controls the request to web servers . One of my application page pop up a new page and there I am using Context.User prpoerty to get current user informtaion and convert into my customer class which lot of customer information . This works fine in...
4
11181
by: wilderness | last post by:
I have a Windows 2000 Server (SP4) with .NET Framework 1.1 (with hotfixes) installed, along with .NET Framework 2 I have a Delphi .DLL that interfaces with several .aspx files as part of a member database. Each .aspx file contains categorized properties about members. The first page is named profile1.aspx, the second page profile2.aspx and so...
0
7923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2364
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 we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.