- Confirm the load is yours before changing anything. On a shared server the graph often shows your neighbours.
- Automated traffic is the most common cause. Check the access log by user agent before you blame a plugin.
- Full-page caching is the biggest single fix, because a cached request uses no PHP and no database.
- Slow queries are usually a missing index or an oversized options table, not a lack of CPU.
- Upgrade the server last. Doubling capacity for a site crawled ten thousand times an hour only doubles the bill.
How do I confirm it really is high CPU or memory?
To fix high CPU or memory use on WordPress, find the cause before you buy capacity. Check the load is sustained and really yours, then read the access log for bots, find the slow plugin or query, and add page caching. A bigger server is the last step, once the waste is gone.
# Load against core count. Load 4 on 4 cores is busy; on 16 it is quiet.
uptime && nproc
# What is consuming CPU right now
ps -eo pcpu,pid,user,comm --sort=-pcpu | head -10
# Total memory across all PHP workers, in MB
ps -ylC php-fpm8.3 --sort:rss | awk 'NR>1 {s+=$8} END {printf "PHP total: %.0f MB\n", s/1024}'
# Database memory
ps -eo rss,comm | grep -E 'mysqld|mariadbd'
# Available memory: this is the column that matters
free -h
# Has the kernel been killing processes?
sudo dmesg -T | grep -i 'killed process' | tailOn shared hosting the graph may not be about you
A shared server's CPU chart shows every site on the machine. If your own PHP processes are modest while the machine is busy, the load is a neighbour's, and tuning your site will not change it.
Is it bots rather than visitors?
Check this first: it is the most common cause. Crawlers, scrapers and AI training bots can outnumber people many times over, and analytics that rely on JavaScript never see them. The server's access log does.
LOG=/var/log/nginx/access.log
# Top 20 user agents
awk -F'"' '{print $6}' $LOG | sort | uniq -c | sort -rn | head -20
# Top 20 client IPs
awk '{print $1}' $LOG | sort | uniq -c | sort -rn | head -20
# Requests per hour: where is the peak?
awk '{print substr($4,2,14)}' $LOG | sort | uniq -c | tail -24
# Most requested URLs
awk '{print $7}' $LOG | sort | uniq -c | sort -rn | head -20
# Requests hitting the expensive endpoints
grep -cE 'wp-login|xmlrpc|wp-json|\?s=' $LOG| Pattern in the log | Means | Response |
|---|---|---|
| One IP with thousands of requests | A scraper or a broken integration | Rate limit or block that address |
| Heavy hits on /?s= | Search spam: every one bypasses the cache | Rate limit search, or require a longer query |
| Repeated POSTs to xmlrpc.php | Brute force or pingback abuse | Disable xmlrpc.php if nothing uses it |
| Constant wp-login.php POSTs | Credential stuffing (trying leaked passwords) | Rate limit, and use a bot challenge |
| Many AI crawler user agents | Training crawlers, often ignoring robots.txt | Filter them before they reach PHP |
Every row here takes a PHP worker per request, which is exactly the resource you are short of.
Filtering in front of the site costs your server nothing
Blocking bots inside WordPress still means running PHP to decide to block them. On G7Cloud, ScaleShield sits in front of every site and challenges or blocks abusive automated traffic before it reaches your container, so that CPU is never spent.
Which plugin or query is responsible?
Once you have ruled out traffic, find the code. Query Monitor (a free plugin) breaks each page request down in the browser. The MySQL slow query log catches queries that only misbehave under load.
# In my.cnf, under [mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1
log_queries_not_using_indexes = 1
sudo systemctl restart mariadb
# After some real traffic, summarise it
sudo mysqldumpslow -s t -t 20 /var/log/mysql/slow.log
# What is running right now
mysqladmin processlist
mysql -e "SELECT * FROM information_schema.processlist WHERE time > 5\G"mysqldumpslow -s t sorts by total time. That surfaces the query that costs the most overall, not the single slowest run.cd /var/www/example.com
# Time how long WordPress takes to run its init hooks
wp eval 'timer_start(); do_action("init"); echo timer_stop(3);'
# Autoloaded options: this should be well under 1 MB
wp db query "SELECT ROUND(SUM(LENGTH(option_value))/1024/1024, 2) AS mb
FROM wp_options WHERE autoload='yes'"
# The worst offenders in that table
wp db query "SELECT option_name, ROUND(LENGTH(option_value)/1024) AS kb
FROM wp_options WHERE autoload='yes' ORDER BY LENGTH(option_value) DESC LIMIT 20"
# Table sizes
wp db query "SELECT table_name, ROUND(data_length/1024/1024,1) AS data_mb,
ROUND(index_length/1024/1024,1) AS idx_mb
FROM information_schema.tables WHERE table_schema=DATABASE()
ORDER BY data_length DESC LIMIT 15"- Install Query Monitor and open the Queries and Hooks panels on a slow page. It names the plugin behind each query.
- Deactivate plugins in halves on a staging copy, then narrow down. Eight plugins takes three rounds, not eight.
- Check what runs on admin-ajax.php. Heartbeat, live stock checks and analytics widgets fire repeatedly and are never cached.
- Look at the scheduler. A stalled task queue that suddenly catches up will spike CPU. See WordPress cron and missed tasks.
What actually reduces CPU and memory?
Here are the fixes in order of impact for the effort. The first usually beats the rest combined, because a cached request runs no PHP, makes no database query and takes no worker.
| Fix | Typical impact | Effort |
|---|---|---|
| Full-page caching for anonymous visitors | Very large | Low |
| Filtering bots before they reach PHP | Large on a crawled site | Low |
| OPcache (PHP's compiled-code cache) on and sized correctly | Around a third of PHP CPU | Low |
| Object caching with Redis | Large on logged-in and dynamic pages | Medium |
| Removing or replacing a heavy plugin | Varies, sometimes total | Medium |
| Adding a missing database index | Large where it applies | Medium |
| Trimming the database and options table | Moderate, and helps admin speed | Medium |
| A bigger server | Buys headroom, fixes nothing | Low, and recurring |
Work from the top down. People usually start with the last row, which is why the problem comes back.
# 1. OPcache. Check it is on and not full.
php -i | grep -E 'opcache.enable|memory_consumption|max_accelerated_files'
# 2. Object caching with Redis
sudo apt install -y redis-server php8.3-redis
wp plugin install redis-cache --activate
wp redis enable
wp redis status
# 3. Remove expired transients (cached values plugins store in wp_options)
wp transient delete --expired
# 4. Post revisions, which accumulate without limit by default
wp post delete $(wp post list --post_type=revision --format=ids) --forceCap revisions for good in wp-config.php with define('WP_POST_REVISIONS', 5);. Deleting them once helps; stopping them building up again keeps the fix in place.
When is a bigger server actually the answer?
When the work is genuine and already efficient. If caching is on, bots are filtered, queries are indexed and the site still runs at capacity during normal trading, you have outgrown the server. Upgrading before the other fixes only makes the same waste cost more.
- The cache hit rate is high and CPU is still full. The remaining traffic genuinely needs PHP.
- Load stays above your core count in ordinary hours, not only during a sale.
- Available memory is always low and the out-of-memory killer has fired. That is a hard limit.
- A checkout or admin page is slow with no slow queries. The work is genuine and has nowhere left to run.
Isolation removes a whole category of this
On shared hosting your CPU is shared with every site on the box, so your response times move with their traffic. On G7Cloud each site runs in its own container with its own database and its own PHP, so the resources you measure are yours. See managed WordPress hosting compared with shared hosting, or how our WordPress hosting is set up.
For the front-end half of the picture, where server time turns into what visitors feel, Core Web Vitals for WordPress covers the measurements Google uses.
Frequently asked questions
What causes high CPU usage on a WordPress site?
Most often bots hitting pages that cannot be cached, then slow database queries, a heavy plugin running on every page load, and missing caching. Check the access log by user agent first: bots are the most common cause and the easiest to fix.
How do I find which plugin is using the most resources?
Install Query Monitor and open a slow page: it shows which plugin is behind each query and hook. To confirm, deactivate plugins in halves on a staging copy, which narrows eight plugins down in three rounds.
Will more RAM fix a slow WordPress site?
Only if you are short of memory, which shows as low available in free -h and out-of-memory kills in dmesg. If the site is slow with memory to spare, the limit is CPU, disk or a slow query, and more RAM changes nothing.
What are autoloaded options and why do they matter?
They are settings WordPress reads on every page load, including AJAX and REST requests. Plugins that store logs or cached API data there can push the total past several megabytes, all read and unpacked on every request. Keep it under 1 MB.
Does caching reduce CPU usage on WordPress?
A great deal. A full-page cache hit is served as a stored copy, with no PHP and no database. Where most visitors are not logged in, page caching usually removes most of the CPU work.
Why does my site use high CPU with almost no visitors?
Usually bots, which do not appear in JavaScript-based analytics but do appear in the server access log. A backlog of scheduled tasks catching up, or a plugin calling an external API on every load, look the same. Check the access log first.
About G7Cloud Engineering
Articles written by the engineers who build and run G7Cloud: UK managed hosting and the AI Website Builder. We write about what we operate every day: containers, backups, databases, and the small-business websites that run on them.
More about G7Cloud →