Nginx + PHP-FPM 4GB Ram optimization

So I have it all running, no errors, but I'm trying to optimise it for a 4gb Rackspace Cloud server.

This is what I have currently:

php-fpm.conf

pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 60
pm.max_requests = 100

nginx.conf

worker_processes 4;
events {
        worker_connections 2000;
        # multi_accept on;
}

php.ini

memory_limit = 16m;

Just doesn't seem to perform as well as my Apache2 setup with the same server when runnning

ab -n 30000 -c 350 http://domain.com/

Solution 1:

You will need to tweak and adjust until you find your sweet spot but "pm.max_requests = 100" seems very low. Something like 500 or 1000 or maybe more, might be better. Fastcgi will have to kill and respawn children after each one serves pm.max_requests.

PHP memory should not directly impact speed and is the same for both test targets or yours but "memory_limit = 16m;" is low. Start at 256M. You have 4GB of RAM so why limit PHP to a measly 16mb max?