Management Guides Troubleshooting

Why Is WordPress Slow? Find the Cause on Your Own VPS

A triage guide for slow WordPress pages and a slow admin on a self-managed VPS: tell server problems from WordPress problems, then check caches, plugins, queries, cron and PHP-FPM.

A slow WordPress site on your own VPS has one of two problems: the server is short of CPU, memory or disk speed, or WordPress does too much work for each page. Ten minutes with curl and top tell you which one you have.

In most cases the server is fine and the cause is one of a short list: no page cache, no object cache, one slow plugin, a slow database query, a call to an outside service, or PHP-FPM with the wrong number of workers. This guide goes through them in the order they usually turn up, and covers the slow admin area separately at the end.

The commands below follow the official documentation of curl, WP-CLI, PHP and MariaDB. They were not run on a test server for this article.

Symptoms and where to look

SymptomLikely causeArticle in this series
Every page is slow for visitors, admin includedNo page cache, or the server is overloadednginx FastCGI cache; step 1 for the server
Front end is fast, admin and logged-in pages are slowNo object cache, Heartbeat, remote calls from dashboard widgetsRedis object cache
Fast when idle, slow or 502/504 under trafficToo few PHP-FPM workers, or too many for the RAMPHP-FPM tuning
Random slow page loads on a quiet siteWP-Cron running inside a visitor's requestWordPress cron jobs
Slow since a plugin or theme was addedThat plugin: slow queries or outside HTTP callsSections below

Step 1: is it the server or WordPress?

Time to first byte (TTFB) is how long the server takes to start answering. Measure it for a PHP page and for a static file, from the server itself or from your own computer:

curl -o /dev/null -s -w 'connect %{time_connect}  tls %{time_appconnect}  ttfb %{time_starttransfer}  total %{time_total}\n' https://example.com/

curl -o /dev/null -s -w 'ttfb %{time_starttransfer}\n' https://example.com/wp-includes/images/blank.gif

Run each a few times. The static file never touches PHP or the database, so it shows what nginx and the network can do.

  • Static file fast, PHP page slow: the problem is in WordPress, PHP or the database. Continue with step 2.
  • Both slow: the server or the network is the problem. Check the server first.

As a rule of thumb, an uncached WordPress page that takes more than about one second to its first byte deserves a look, and a cached page should come back in a small fraction of that.

On the server, look at load, memory and steal time:

uptime        # load average, compare with the number of CPU cores (nproc)
free -m       # "available" memory, and whether swap is in use
vmstat 5 3    # si/so = swapping, wa = waiting for disk, st = steal

Steal (st) is CPU time the host gave to other customers. If the load is higher than the core count, memory is in swap or steal is high, follow Why is my VPS slow? before changing anything in WordPress.

Step 2: no page cache

Without a page cache, every visit starts PHP, loads all plugins and runs dozens of database queries to build the same HTML again. A page cache stores the finished HTML and serves it without PHP. For anonymous visitors this is the largest single improvement available.

Check whether one is active by looking at the response headers:

curl -s -o /dev/null -D - https://example.com/ | grep -i -E 'cache|age'

If nothing indicates a cache hit, set up the nginx FastCGI cache (linked in the table above) or a page cache plugin. Use one of them, not both.

Step 3: no object cache

A page cache does not help logged-in users, the admin area, carts or checkouts. For those, WordPress repeats the same database lookups on every request unless a persistent object cache keeps the results in memory between requests. Check:

wp eval 'var_dump( wp_using_ext_object_cache() );'

bool(false) or NULL means there is none. Set up Redis as the object cache; the guide is linked in the table above.

Step 4: find a slow plugin

Three ways to find it, from least to most effort:

Query Monitor. This plugin adds a panel to the admin bar that lists database queries grouped by the plugin that issued them, outside HTTP calls, and the time each took. Install it, load the slow page while logged in, read the panel, then deactivate it.

