When a page takes several seconds to load but static files still arrive quickly, PHP is usually where the time goes. Nginx answers a plain image in milliseconds, while a WordPress page or admin screen hangs. That gap points to slow nginx response times php-fpm trouble, not to Nginx itself. Nginx is waiting for PHP-FPM to finish work, and PHP-FPM is either busy, short of workers, or stuck on a slow database query.
This guide works through the fix in the order that wastes the least time. First measure where the delay sits, then read the PHP-FPM status page and slow log, then adjust the pool settings, OPcache, and the code behind the request. Each step shows how to tell whether it helped.
Diagnosing Slow Nginx Response Times PHP-FPM Causes
Start by separating Nginx time from PHP time. Run a timed request against a static file and a PHP page from the server itself, so your home connection does not muddy the result:
curl -o /dev/null -s -w "static: %{time_total}sn" https://example.com/test.txt
curl -o /dev/null -s -w "php: %{time_total}sn" https://example.com/
If the static file is fast and the PHP page is slow, the bottleneck sits behind Nginx. If both are slow, check CPU, memory, and disk first with htop, free -h, and df -h. A server with no free RAM will swap, and swapping makes every PHP request crawl. No PHP setting fixes that.
Next, check the Nginx error log for the exact symptom. An upstream timed out message means PHP-FPM did not answer in time, which is a classic nginx php-fpm timeout. A connect() to unix:/run/php/php8.3-fpm.sock failed message means the pool is down or the socket path in your Nginx config does not match the pool config. Read the last 50 lines and check the service state:
sudo tail -n 50 /var/log/nginx/error.log
sudo systemctl status php8.3-fpm --no-pager
Adjust the PHP version to match your install. If PHP-FPM is not running, restart it and check /var/log/php8.3-fpm.log for why it stopped.
Read the PHP-FPM Status Page and Slow Log First
Before you touch a setting, turn on the status page and the slow log. They show what is actually happening inside the pool, which beats every rule of thumb. In your pool config, usually /etc/php/8.3/fpm/pool.d/www.conf, add or uncomment:
pm.status_path = /status
request_slowlog_timeout = 5s
slowlog = /var/log/php8.3-fpm-slow.log
Expose /status only to localhost in your Nginx server block, reload PHP-FPM, and fetch it with curl http://127.0.0.1/status. Three numbers matter. active processes shows how many workers are busy now. max active processes shows the peak since the last restart. listen queue len shows whether requests are waiting for a free worker. A listen queue that keeps growing is the clearest sign of a php-fpm slow response caused by too few workers. A pool with idle workers and slow pages points somewhere else, usually the database or a plugin.
The slow log is just as useful. Any request longer than request_slowlog_timeout gets a stack trace there. Open it after a slow page load and look for repeating function names. If the same query or plugin function appears again and again, fixing it often does more than any pool change.
Tune pm.max_children, pm.start_servers, and Friends
Most PHP-FPM slowness on a small VPS comes from the process manager settings. For a WordPress site, pm = dynamic is usually right, because it keeps a few workers ready, adds more under load, and releases them when traffic drops. The values that matter most are pm.max_children, pm.start_servers, and the spare-server limits.
To tune php-fpm pm settings sensibly, start from memory, not from a copied config. Find how much RAM one PHP worker uses on your site under normal load, then divide your available RAM by that number. Leave at least 512 MB to 1 GB for the system, MySQL, and Nginx. If each worker uses about 50 MB and you have 1 GB free for PHP, pm.max_children = 20 is a reasonable starting point. Setting it to 100 on a 2 GB server does not make the site faster; it makes the server swap, and swapping makes everything slower.
A practical starting set for a 2 GB VPS running one WordPress site looks like this:
pm = dynamic
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 8
pm.max_requests = 500
The pm.max_requests value restarts each worker after 500 requests, which clears slow memory growth in plugins without any visible effect on visitors. For a detailed walkthrough of these numbers on a small server, see the guide on how to tune PHP-FPM pool settings for a 2 GB VPS.
After changing the pool, reload PHP-FPM and watch the status page again during normal traffic. If the listen queue stays at zero and active processes sit below the maximum, the pool is no longer the bottleneck. If the queue still grows, raise pm.max_children a little and check memory again. Change one value at a time, or you will not know which change helped. The companion guide on PHP-FPM tuning and pm.max_children explains how that one setting interacts with RAM, and why raising it without checking memory backfires.
Turn On OPcache and Check It Is Actually Working
OPcache stores compiled PHP code in memory, so PHP does not recompile every file on every request. On a WordPress site it is one of the largest single wins, and it is often off or too small on a fresh install. Check whether it is running with php -i | grep -i opcache, then confirm the settings in your PHP config.
The values worth checking are opcache.enable=1, opcache.memory_consumption=128, opcache.interned_strings_buffer=16, and opcache.max_accelerated_files=10000. The last one catches people out: WordPress with several plugins can hold more files than the default limit, and files past the limit simply do not get cached. Raise it if your file count is close to the limit, then restart PHP-FPM.
Verify the cache is filling, not just enabled. A cache that reports almost full memory or a high number of misses is too small for the site. For the full setup, including how to read the OPcache status, see the OPcache setup guide for PHP 8.3 on Ubuntu. One warning: after you deploy new plugin or theme code, restart PHP-FPM or clear OPcache, or visitors may keep seeing the old files until the cache revalidates.
Fix the Database and WordPress Queries Behind the Slowness
PHP-FPM often looks slow when the database is the slow part. PHP waits for MySQL, Nginx waits for PHP, and the visitor waits for all of it. The slow log points at the plugin or theme code, but the MySQL slow query log points at the query itself. Turn it on, load a few slow pages, then read the queries that take the longest.
Common causes are a plugin that runs an unindexed query on every page load, a bloated wp_options table full of expired transients, or a postmeta table that has grown without cleanup. Clean the transients, add the missing index the slow log suggests, and test again. To fix slow ttfb nginx users often chase Nginx settings first, but the first byte usually waits on PHP and the database, so measure there before changing timeouts. Raising fastcgi_read_timeout only hides the symptom: the page still takes just as long, it just fails less often. If you need a broader check, the guide on how to fix slow TTFB with database and cache checks walks through the same diagnosis from the time-to-first-byte side.
Plugins deserve a direct test. Disable them in groups, load the slow page after each group, and note when the time drops. A single plugin that calls an external service on every request can add seconds while PHP waits for a remote server that never answers quickly. Replace it or set it to run in the background instead of inside the page request.
Checklist: Fix Slow Nginx Response Times in Order
Work through this list from the top and stop when the pages are fast again.
- Time a static file and a PHP page with
curlto confirm PHP is the slow part. - Read the Nginx error log for timeouts and socket errors.
- Enable the PHP-FPM status page and slow log, then read both.
- Set
pm.max_childrenfrom measured RAM per worker, not from a copied config. - Turn on OPcache, size it for the site, and confirm it is caching.
- Find and fix the slow database query or plugin the slow log names.
- Re-test the same pages with
curland compare the times with your first measurement.
Slow PHP-FPM responses feel like an Nginx problem because Nginx is the part that answers the visitor, but the fix usually lives one layer back. Measure the delay, read the status page and the slow log, size the pool from real memory numbers, and fix the query or plugin that the logs name. Do those in order and most slow sites speed up without a bigger server or a new stack.