maximum number of sessions....

O

Ollie

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
 
C

Carpe Diem

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();
}
 
O

Ollie

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
 
A

Alvin Bruney [MVP]

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.
 
B

Ben Strackany

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top