Now that things are stable, you can possibly adjust your MaxClients setting upwards. First, find out how much memory each Apache process is using with
top.
Code:
top - 23:06:58 up 24 days, 23:23, 1 user, load average: 0.24, 0.53, 0.44
Tasks: 97 total, 2 running, 95 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.8%us, 0.2%sy, 0.0%ni, 97.9%id, 1.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 524512k total, 459528k used, 64984k free, 19512k buffers
Swap: 262136k total, 48k used, 262088k free, 285840k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8597 www-data 15 0 24240 7368 3452 S 1 1.4 0:02.53 apache2
8601 www-data 15 0 24052 7252 3408 S 1 1.4 0:00.90 apache2
8562 www-data 15 0 24936 8184 3512 S 0 1.6 0:05.41 apache2
1434 mysql 23 0 61136 39m 4708 S 0 7.7 268:55.03 mysqld
8574 www-data 15 0 24004 7256 3452 S 0 1.4 0:03.30 apache2
8581 www-data 16 0 24780 7780 3432 S 0 1.5 0:05.31 apache2
8657 www-data 16 0 23972 7124 3364 S 0 1.4 0:00.02 apache2
8655 www-data 15 0 25288 8248 3408 S 0 1.6 0:00.12 apache2
...
The RES value is the physical memory used by the process, and SHR is memory potentially shared with other processes. So RES minus SHR gives you a rough idea of how much memory each additional apache2 process will need (in this case, around to 3800 to 4800 KB or 3.7 to 4.7 MB).
Now you need to determine how much additional memory is available on your system.
Code:
$ ps aux | grep -c '^www-data' ; free -m
11
total used free shared buffers cached
Mem: 512 444 67 0 18 280
-/+ buffers/cache: 145 367
Swap: 255 0 255
The
ps aux | grep -c '^www-data' tells you how many Apache processes are running (on Debian and Ubuntu servers; on CentOS use
ps aux | grep -c '^apache'). In this case, there are 11. As explained by
http://www.linuxatemyram.com/ , the free command shows us we have 367 MB unused. Doing 367 divided by 4.7 tells us we could potentially run 78 more processes, for a total MaxClients setting of 89.
Of course, you probably are running other services (e-mail, database, etc.) on this machine and don't want to fill the memory completely with Apache processes, so leave yourself a cushion. I have MaxClients set to 60 on this example machine and that keeps it from running into swap.
You can check this by running
free -m during a time when your server is getting lots of traffic (either naturally, or you can use a tool like
ab to make it busy) and seeing that you still have some memory left in the "free" column.