0

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!

2
  • 1
    Check your web server logs and PHP logs (there is a separate log when using php-fpm) after running apache bench. You will find useful information there. Nov 15, 2014 at 22:42
  • httpd logs only indicate that the requests were successful (200) and size (116). PHP-FPM logs had nothing, though I did notice that few days ago I reached my max_children setting. Based on this link, I changed the php-fpm settings to max_children = 16, start servers = 8, max_spare_servers = 16 and max_requests = 500. Now I get 25 requests per second in AB and I don't see SSL handshake issues which is good. I still need to modify my apache settings though.
    – Liam
    Nov 16, 2014 at 0:49

0

You must log in to answer this question.