I have a fairly low-budget VPS (1GB RAM + 2 CPU's) to run a few (5 - 10) different small websites (both static and dynamic). These websites have (very) low traffic (average of 500 unique visits for all websites).
The problem I have is that apache2 is very slow for HTML files (and dynamic pages) but not for other static content: Static html files are handled at only 16 requests / second,dynamic pages (wordpress) about half of that and other static content (like images and .txt) at 400 requests / second.
I'm running apache2 with mod_php and am looking for an explanation why an html file takes 25 times longer to load than a .txt copy of exactly the same file?
Tests with apachebench (run on the same server):
$ ab -n 1000 -c 30 http://mysite/index.html ... Concurrency Level: 30 Time taken for tests: 58.987 seconds Complete requests: 1000 Failed requests: 962 (Connect: 0, Receive: 0, Length: 962, Exceptions: 0) Write errors: 0 Total transferred: 6619655 bytes HTML transferred: 6337655 bytes Requests per second: 16.95 [#/sec] (mean) Time per request: 1769.599 [ms] (mean) Time per request: 58.987 [ms] (mean, across all concurrent requests) Transfer rate: 109.59 [Kbytes/sec] received ...
$ ab -n 1000 -c 30 http://mysite/index.txt ... Concurrency Level: 30 Time taken for tests: 2.314 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 6564000 bytes HTML transferred: 6284000 bytes Requests per second: 432.19 [#/sec] (mean) Time per request: 69.414 [ms] (mean) Time per request: 2.314 [ms] (mean, across all concurrent requests) Transfer rate: 2770.40 [Kbytes/sec] received ...
Extra: I have tuned the maxClients so that the server is not swapping:
StartServers 5 MinSpareServers 5 MaxSpareServers 10 ServerLimit 20 MaxClients 20 MaxRequestsPerChild 5000 KeepAlive Off HostnameLookups Off
I have also disabled the apache access log and AllowOverride equals None
During stress-testing of the html files, cpu does not spike above 20%
What could cause this behaviour?