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

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

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)

hp proliant - Smart Array P822 with HBA Mode?

We get an HP DL360 G8 with an Smart Array P822 controller. On that controller will come a HP StorageWorks D2700 . Does anybody know, that it is possible to run the Smart Array P822 in HBA mode? I found only information about the P410i, who can run HBA. If this is not supported, what you think about the LSI 9207-8e controller? Will this fit good in that setup? The Hardware we get is used but all original from HP. The StorageWorks has 25 x 900 GB SAS 10K disks. Because the disks are not new I would like to use only 22 for raid6, and the rest for spare (I need to see if the disk count is optimal or not for zfs). It would be nice if I'm not stick to SAS in future. As OS I would like to install debian stretch with zfs 0.71 as file system and software raid. I have see that hp has an page for debian to. I would like to use hba mode because it is recommend, that zfs know at most as possible about the disk, and I'm independent from the raid controller. For us zfs have many benefits, ...