I'm trying to speed up a website with a lot of images that are served from a separate subdomain static.example.com (same IP as www.)
Using the pingdom tool noticed that first 5-6 requests (on static.example.com) are making full connections (DNS+SSL+Send+Wait+Receive+Connect).
Does it have anything to do with prefork configuration?
<IfModule mpm_prefork_module>
StartServers 20
MinSpareServers 20
MaxSpareServers 20
ServerLimit 150
MaxRequestWorkers 150
MaxConnectionsPerChild 10000
MaxRequestsPerChild 500
</IfModule>
This is a 4GB machine with not a lot of traffic.
Avg apache size:
ps aux | grep 'apache2' | awk '{print $6/1024;}' | awk '{avg += ($1 – avg) / NR;} END {print avg " MB";}'
11.2921 MB
MySQL roughly 500MB
KeepAlive On, MaxKeepAliveRequests 100, KeepAliveTimeout 5
No sure how to resolve this. Does it help to switch to the MPM-Event module?
Best Answer
You should switch to event, yes.
With prefork every single connection takes 1 process. CPU wise is most costly to spawn processes than new threads unless you "preload" them on start.
But still to serve static content and those specs you could easily have httpd with event mpm and allow 1000 threads easily with few processes.
An example:
If you are using prefork because you are forced to, like having mod_php module which is not thread safe, consider migrating to mod_proxy_fcgi -> PHP-FPM instead.
php-fpm info on the httpd wiki