WP-CLI without plugins. Compare how long WordPress takes to load with and without plugins:

cd /var/www/example.com
time wp eval 'echo "ok\n";'
time wp eval 'echo "ok\n";' --skip-plugins
time wp eval 'echo "ok\n";' --skip-plugins --skip-themes

A large gap points to a plugin. Use --skip-plugins=name with one plugin at a time to narrow it down. The WP-CLI guide covers installation.

PHP-FPM slow log. PHP-FPM can write a stack trace for every request that runs longer than a set time. The trace names the file and function that was running, which usually names the plugin. The PHP-FPM tuning guide shows how to enable it with request_slowlog_timeout.

Step 5: slow database queries

Turn on the MariaDB slow query log for a while. It can be done without a restart:

sudo mariadb -e "SET GLOBAL slow_query_log = 1; SET GLOBAL long_query_time = 1;"
sudo mariadb -e "SHOW GLOBAL VARIABLES LIKE 'slow_query_log%';"

The second command confirms it is on and prints the file name. Queries that take longer than one second are written there. The setting is lost at the next restart, which is fine for a diagnosis. On MySQL the same statements work with the mysql client.

The most common WordPress-specific problem is the wp_options table. Options marked as autoloaded are read on every request, and plugins leave large entries behind. Measure their total size:

wp db query "SELECT COUNT(*) AS options, ROUND(SUM(LENGTH(option_value))/1024) AS kb FROM $(wp db prefix)options WHERE autoload IN ('yes','on','auto','auto-on');"

Site Health in WordPress warns above 800 KB. To see the largest entries:

wp db query "SELECT option_name, LENGTH(option_value) AS bytes FROM $(wp db prefix)options WHERE autoload IN ('yes','on','auto','auto-on') ORDER BY bytes DESC LIMIT 15;"

Entries from plugins you removed can be deleted with wp option delete name. Take a database backup first.

Step 6: calls to outside services

A plugin that asks a remote API for a licence check, a feed or statistics makes the page wait for that server. Query Monitor lists these under "HTTP API Calls". To confirm the suspicion, block outgoing requests temporarily in wp-config.php:

define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.wordpress.org' );

If the site is fast with this in place, a remote call is the cause. Remove the lines after the test, because updates and many plugins need outgoing requests.

Step 7: WP-Cron and PHP-FPM workers

WordPress runs its scheduled tasks from page visits. On a busy site this adds a check to every request, and a heavy task slows whichever worker picks it up. Moving it to a system cron job is a small change, described in the cron guide linked above.

PHP-FPM serves each request with one worker process. With too few workers, requests queue and the log shows server reached pm.max_children. With too many, the server runs out of memory and swaps, which is slower than queueing. Check the log:

# Ubuntu, Debian (adjust the PHP version)
sudo grep max_children /var/log/php8.5-fpm.log
# AlmaLinux, Rocky Linux
sudo grep max_children /var/log/php-fpm/error.log

The PHP-FPM tuning guide explains how to size the pool from measured memory.

When only the admin is slow

  • No object cache. The admin is never page-cached, so this matters most here (step 3).
  • Heartbeat. Open admin tabs send regular admin-ajax.php requests to the server. Several editors with several tabs each keep PHP workers busy. Count them with sudo grep -c admin-ajax.php /var/log/nginx/access.log.
  • Dashboard widgets. News, statistics and licence widgets fetch remote data when the dashboard loads. If /wp-admin/ is slow and /wp-admin/edit.php is not, hide the widgets under Screen Options.
  • Autoloaded options and outside calls. Both affect the admin more than the cached front end (steps 5 and 6).

Frequently asked questions

Will a bigger VPS fix a slow WordPress site?

Only if step 1 showed a server problem. A slow plugin or a missing cache is just as slow on a larger plan.

Can I use a page cache plugin together with the nginx cache?

It is possible, but two layers make it hard to know which one served a stale page. Pick one.

Share story:

Continue reading other guides on How VPS.