0

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?

mj23
  • 1
  • 2

1 Answers1

1

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:

StartServers            1
ServerLimit             5
MinSpareThreads         100
MaxSpareThreads         600
ThreadsPerChild         200
ThreadLimit             200
MaxRequestWorkers       10000
MaxConnectionsPerChild  10000000

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

ezra-s
  • 2,215
  • 1
  • 7
  • 13