Set up Debian Apache web server for 250 users

Hi,

I have a network of 250 users.

They are simultaneously connected to my Linode 1024 machine.

I've some issue with the apache2 processes,

in some cases the processes are tons and so this causes

that the server goes down.

My /etc/apache2/apache2.conf is:

"

StartServers 5

MinSpareServers 5

MaxSpareServers 10

MaxClients 150

MaxRequestsPerChild 0

"

can you help me with this config?

or what I have to config to prevent the server issue?

thanks in advance!

Alberto

16 Replies

Set MaxClients 150 to around 40, that should help, then watch your ram usage, you maybe able to increase it after that depending on how much ram other processes are using and how much ram each apache process uses.

If I set MaxClients to 40

what it causes?

if 50 user request a page simultaneously,

all the user can view that page?

or only 40 can view the page? and 10 can't connect.

From http://httpd.apache.org/docs/2.2/mod/mp … maxclients">http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxclients

> The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.

For non-threaded servers (i.e., prefork), MaxClients translates into the maximum number of child processes that will be launched to serve requests.

So if 50 requests come in at exactly the same time then 10 will be queued, however keep in mind requests are fast, even if you can only serve 10 request per second then a MaxClients of 40 = 400 requests per second.

10 will wait for connect.

Count, how many memory you need for 150 clients.

1 apache process takes around 20M of memory (look your value in 'top'), so 150*20M = 3000M. You have 1024M. And memory not only for apache. Let's take half memory for apache - 512M, each process eats around 20M, so MaxClients = 512M/20M = 25.6, so in this case MaxClients = 25 should be used.

If apache is only user of RAM (no mysql/mongo/redis/memcache), you can set 1024/20=50 MaxClients.

With MaxClients = 150 your server can start use swap and it will looks like server is down.

With mpm-worker it's less than 500KB per connection, people…

@rsk:

With mpm-worker it's less than 500KB per connection, people…

It is acting like mpmprefork and failing like mpmprefork, so I'd be surprised if mpm_worker were being used.

@hoopycat:

@rsk:

With mpm-worker it's less than 500KB per connection, people…

It is acting like mpmprefork and failing like mpmprefork, so I'd be surprised if mpm_worker were being used.

quack

Just reminding ya that a switch of MPM might be a good move… ;)

@rsk:

Just reminding ya that a switch of MPM might be a good move… ;)
If using PHP, FastCGI should be used with mpm-worker:

http://ru2.php.net/manual/en/faq.instal … on.apache2">http://ru2.php.net/manual/en/faq.installation.php#faq.installation.apache2

@OZ:

If using PHP, FastCGI should be used with mpm-worker:
If using FastCGI, it's probably a good idea to ditch Apache altogether and look into nginx+fpm. There are very few cases where you actually need to use mpm-worker with PHP these days, unless you have some insanely complicated rewrite rules in your .htaccess file. Less than 500 freakin' kilobytes per process? Ha, tell that to lighttpd or nginx.

Per thread, not per process.

Lighttpd was annoying to me, to get a "recent enough to make any sense" nginx I'd have to compile it myself.

Apache just works, everything that "ass-umes" apache just works, and while it may not be as "efficient" as other options it still handles average of 50 hits/s with peaks of 250 hits/s (latter's my max clients limit, yeah) with negligible CPU load. shrug

rsk do you mind sharing your mpm-worker config ?

Sure, but it quite sucks. "Works for me good enough", you sure know the deal.

Someone who actually knows what he's doing definitely could make it better. ;)

(or go after the current trend and compile nginx; I prefer supported packages, tyvm.)

Anyway, HERE.

And you run this with mod_php ? How about all that "PHP is not thread safe" thingy ?

No rsk's running it with php under fastcgi

@Amar:

And you run this with mod_php ? How about all that "PHP is not thread safe" thingy ?

No, this is fastcgi, not mod_php

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct