{"id":2554,"date":"2015-03-06T09:52:26","date_gmt":"2015-03-06T08:52:26","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/wehr\/?p=2554"},"modified":"2015-03-06T11:02:31","modified_gmt":"2015-03-06T10:02:31","slug":"tune-apache-mpm-prefork-with-some-webminstats","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/wehr\/2015\/03\/06\/tune-apache-mpm-prefork-with-some-webminstats\/","title":{"rendered":"Tune Apache-MPM prefork with some Webminstats"},"content":{"rendered":"<p id=\"top\" \/>A couple of days ago I started to do some optimizations on our server backends. Most of them are Apache-Prefork PHP powered.<\/p>\n<p>One part of doing Apache-Tuning is to play around with the MPM configuration:<\/p>\n<pre class=\"brush: apache; title: ; notranslate\" title=\"\">\r\n&lt;ifmodule prefork.c&gt;\r\n  StartServers       4\r\n  MinSpareServers    3\r\n  MaxSpareServers   10\r\n  ServerLimit      256\r\n  MaxClients       256\r\n  MaxRequestsPerChild  10000\r\n&lt;\/ifmodule&gt;\r\n<\/pre>\n<p>The particular configuration setting for Apache can be found in the file <code>\/etc\/apache\/httpd.conf<\/code><\/p>\n<p>I&#8217;m using Webmin-&gt;Sysstats to get some basic data where I can start from.<\/p>\n<p>First I wanted to know the <em>average<\/em> and <em>total<\/em> memory usage of the apache worker process(es).<\/p>\n<figure id=\"attachment_2588\" aria-describedby=\"caption-attachment-2588\" style=\"width: 571px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheMemStat.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"  wp-image-2588 \" src=\"http:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheMemStat.png\" alt=\"ApacheMemStat\" width=\"571\" height=\"349\" srcset=\"https:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheMemStat.png 597w, https:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheMemStat-300x183.png 300w\" sizes=\"(max-width: 571px) 100vw, 571px\" \/><\/a><figcaption id=\"caption-attachment-2588\" class=\"wp-caption-text\">Apache memory consumption (total, per worker)<\/figcaption><\/figure>\n<p style=\"text-align: left;\">As you can see after a few days you get a clew about how our worker memory consumption behaves.<\/p>\n<p style=\"text-align: left;\">Especially the per worker chart is import which gives you a hint for the MaxClients and ServerLimit settings.<\/p>\n<p style=\"text-align: left;\">The used bash script :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n-getApachePerWorkerMem)\r\n   ps -ylC apache2 | awk '{x += $8;y += 1} END {print x\/((y-1)*1024)}';;\r\n-getApacheTotalMemPercent)\r\n   sys_mem=`free -m | awk 'NR==2{print $2 }'`\r\n   apache_total_mem=`ps -ylC apache2 | awk '{x += $8;y += 1} END {print x\/1024;}'`\r\n   echo &quot;scale=2;$apache_total_mem\/($sys_mem\/100)&quot; | bc;;\r\n<\/pre>\n<p>Another important part\u00a0is the relation of <em>idle<\/em> and <em>busy <\/em>workers.<\/p>\n<figure id=\"attachment_2597\" aria-describedby=\"caption-attachment-2597\" style=\"width: 569px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheWorkerStats.png\"><img decoding=\"async\" class=\" wp-image-2597\" src=\"http:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheWorkerStats.png\" alt=\"Apache amount and relation of busy\/idle workers\" width=\"569\" height=\"348\" srcset=\"https:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheWorkerStats.png 597w, https:\/\/blog.fh-kaernten.at\/wehr\/files\/2015\/03\/ApacheWorkerStats-300x183.png 300w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/a><figcaption id=\"caption-attachment-2597\" class=\"wp-caption-text\">Apache amount and relation of busy\/idle workers<\/figcaption><\/figure>\n<p>Here we see that in this particular case we have an average ratio 10\/2 (<em>idle<\/em>\/<em>busy<\/em>) and our max is about (11\/7) which gives\u00a0a balanced amount of <em>idle<\/em> and busy <em>workers.<\/em><\/p>\n<p>The used bash script :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n-getApacheBusyWorker)\r\n  echo `wget -q -O - &quot;$URL&quot; --user=&quot;$USER&quot; --password=$PASS |grep BusyWorker |cut -d&quot; &quot; -f2`;;\r\n-getApacheIdleWorker)\r\n  echo `wget -q -O - &quot;$URL&quot; --user=&quot;$USER&quot; --password=$PASS |grep IdleWorker |cut -d&quot; &quot; -f2`;;\r\n<\/pre>\n<p>have fun<\/p>\n<p>Mario<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of days ago I started to do some optimizations on our server backends. Most of them are Apache-Prefork PHP powered. One part of doing Apache-Tuning is to play around with the MPM configuration: &lt;ifmodule prefork.c&gt; StartServers 4 MinSpareServers 3 MaxSpareServers 10 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 10000 &lt;\/ifmodule&gt; The particular configuration setting for &hellip; <a href=\"https:\/\/blog.fh-kaernten.at\/wehr\/2015\/03\/06\/tune-apache-mpm-prefork-with-some-webminstats\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tune Apache-MPM prefork with some Webminstats<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2554","post","type-post","status-publish","format-standard","hentry","category-linux-stuff"],"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/2554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/comments?post=2554"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/2554\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/media?parent=2554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/categories?post=2554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/tags?post=2554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}