PHP-FPM (FastCGI Process Manager) is the process manager designed to run PHP alongside a web server (Nginx, Apache). PHP-FPM controls PHP processes: how many are spawned, when they're forked and killed, how many requests each handles. Properly tuned, PHP-FPM is essential for high-traffic sites β it efficiently handles thousands of concurrent requests.
Main parameters
pm β process manager mode: static (fixed count, uses more RAM but faster), dynamic (demand-based, balanced β most commonly used), ondemand (created on request, saves RAM but slower). Recommended: dynamic.
pm.max_children β the maximum PHP processes that can run in parallel. The most important parameter β must be set based on available RAM and CPU. Formula: (available RAM - other services) / (average RAM per PHP process). Example: 4GB server, 1GB for MySQL and Nginx, 60MB per PHP process β max_children = 3000 / 60 = 50.
pm.start_servers β number of processes started at startup. Recommended: 20-25% of max_children.
pm.min_spare_servers β the minimum number of idle processes. Spare capacity for new requests to start immediately. Recommended: 10-15% of max_children.
pm.max_spare_servers β the maximum number of idle processes. Extra idle processes get killed (saving RAM). Recommended: 25-30% of max_children.
pm.max_requests β how many requests each process handles before being restarted. Prevents memory leaks. Recommended: 500-1000.
Status page setup
To monitor PHP-FPM, configure a status page: pm.status_path = /fpm-status. Then in nginx: location ~ ^/fpm-status$ { fastcgi_pass php-fpm; allow 127.0.0.1; deny all; }. Visit http://yoursite.uz/fpm-status β process count, active requests, queue.
Slowlog β finding slow requests
request_slowlog_timeout = 5s β if a request runs longer than 5 seconds, it's written to slowlog. slowlog = /var/log/php-fpm-slow.log. This file lets you find the slowest PHP functions and optimize them.
Sayt.uz practice
Sayt.uz tariffs come with PHP-FPM optimized: Basic Hosting max_children = 25, Pro Hosting 50, VPS 100+. During sale seasons (Sunday promotions, Ramadan) we temporarily raise max_children 1.5x. WordPress and e-commerce sites run 30-50% faster with PHP-FPM optimization. Tip: don't set pm.max_children too high β when RAM runs out everything dies (OOM kill).