Comparing Apache mod_php, fcgid, proxy_fcgi + php-fpm with different MPMs for a WordPress blog.

WordPress platform is very popular for personal sites and blogs. In this article I will stress-test my own site in order find best performance CGI and MPM.

All test was performed on low-end droplet from DigitalOcean:
1 CPU, 512 MB RAM, 20 GB SSD

Apache 2.4.10, PHP 5.6.20, MySQL 14.14 Distrib 5.5.49 was installed.
Opcache was enabled and tuned.
MySQL was tuned too. Used engine – InnoDB.
Apache mod_disk_cache is enabled, which is must-have for sites like mine.

Tests was performed by JMeter, installed on the same droplet in the same data center. Number of threads was gradually increased until the maximum stable values. All site pages was involved.
Apache was tested with classical mod_php and prefork MPM only(mod_php is not multithread-ready). fcgid and proxy_fcgi + php-fpm was tested with all of MPMs(prefork, worker, event). libapache2-mod-fastcgi was not tested, because of caching issues.

As a control test, Nginx was tested too with php-fpm and enabled fastcgi_cache.

Results:

HTTPDPHPMPMQueries per second
Apachemod_phpprefork2610
Apachefcgidprefork2400
Apachefcgidworker2460
Apachefcgidevent2520
Apacheproxy_fcgi + php-fpmprefork2670
Apacheproxy_fcgi + php-fpmworker2700
Apacheproxy_fcgi + php-fpmevent2850
Nginxphp-fpm 2600

Comments:
1) All queries was cached(100% HIT).
2) As JMeter was in the same data center, bandwidth was huge. This is not how real world client apps works – just keep it in mind.
3) In spite of the fact that Apache showed the best throughput, about 2% of requests was closed with an error 403 Forbidden.
4) Despite the average throughput in the tests, Nginx proved to be the best – no errors, and the request processing time did not exceed 10 seconds.

Conclusion:
1) If you are tied to Apache for some reason, the proxy_fcgi + php-fpm + MPM will provide maximum performance on a similar site.
2) If you are not tied to a specific HTTPD, use Ngnix. In addition to stability, it has advantages over Apache in terms of processing requests from the real world.

1 thought on “Comparing Apache mod_php, fcgid, proxy_fcgi + php-fpm with different MPMs for a WordPress blog.”

Leave a Reply to gipssdh Cancel Reply

Your email address will not be published. Required fields are marked *