Maximum Number of Clients (APACHE)

Maximum Number of Clients (APACHE)

Post by Daniel Anderss » Thu, 15 Apr 1999 04:00:00



Hi,

We are running Apache and are now looking for an way to get Apache to tell
the users (the ones thats surfs to us) that our server is busy and dosent
allow any more connection. With the Maximum Number of Clients the server
just stops answering request when it hits the maximum, we would want it to
display an html page when reaching say 98-99% of the maximum and then tell
the user "Sorry its full, try later". Is there any way to do this with
Apache or some other webserver for Linux??

If there is anyone out there with an answer i would aprosiate to get an
email from you! Thanks in advance!

--

 
 
 

Maximum Number of Clients (APACHE)

Post by Ron Klatchk » Thu, 15 Apr 1999 04:00:00



> We are running Apache and are now looking for an way to get Apache to tell
> the users (the ones thats surfs to us) that our server is busy and dosent
> allow any more connection. With the Maximum Number of Clients the server
> just stops answering request when it hits the maximum, we would want it to
> display an html page when reaching say 98-99% of the maximum and then tell
> the user "Sorry its full, try later". Is there any way to do this with
> Apache or some other webserver for Linux??

Unfortunately, this is not possible; the way Apache integrates with the
TCP/IP stack precludes this.  Apache would not be able to issue such a
message until it is actually ready to service it, by that time it's
ready to service the request so it makes no sense to refuse it at that
point.

moo
----------------------------------------------------------------------
          Ron Klatchko - Manager, Advanced Technology Group          
           UCSF Library and Center for Knowledge Management          


 
 
 

Maximum Number of Clients (APACHE)

Post by Marc Slemk » Thu, 15 Apr 1999 04:00:00




>> We are running Apache and are now looking for an way to get Apache to tell
>> the users (the ones thats surfs to us) that our server is busy and dosent
>> allow any more connection. With the Maximum Number of Clients the server
>> just stops answering request when it hits the maximum, we would want it to
>> display an html page when reaching say 98-99% of the maximum and then tell
>> the user "Sorry its full, try later". Is there any way to do this with
>> Apache or some other webserver for Linux??
>Unfortunately, this is not possible; the way Apache integrates with the
>TCP/IP stack precludes this.  Apache would not be able to issue such a
>message until it is actually ready to service it, by that time it's
>ready to service the request so it makes no sense to refuse it at that
>point.

Not entirely true.  It is possible.  An Apache child could count the number
of children currently in use, and if it is the "last" one then it could
return a "too busy" error.  This is "helpful" in the sense that although
returning a "too busy" error may or may not be cheaper than returning
the real document, it does cut down on the number of future requests
made because there are no links or images, etc. on that page.  It isn't
about using less resources for the one current hit, but rather about
reducing the number of connections that happen in the future.  It isn't
necessarily a great solution, but you have to weigh the tradeoffs
here.

Now, just because it could do it doesn't mean it does.  Implementation
is left as an exercise for the reader.

 
 
 

Maximum Number of Clients (APACHE)

Post by Ron Klatchk » Thu, 15 Apr 1999 04:00:00



> Not entirely true.  It is possible.  An Apache child could count the number
> of children currently in use, and if it is the "last" one then it could
> return a "too busy" error.

Wouldn't those semantics be awfully restrictive?  Imagine the situation
where you have five children and five requests show up simultaneously
(for the point of this discussion, I'll define that to mean the last
request has made a valid TCP connection prior to the first one being
finished).  According to the semantics you suggest, the last request
will return the "too busy" error even though the server is hardly
overloaded.

In my mind, the only way to make sense of this request is to assume that
busy means there's a delay between the TCP connection being established
and a child accept()ing the connection.  Unless I've missed something in
the socket interface, there's no way to detect this.  Furthermore, I
assume the original question was how to send back a "too busy" message
as soon as the connection was established if the listen queue was
backlogged, which is not possible.

Marc, I highly respect your opinion and knowledge, but although your
solution would work, I don't think it would be useful in most, if not
all, real world situations.

moo
----------------------------------------------------------------------
          Ron Klatchko - Manager, Advanced Technology Group          
           UCSF Library and Center for Knowledge Management          

 
 
 

Maximum Number of Clients (APACHE)

Post by Marc Slemk » Fri, 16 Apr 1999 04:00:00




>> Not entirely true.  It is possible.  An Apache child could count the number
>> of children currently in use, and if it is the "last" one then it could
>> return a "too busy" error.
>Wouldn't those semantics be awfully restrictive?  Imagine the situation

Yes.  Restrictive can still be useful.

Quote:>where you have five children and five requests show up simultaneously

Presumably, the biggest use of this would be on servers with a large
number of connections.  If you have a choice between having your
server hopelessly backlogging and between refusing some requests,
which do you think is better?  Whichever it is, if you want to emulate
the IIS behaviour of only allowing x connections  before giving a
"too busy" error, that can be done.

You also have to have a big enough number of child processes around
to make such anomolies statistically insignificant.

So if you have a MaxClients of 5 and have wild swings in traffic
(eg. a burst of 10 or 20 hits every 10 minutes), then this won't
work too well for you.

