{"id":771,"date":"2015-11-02T17:49:43","date_gmt":"2015-11-02T16:49:43","guid":{"rendered":"http:\/\/ndk.sytes.net\/wordpress\/?p=771"},"modified":"2015-11-02T17:49:43","modified_gmt":"2015-11-02T16:49:43","slug":"setting-apache2-2-prefork-settings-correctly","status":"publish","type":"post","link":"https:\/\/ndk.sytes.net\/wordpress\/?p=771","title":{"rendered":"Setting Apache2.2 prefork settings correctly"},"content":{"rendered":"<p>\n\tApache&#39;s memory consumption is regulated by the spawned server processes and can easily consume all of your servers memory. If the prefork-module is used following paramters needs to be configured in your httpd.conf:\n<\/p>\n<p>\n\t<code>StartServers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 18<br \/>\n\tMinSpareServers &nbsp; &nbsp; &nbsp; 3<br \/>\n\tMaxSpareServers &nbsp; &nbsp; &nbsp; 6<br \/>\n\tServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 60<br \/>\n\tMaxClients&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 60<br \/>\n\tMaxRequestsPerChild &nbsp; 4000 <\/code>\n<\/p>\n<p>\n\tNow to get this parameters right use the following script to determine the actual memory consumption of one apache child process:\n<\/p>\n<p>\n\t<code>\u200bpgrep httpd | xargs -n1 -I{} cat \/proc\/{}\/smaps | awk &#39;{if ($0 ~ \/stack\/) {pids+=1} else if ($0 ~\/^Shared_\/) {shared+=$2} else if ($0 ~ \/^Pss:\/) {priv+=$2}} END {printf &quot;%.2f MB\\n&quot;,(priv+shared\/(pids*pids))\/1024}&#39;<\/code>\n<\/p>\n<p>\n\tNow to get MaxClients simply take the amount you want to give to apache and divide it with the consumption of one process, depending on the actual load the results may vary. Typically one process took between 30MB and 50MB.&nbsp;The above mentioned configuration is set for 3GB RAM (3*1024MB). Here a thumbrule:\n<\/p>\n<p>\n\t<code>StartServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 30% of MaxClients<br \/>\n\tMinSpareServers &nbsp; &nbsp; &nbsp; = 5% of MaxClients<br \/>\n\tMaxSpareServers &nbsp; &nbsp; &nbsp; = 10% of MaxClients<br \/>\n\tServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = MaxClients<br \/>\n\tMaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= total memory \/ one process memory (round down to be safe)<br \/>\n\tMaxRequestsPerChild &nbsp; 4000<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache&#39;s memory consumption is regulated by the spawned server processes and can easily consume all of your servers memory. If the prefork-module is used following paramters needs to be configured in your httpd.conf: StartServers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 18 MinSpareServers &nbsp; &nbsp; &nbsp; 3 MaxSpareServers &nbsp; &nbsp; &nbsp; 6 ServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7],"tags":[],"class_list":["post-771","post","type-post","status-publish","format-standard","hentry","category-linuxunix","category-servers"],"_links":{"self":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=771"}],"version-history":[{"count":0,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/771\/revisions"}],"wp:attachment":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}