Skip to main content

apache 2.2 - Tuning Apache2 prefork MaxClients ServerLimit



I have a machine with 128 GB Ram that is using Apache2 as Webserver (in this machine there is no Database Server, the Database Machine is a 64 GB Ram machine that can handle 2000 max connections). I see with a monitoring tool that there are at the moment about 44 busy workers and 12 idle workers, what are best theoretical values for my prefork module?



i got blank pages sometimes loading websites on high load hours and got this error on my apache error log:



[notice] child pid 13595 exit signal Segmentation fault (11)



how can solve this issue too?




My Apache2 Prefork Module configuration:



StartServers          3
MinSpareServers 3
MaxSpareServers 5
ServerLimit 3200
MaxClients 3100
MaxRequestsPerChild 0



Free -h on the www Machine :



total: 128 G free: 97GB (with apache2 running) shared 0b buffers 1.9G cache 23G



Ram used By Apache2 and other Programs:



Private  +   Shared  =  RAM used    Program

96.0 KiB + 61.0 KiB = 157.0 KiB sh

176.0 KiB + 26.0 KiB = 202.0 KiB atd
176.0 KiB + 35.5 KiB = 211.5 KiB acpid
208.0 KiB + 19.5 KiB = 227.5 KiB mdadm
204.0 KiB + 30.0 KiB = 234.0 KiB init
248.0 KiB + 62.0 KiB = 310.0 KiB sendmail
376.0 KiB + 36.0 KiB = 412.0 KiB dbus-daemon
388.0 KiB + 285.5 KiB = 673.5 KiB cron (2)
820.0 KiB + 42.0 KiB = 862.0 KiB gam_server
920.0 KiB + 108.0 KiB = 1.0 MiB ntpd
968.0 KiB + 243.0 KiB = 1.2 MiB getty (6)

1.3 MiB + 351.5 KiB = 1.6 MiB udevd (3)
1.5 MiB + 343.0 KiB = 1.8 MiB sendmail-msp
2.0 MiB + 910.0 KiB = 2.9 MiB plugin-localresources2
3.4 MiB + 50.0 KiB = 3.4 MiB rsyslogd
3.6 MiB + 68.5 KiB = 3.7 MiB bash
1.9 MiB + 2.1 MiB = 4.0 MiB sendmail-mta (4)
3.8 MiB + 556.0 KiB = 4.3 MiB sshd (2)
3.7 MiB + 1.2 MiB = 4.8 MiB plugin-apache2
5.1 MiB + 1.2 MiB = 6.3 MiB agent-service
7.0 MiB + 654.0 KiB = 7.6 MiB fail2ban-server

9.6 MiB + 2.6 MiB = 12.2 MiB proftpd (8)
59.2 MiB + 70.0 KiB = 59.3 MiB miniserv.pl
96.8 MiB + 3.6 MiB = 100.4 MiB php5-cgi (2)
196.4 MiB + 35.9 MiB = 232.3 MiB apache2 (40)
---------------------------------
tot 450.0 MiB

Answer



Apache prefork settings, per apache performance tuning guidelines




quote:



The single biggest hardware issue affecting webserver performance is RAM.
A webserver should never ever have to swap, as swapping increases the latency
of each request beyond a point that users consider "fast enough".
This causes users to hit stop and reload, further increasing the load.
You can, and should, control the MaxClients setting so that your server does
not spawn so many children it starts swapping. This procedure for doing this
is simple: determine the size of your average Apache process, by looking at
your process list via a tool such as top, and divide this into your total

available memory, leaving some room for other processes.


you should set it up like this based on your input to:




  • Total Memory : 128 GB

  • -10% memory for everything except apache: 115 GB

  • Now we need to figure out how much single apache process is using.




To calculate this you can use following script :



pgrep apache2 | xargs -n1 -I{} cat /proc/{}/smaps | \
awk '{if ($0 ~ /stack/) {pids+=1} else if ($0 ~/^Shared_/)
{shared+=$2} else if ($0 ~ /^Pss:/) {priv+=$2}} END {
printf "%.2f MB\n",(priv+shared/(pids*pids))/1024}'


This is best estimate of how much single apache process is using memory while trying to proportionally dividing shared usage per number of active apache processes and adding it on top of Pss (proportional set size)




Finally you divide 115 GB with this figure and you get MaxClients/ServerLimit. From here you can relatively calculate other figures like




  • StartServers 30% of MaxClients

  • MinSpareServers 5% of MaxClients

  • MaxSpareServers 10% of MaxClients

  • ServerLimit == MaxClients

  • MaxConnectionsPerChild 10000 (as conservative alternative to address possible problem with memory leaky apps)



Comments

Popular posts from this blog

iLO 3 Firmware Update (HP Proliant DL380 G7)

The iLO web interface allows me to upload a .bin file ( Obtain the firmware image (.bin) file from the Online ROM Flash Component for HP Integrated Lights-Out. ) The iLO web interface redirects me to a page in the HP support website ( http://www.hp.com/go/iLO ) where I am supposed to find this .bin firmware, but no luck for me. The support website is a mess and very slow, badly categorized and generally unusable. Where can I find this .bin file? The only related link I am able to find asks me about my server operating system (what does this have to do with the iLO?!) and lets me download an .iso with no .bin file And also a related question: what is the latest iLO 3 version? (for Proliant DL380 G7, not sure if the iLO is tied to the server model)

linux - Awstats - outputting stats for merged Access_logs only producing stats for one server's log

I've been attempting this for two weeks and I've accessed countless number of sites on this issue and it seems there is something I'm not getting here and I'm at a lost. I manged to figure out how to merge logs from two servers together. (Taking care to only merge the matching domains together) The logs from the first server span from 15 Dec 2012 to 8 April 2014 The logs from the second server span from 2 Mar 2014 to 9 April 2014 I was able to successfully merge them using the logresolvemerge.pl script simply enermerating each log and > out_putting_it_to_file Looking at the two logs from each server the format seems exactly the same. The problem I'm having is producing the stats page for the logs. The command I've boiled it down to is /usr/share/awstats/tools/awstats_buildstaticpages.pl -configdir=/home/User/Documents/conf/ -config=example.com awstatsprog=/usr/share/awstats/wwwroot/cgi-bin/awstats.pl dir=/home/User/Documents/parced -month=all -year=all...

linux - How can I get my mediawiki to stop thinking I have cookies disabled?

I've searched half a day for how to resolve this issue, and can't figure it out. Shortly after I made my wiki a simple private wiki according to the instructions at Mediawiki's website, it started giving me this weird login error message: Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again. If I remove those private wiki settings, the error disappears, even if I try logging in. But I need it to be a private wiki for only my team. So what do I do? Here's what I've done so far. Just to be safe, after ever change, I try rebooting Apache using: sudo /etc/init.d/apache2 restart In my php.ini file, I have the following set: session.save_path = "/var/lib/php5" session.cookie_secure = secure session.cookie_path = /tmp session.cookie_domain = my server's internal URL (should I even set this? this field was blank before, but not commented out) session.referer_check = Off I ran the following to ensure that the fold...