tl;dr: If you want to improve Apache's performance, just add more CPU cores and more RAM.
While learning Ansible, I learned that Apache now is using
mpm_event instead of
mpm_prefork. I read that
mpm_event is faster, more modern, and handles concurrency better.
I decided to spin up a test machine and stress test it. Turns out that
mpm_event is faster, but not by much. It’s possible that
mpm_event would be much faster than with more complex, sustained loads… but for the most part, it seems that adding CPU and RAM is the single best way to improve Apache’s performance.
ab -c 25 -n 5000 -r http://x/
These charts show data for:
- mpm_prefork + mod_php (1 CPU / 1 GB RAM)
- mpm_event + php-fpm (1 CPU / 1 GB RAM)
- mpm_prefork + mod_php (4 CPU / 4 GB RAM)
- mpm_event + php-fpm (4 CPU / 4 GB RAM)
Time it took for reach request, in milliseconds. Lower numbers are better.
Number of requests per second the server could handle. Higher numbers are better.
Throughput of data served. Higher numbers are better.
mpm_eventresponds 10% faster than
mpm_preforkwhile serving a basic WordPress site.
- Increasing the server’s CPU and RAM allocation to 4 CPU cores / 4 GB RAM serves data 325% faster than the same server with 1 CPU core / 1 GB RAM.