Hostdog - prefork https://www.hostdog.eu/tags/prefork en Optimize Apache on cPanel - apache benchmark https://www.hostdog.eu/blog/optimize-apache-cpanel-apache-benchmark <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>Requirements: If you don't have Prefork installed, then please install it via Easy Apache on your WHM. You will have to recompile Apache.</p> <p>Run apache benchmark on terminal:<br /><code> ab -n 500 -c 50 http://www.yourdomain.gr/el</code></p> <p>It's best to select your heavier webpage.<br /> You'll get something like the following screen:</p> <div class="codeblock"><code>Document Path: /el&lt;br /&gt;<br />  Document Length: 0 bytes&lt;br /&gt;&lt;br /&gt;<br />Concurrency Level: 50&lt;br&gt;<br />  Time taken for tests: 28.558 seconds&lt;br&gt;<br />  Complete requests: 500&lt;br&gt;<br />  Failed requests: 0&lt;br&gt;<br />  Write errors: 0&lt;br&gt;<br />  Non-2xx responses: 500&lt;br&gt;<br />  Total transferred: 243000 bytes&lt;br&gt;<br />  HTML transferred: 0 bytes&lt;br&gt;<br />  Requests per second: 17.51 [#/sec] (mean)&lt;br&gt;<br />  Time per request: 2855.831 [ms] (mean)&lt;br&gt;<br />  Time per request: 57.117 [ms] (mean, across all concurrent requests)&lt;br&gt;<br />  Transfer rate: 8.31 [Kbytes/sec] received&lt;br /&gt;&lt;br /&gt;<br />Connection Times (ms)&lt;br&gt;<br />  min mean[+/-sd] median max&lt;br&gt;<br />  Connect: 0 0 0.5 0 3&lt;br&gt;<br />  Processing: 337 2829 916.6 2779 6550&lt;br&gt;<br />  Waiting: 337 2828 916.6 2777 6550&lt;br&gt;<br />  Total: 338 2829 916.5 2779 6550&lt;br /&gt;&lt;br /&gt;<br />Percentage of the requests served within a certain time (ms)&lt;br&gt;<br />  50% 2779&lt;br&gt;<br />  66% 2917&lt;br&gt;<br />  75% 3018&lt;br&gt;<br />  80% 3111&lt;br&gt;<br />  90% 4094&lt;br&gt;<br />  95% 4836&lt;br&gt;<br />  98% 5162&lt;br&gt;<br />  99% 5453&lt;br&gt;<br />  100% 6550 (longest request)</code></div> <p>In order to check the amound of memory its apache request requires, run the following via terminal: <code>ps aux | grep apache</code></p> <p>Devide the half of the memory of your server with the average memory that its apache request requires.<br /> For example a server that has 2GB of RAM and a average request is 20MB, then 100 is the result.<br /><br /> Edit /usr/local/apache/conf/httpd.conf<br /> For example: <code>nano /usr/local/apache/conf/httpd.conf</code></p> <p>Set:</p> <div class="codeblock"><code>&amp;lt;IfModule prefork.c&amp;gt;&lt;br&gt;<br />  StartServers 20&lt;br&gt;<br />  MinSpareServers 15&lt;br&gt;<br />  MaxSpareServers 20&lt;br&gt;<br />  MaxClients 100&lt;br&gt;<br />  MaxRequestsPerChild 5000&lt;br&gt;<br />&amp;lt;/IfModule&amp;gt;</code></div> <p>Explanation:<br /> Initially start 20 httpd processes. (StartServers)<br /> Keep min 15 processes idle to wait for request. (MinSpareServers)<br /> No more than 20 idle processes. (MaxSpareServers)<br /> Never have more than 100 processes (the result we got above from the division). (MaxClients)<br /> When a process exceeds 5000, kill it. (MaxRequestsPerChild)</p> <p>Also set:</p> <div class="codeblock"><code>KeepAlive On&lt;br&gt;<br />  MaxKeepAliveRequests 100&lt;br&gt;<br />KeepAliveTimeout 12</code></div> <p>Set MaxKeepAliveRequests accordingly to your webpages elements<br /> Set KeepAliveTimeout to the double of you longest request (6550 for this demo).</p> <p>Restart apache (via cPanel).</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0"><a href="https://www.hostdog.eu/tags/apache-optimize">apache optimize</a></li><li class="taxonomy-term-reference-1"><a href="https://www.hostdog.eu/tags/cpanel">cpanel</a></li><li class="taxonomy-term-reference-2"><a href="https://www.hostdog.eu/tags/apache-benchmark">apache benchmark</a></li><li class="taxonomy-term-reference-3"><a href="https://www.hostdog.eu/tags/prefork">prefork</a></li><li class="taxonomy-term-reference-4"><a href="https://www.hostdog.eu/tags/keepalive">keepAlive</a></li></ul></div> Wed, 28 Mar 2012 20:04:51 +0000 hostdog 72 at https://www.hostdog.eu