Thursday, March 29, 2012

maximum number of sessions....

Is there anyway to montior the number of user sessions from an asp.net
app\page?

The reason I ask is because I would like to throttle the number of
concurrent sessions to a website, i.e. limit the number of concurrent user
sessions lets say to 10,000 and if a user session exceeeds this amount they
would be redirected to a 'Server is to busy' screen.

I get the feeling there is no way to programmtically do this as I believe
the number of possible supported session is dependant on hardware and the
size of the data being stored in a session.

Cheers in advance

OllieI've been using this code in global.asax, but the session count is flawed...
I just don't believe the results are correct :) I think I read somewhere
that the session_end is not firing, but someone else will have to tell you
about it.

function Session_Start(sender:Object, e:EventArgs) {
Application.Lock();
curUsers = (int)(Application["howManyUsers"]);
if (String(curUsers)!="NaN") {
curUsers++;
} else {
curUsers = 2;
}
Application["howManyUsers"] = curUsers;
Application.UnLock();
}

function Session_End(sender:Object, e:EventArgs) {
Application.Lock();
curUsers = (int)(Application["howManyUsers"]);
if (String(curUsers)!="NaN") {
curUsers--;
} else {
curUsers = -1;
}
Application["howManyUsers"] = curUsers;
Application.UnLock();
}

--
Jure pik
Cheers for the reply,

session_end events don't fire when you have a web farm (effectively when
ever you have out of process session state) - and the code you sent would
not work on a web farm either as the Application object is process specfic.

Cheers

Ollie Riches

"Carpe Diem" <webdesign@.carpediem.si> wrote in message
news:OC3Ot3ouEHA.1448@.TK2MSFTNGP10.phx.gbl...
> I've been using this code in global.asax, but the session count is
flawed...
> I just don't believe the results are correct :) I think I read somewhere
> that the session_end is not firing, but someone else will have to tell you
> about it.
>
> function Session_Start(sender:Object, e:EventArgs) {
> Application.Lock();
> curUsers = (int)(Application["howManyUsers"]);
> if (String(curUsers)!="NaN") {
> curUsers++;
> } else {
> curUsers = 2;
> }
> Application["howManyUsers"] = curUsers;
> Application.UnLock();
> }
>
> function Session_End(sender:Object, e:EventArgs) {
> Application.Lock();
> curUsers = (int)(Application["howManyUsers"]);
> if (String(curUsers)!="NaN") {
> curUsers--;
> } else {
> curUsers = -1;
> }
> Application["howManyUsers"] = curUsers;
> Application.UnLock();
> }
> --
> Jure pik
there is a way but you will need to implement an httphandler to count the
sessions or use the session start event. typically, that sort of throttling
is done outside of code, from IIS.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Ollie" <ollie_riches@.hotmail.com> wrote in message
news:u$TiGFnuEHA.3900@.tk2msftngp13.phx.gbl...
> Is there anyway to montior the number of user sessions from an asp.net
> app\page?
> The reason I ask is because I would like to throttle the number of
> concurrent sessions to a website, i.e. limit the number of concurrent user
> sessions lets say to 10,000 and if a user session exceeeds this amount
> they
> would be redirected to a 'Server is to busy' screen.
> I get the feeling there is no way to programmtically do this as I believe
> the number of possible supported session is dependant on hardware and the
> size of the data being stored in a session.
> Cheers in advance
> Ollie
I'm assuming you want to do this dynamically, since you probably know you
can set a fixed maximum # of sessions using IIS manager. If you aren't sure
what max # of sessions you should set it to, you could monitor the server
during load (or simulate the load) & make a note of traffic vs CPU or
whatever you're concerned about. You should not have a goal of running the
server up to 99% CPU, though -- shoot for 85%.

For dynamic, programmatic control, as Alvin said you're probably better off
(IMO) having a job outside of IIS monitoring the number of connections via
WMI or something, then setting the max user sessions in the metabase based
on some criteria.

--
Ben Strackany
www.developmentnow.com

<a href="http://links.10026.com/?link=http://www.developmentnow.com">dn</a
"Ollie" <ollie_riches@.hotmail.com> wrote in message
news:u$TiGFnuEHA.3900@.tk2msftngp13.phx.gbl...
> Is there anyway to montior the number of user sessions from an asp.net
> app\page?
> The reason I ask is because I would like to throttle the number of
> concurrent sessions to a website, i.e. limit the number of concurrent user
> sessions lets say to 10,000 and if a user session exceeeds this amount
they
> would be redirected to a 'Server is to busy' screen.
> I get the feeling there is no way to programmtically do this as I believe
> the number of possible supported session is dependant on hardware and the
> size of the data being stored in a session.
> Cheers in advance
> Ollie

0 comments:

Post a Comment