{"id":704,"date":"2016-07-13T08:56:19","date_gmt":"2016-07-13T07:56:19","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=704"},"modified":"2016-07-13T08:56:19","modified_gmt":"2016-07-13T07:56:19","slug":"tuning-apache2-high-traffic-spikes","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2016\/07\/13\/tuning-apache2-high-traffic-spikes\/","title":{"rendered":"Tuning Apache2 for high Traffic Spikes"},"content":{"rendered":"<p>So this came up recently where a customer was asking  if we could tune their apache2 for higher traffic. The best way to do this is to benchmark the site to double the traffic expected, this should be a good measure of whether the site is going to hold up..<\/p>\n<pre>\r\n# Use Apachebench to test the local requests\r\nab -n 1000000 -c 1000 http:\/\/localhost:80\/__*index.html\r\n\r\nBenchmarking localhost (be patient)\r\nCompleted 100000 requests\r\nCompleted 200000 requests\r\nCompleted 300000 requests\r\nCompleted 400000 requests\r\nCompleted 500000 requests\r\nCompleted 600000 requests\r\nCompleted 700000 requests\r\nCompleted 800000 requests\r\nCompleted 900000 requests\r\nCompleted 1000000 requests\r\nFinished 1000000 requests\r\n\r\nServer Software:        Apache\/2.2.15\r\nServer Hostname:        localhost\r\nServer Port:            80\r\n\r\nDocument Path:          \/__*index.html\r\nDocument Length:        5758 bytes\r\n\r\nConcurrency Level:      1000\r\nTime taken for tests:   377.636 seconds\r\nComplete requests:      1000000\r\nFailed requests:        115\r\n   (Connect: 0, Receive: 0, Length: 115, Exceptions: 0)\r\nWrite errors:           0\r\nTotal transferred:      6028336810 bytes\r\nHTML transferred:       5757366620 bytes\r\nRequests per second:    2648.05 [#\/sec] (mean)\r\nTime per request:       377.636 [ms] (mean)\r\nTime per request:       0.378 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          15589.21 [Kbytes\/sec] received\r\n\r\nConnection Times (ms)\r\n              min  mean[+\/-sd] median   max\r\nConnect:        0   52  243.0     22   15036\r\nProcessing:     0  282 1898.4     27   81404\r\nWaiting:        0  270 1780.1     24   81400\r\nTotal:          6  334 1923.7     50   82432\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n  50%     50\r\n  66%     57\r\n  75%     63\r\n  80%     67\r\n  90%     84\r\n  95%   1036\r\n  98%   4773\r\n  99%   7991\r\n 100%  82432 (longest request)\r\n\r\n\r\n\r\n# During the benchmark test you may wish to use sar to indicate general load and io\r\nstdbuf -o0 paste <(sar -q 10 100) <(sar 10 100) | awk '{printf \"%8s %2s %7s %7s %7s %8s %9s %8s %8s\\n\", $1,$2,$3,$4,$5,$11,$13,$14,$NF}'\r\n\r\n# Make any relevant adjustments to httpd.conf threads\r\n\r\n# diff \/etc\/httpd\/conf\/httpd.conf \/home\/backup\/etc\/httpd\/conf\/httpd.conf\r\n103,108c103,108\r\n< StartServers       2000\r\n< MinSpareServers    500\r\n< MaxSpareServers   900\r\n< ServerLimit      2990\r\n< MaxClients       2990\r\n< MaxRequestsPerChild  20000\r\n---\r\n> StartServers       8\r\n> MinSpareServers    5\r\n> MaxSpareServers   20\r\n> ServerLimit      256\r\n> MaxClients       256\r\n> MaxRequestsPerChild  4000\r\n-----------------------------------\r\n<\/pre>\n<p>In this case we increased the number of startservers and minspareservers. Thanks to Jacob for this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So this came up recently where a customer was asking if we could tune their apache2 for higher traffic. The best way to do this is to benchmark the site to double the traffic expected, this should be a good &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2016\/07\/13\/tuning-apache2-high-traffic-spikes\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,42,58,7,29],"tags":[],"class_list":["post-704","post","type-post","status-publish","format-standard","hentry","category-apache","category-automation","category-benchmarking","category-management-tools","category-monitoring"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=704"}],"version-history":[{"count":1,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/704\/revisions"}],"predecessor-version":[{"id":705,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/704\/revisions\/705"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}