Quote:>In my mind, the only way to make sense of this request is to assume that
>busy means there's a delay between the TCP connection being established
>and a child accept()ing the connection.  Unless I've missed something in
>the socket interface, there's no way to detect this.  Furthermore, I

Right, but there is a metric you can use to guess at this.  If your
server has no free child processes, then if you are in a steady
state over some period of time, either it is exactly at the point
of just barely being able to handle the requests or it is not able
to keep up.  If it isn't able to keep up, even if it is only by a tiny
bit, the queueing delay will very quickly spiral out of control no matter
how little that bit is.  

So if you ignore the "exactly what we can handle case", which is a
boundry case that doesn't really matter too much, and assume that you
have a steady state over a period of a few minutes (ie. one client making
5 requests at once isn't statistically significant, which really is
a valid experience on large sites) then not having a free child (ie.
current children == maxclients and they are all b usy) is a useful
metric to estimate if the queuing delay in your accept queue is large or
not.

Quote:>assume the original question was how to send back a "too busy" message
>as soon as the connection was established if the listen queue was
>backlogged, which is not possible.

Except that by sending a small document that requires little processing
to send, that child will free itself quite quickly for accepting the next
connection, keeping the queue reasonably small.

Now, I'm not saying that the behaviour resulting from this (ie. seeing
"too busy" messages all over, half your images failing, etc.) is good
but that is another issue.

 
 
 

Maximum Number of Clients (APACHE)

Post by Alex Brow » Sat, 17 Apr 1999 04:00:00



> Hi,

> We are running Apache and are now looking for an way to get Apache to tell
> the users (the ones thats surfs to us) that our server is busy and dosent
> allow any more connection. With the Maximum Number of Clients the server
> just stops answering request when it hits the maximum, we would want it to
> display an html page when reaching say 98-99% of the maximum and then tell
> the user "Sorry its full, try later".

so, when the load is full, you want to put another call on your server to post
a page saying it's full.  Hmmmm, interesting logic.

Anyone else see a rather amusing loop appearing here?

A.

--
Alex Brown
Webmaster, Cable Internet

"Why should I care about posterity? What's posterity ever done for me?"
-- Groucho Marx

 
 
 

Maximum Number of Clients (APACHE)

Post by Alan J. Flavel » Sat, 17 Apr 1999 04:00:00



> so, when the load is full, you want to put another call on your server
> to post a page saying it's full.  Hmmmm, interesting logic.

That's a rather superficial analysis.

I can certainly see some justification for the argument that when the
server is getting heavily loaded, it's preferable to return a plain text
page that says so, rather than returning a real-content page that's
going to have the client promptly requesting an external stylesheet,
umpty in-line images and who knows what else.

Status code 503 seems to be appropriate for this.  I'm not saying it's
the only choice (neither does rfc2068 say it), all I'm saying is that
it seems to be a choice that has a justifiable argument behind it.

ttfn

 
 
 

Maximum Number of Clients (APACHE)

Post by Nick K » Sat, 17 Apr 1999 04:00:00





>> so, when the load is full, you want to put another call on your server
>> to post a page saying it's full.  Hmmmm, interesting logic.

> That's a rather superficial analysis.

Now that you mention it, there's another very relevant scenario.  If you
are doing some heavyweight processing on the server, then you may want
to ration its use whilst continuing to offer normal webpages, etc.
I've set up servers doing substantial image-processing jobs using simple
old resource-locking to implement a quota.  Users locked out will get a
"server busy" webpage, with a client-pull (Refresh) to try again if they
care to wait around.

That was using the CERN server with CGI, in pre-Apache times.  'Twould be
interesting if such quotas could indeed be enforced by the webserver:
OTTOMH something like

<Directory /my/heavy/duty/stuff/>
Limit-Concurrent-Users: 3
Resource-Server: some-server.foo.com:12345
</Directory>

I might even write such a module, as I have a need for this function
once again right now.

--
Nick Kew

 
 
 

Maximum Number of Clients (APACHE)

Post by Marc Slemk » Sat, 17 Apr 1999 04:00:00



Quote:><Directory /my/heavy/duty/stuff/>
>Limit-Concurrent-Users: 3
>Resource-Server: some-server.foo.com:12345
></Directory>
>I might even write such a module, as I have a need for this function
>once again right now.

There are ways to do such things with current Apache modules (and I
think I may actually be doing it on some site...) but all the
modules I have seen to do it suck, unfortunately.
 
 
 

1. Maximum number of TCP connections on a single client?

I'm getting an ENOSPC error when more than about 20 clients try to make
concurrent TCP connections to a server process.  This return value
isn't documented for the t_open call, but I assume I'm hitting some
limit on the number of connections.  Is this a limit that can be
increased on SCO 3.2v4.1?
--
John W. Temples, III       ||       Providing the only public access Internet
Gulfnet Kuwait             ||            site in the Arabian Gulf region

2. patchrm 105803-07

3. Xlib: Maximum number of clients reached

4. How to set up passwords (Linux & Irix)?

5. BOOKS/PAPERS ON UNIX SECURITY???

6. Linux DHCP & NT Client

7. Xlib: maximum number of clients == 34?

8. Xlib: Maximum number of clients reached

9. Maximum Number of Client Connections

10. Maximum number of clients per exported directory

11. Help Xlib: Maximum number of clients reached