I have a VPS running CentOS 6.5, Apache 2.2, PHP-FPM v5.4 and MySQL 5.5. I take advantage of APC and Memcache. The VPS has 8 cores and 8GB RAM. I'm running a medium volume site (15,000 users / day, peak 1,200 per hour). The VPS also hosts a number of other sites, but they're lower volume. To be clear, there are no performance issues on the sites. Each have been well optimized and load within 1.5s, even during peak traffic.
While performance is good, I'm worried that Apache isn't optimized. I ran Apache Benchmark as follows:
ab -n 1000 -c 100 https://www.example.com/somepage.html
Somepage.html weighs in at only 116 bytes, but this benchmark returned only 183 requests per second. The medium volume site runs on Joomla 3.3 and benchmarks at an embarrassing 3 requests per second. Surely this server can do better. I also realize that Joomla may not be an optimal platform, but I should still be able to get 30-50 requests per second. I can do about 35 on a prefork, mod_php setup.
I've really only experience with mod_php and the Prefork MPM. I recently provisioned this new server and read about the benefits of Worker MPM and PHP-FPM, so I figured I'd try it out.
Here are my configurations
Worker MPM
<IfModule worker.c>
StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
PHP-FPM
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 10000
Running the following two commands, I can see the average private memory usage of each Apache and PHP process are 330kb and 29kb respectively
ps -ef | grep httpd | grep -v ^root | awk '{ print $2 '} | xargs pmap -d | grep ^mapped: | awk '{ print $4 }' | cut -dK -f1 | awk '{ SUM += $1} END { print SUM/NR }'
ps -ef | grep php-fpm | grep -v ^root | awk '{ print $2 '} | xargs pmap -d | grep ^mapped: | awk '{ print $4 }' | cut -dK -f1 | awk '{ SUM += $1} END { print SUM/NR }'
I'm a little unsure how to report system memory usage. HTOP reports 1650 / 7839 whereas free -m reports 7374 / 7839 used; however, 5115 is cached which I think may be due to memcache.
Where do I go from here? If I need to post more configurations, I'm happy to do so.
Thanks for your help!