How to Fix Your High WordPress CPU Usage Problem
If high WordPress CPU usage problems are driving you insane, this post will help you out. If your site is using too many resources, it’s probably making your site run slow for your visitors and could be affecting your rankings. Not to mention the fact that you may be getting warnings from your hosting provider or they may have even suddenly shut you down without warning.
Note: Here’s a guide on how host winds handle continuous high resource usage (No, we won’t shut your site down all of a sudden because your site gets a surge of traffic and resource usage goes through the roof)
So here we go, here are some of the first things you should look at and consider if you’re having constant problems with resource usage or a slow loading site period…
The CPU stands for the central processing unit. On every computer (like a web server which every website is hosted on), the CPU handles all the basic processing of everything.
The lower the CPU usage, the better. When CPU usage gets too high on your computer, you’ll probably hear your fans kick into overdrive to cool it down. When it gets too hot in spite of cooling, the CPU will limit its performance to cool down. If that doesn’t help, the computer will shut itself down to prevent damage to the CPU.
When a web server shuts down, all the websites hosted on it go down with it. So as you might imagine, web hosts can be pretty stingy about CPU load. Especially on a shared web server, where one CPU load-heavy website can potentially bring down websites hosted on other people’s accounts.
Different, but one that can cause similar adverse effects if overutilized is memory usage. This is referring to the RAM (random access memory) utilization on the server. If too much memory is hogged by a problematic plugin, that’s less memory that can be used for basic server operations, which results in slowness.
Check your plugins and themes
Plugins and themes are awesome. They can help you add just about anything you want to your site without having to hire a developer or take on coding yourself. But if you use poorly coded ones or use too many of them, it can take a toll on your site.
Even if you only use a couple at a time, over time, the installing/uninstalling, activating/deactivating of a bunch of plugins or themes can leave rogue, abandoned data just hanging around eating up bandwidth.
So what do you do? Simple, you stop using them. JOKING! No, seriously, you don’t have to do that. But you should do the following…
Only use plugins you need
If you have plugins or themes laying around that were installed just to test them out and you weren’t happy with them, get rid of them. If they’re sitting around for that “Oh maybe, just in case I want to…” then save the zip files somewhere else and install them when you’re going to use them.
Note: Before deactivating and deleting a plugin, look for any uninstall feature or readme files. Some plugins have special uninstall procedures to completely remove them from your site.
Tip: Here’s an awesome guide to choosing a fast loading WordPress theme, so you can ensure your theme isn’t going to bog down your site from the get-go.
Clean and Optimize Database
The database is the soul of your WordPress website because it stores all the data like posts, comments, etc.
A poorly optimized database can often cause problems with high CPU usage, and slow down your websites.
In addition to that, if a database is bloated with unnecessary data(spam comments, post revisions, etc.), it can take more CPU time to process a simple query.
This, in turn, affects the performance of the site.
At Bobcares, we use WordPress optimization plugins to automate the database cleaning process.
Moreover, in VPS/Dedicated servers, we use database optimization tools like mysqltuner.pl or tuning-primer.sh.
It’ll show recommendations as shown in the image and we adjust those parameters in my.cnf file. If it is to optimize tables, we use the mysqlcheck command as shown below.
Only use plugins and themes from trusted sources with clean, optimized code
Many plugins and themes out there are a dime a dozen. They were thrown together by a sloppy or amateur developer. They likely aren’t even supported with new versions to keep it up to date with new WordPress versions or newly discovered security vulnerabilities. And unfortunately, some are even developed to purposefully be malicious.
Find plugins potentially eating up resources
Using your preferred tool for testing page load speed, test your site without your plugins one at a time. Disable a plugin, then test your site. If you find that by disabling a certain one, your site performs much better, then you’ve just identified a potential problem-plugin. See if you can find an alternative one that does offers the same features and try that one.
There’s also a plugin that can help identify plugins that perform poorly, but it’s geared more toward developers:
Some may wonder why we wouldn’t mention P3 (Plugin Performance Profiler), which was once a very popular plugin for doing this. It would analyze your plugins to determine if one or more may be to blame for slowing down your site and user-friendly. But it hasn’t been updated in over two years and many conversations are going on around the web about it.
There are reports of it breaking sites, locking admin, etc. So we don’t recommend it until it gets a new update.
Do you get a lot of traffic?
“A lot” is a very relative term, I know. But it’s important to put these sorts of stats in perspective.
For example, 500 visitors per day may not seem like much, but you can’t assume that all 500 visitors were evenly spread out throughout 24 hours. You have peak hours when the bulk of your visitors land on your site.
If those 500 visitors landed on your website at the same minute (an unlikely scenario, but consider it for example’s sake), your web server would likely buckle under pressure with that amount of concurrent users.
And if you were just looking at daily stats, you wouldn’t have a clue as to why. It’s important to drill down to more specific measurements of time to gauge your server’s ability to handle the traffic.
Eliminate Gravatar comment page load delays
Gravatars are awesome. They let your users show their personality, add a genuine touch and plenty of people are easily identified by their unique Gravatars. But there’s a problem with using them on your site if you get lots of comments. Each comment will send a request to the servers at Gravatar. So if you have lots of comments on a page, you’re going to have lots of calls being transferred back and forth, making that page load slower. Eliminate this with FV Gravatar Cache.
FV Gravatar Cache will cache those images locally, which will reduce the load time on pages with many, many comments…
With one exception: Alec Kinnear from foliovision, the developers of FV Gravatar Cache, warns that if you have bad hosting and/or a site that’s overloaded with plugins, etc. then this plugin could slow things down.
Also, if you have hundreds of comments already, keep in mind it can take anywhere from five hours to a couple of days for everything to get cached.
You can grab it from the official WordPress plugins repository here and test it out for yourself.
Tip for reducing CPU server usage for WordPress if you get a lot of comments- FV Gravatar Cache!
Use a caching plugin
A caching plugin will help load content faster that’s been served recently. Generally speaking, when someone visits your WordPress site, their browser will fetch the HTML files, which requires PHP scripts to be run or data to be grabbed from the WordPress database.
Luckily, today most browsers are smart enough to keep a “memory” of sites that are accessed through the browser. This is the cache. A WordPress plugin will save the HTML files that were served so browsers can load them faster without the need to run scripts or grab info from databases.
Some caching plugins even work with a content delivery network (see below) or GZIP.
Some popular WP caching plugins to consider are:
- W3 Total Cache
- WP Super Cache
- WP Rocket
- Comet Cache
- WP Fastest Cache
Get on board with a CDN
Doing this one thing is almost guaranteed to give a boost to your site’s performance, and that’s using a content delivery network (CDN). By using a CDN, static files, especially media files, are loaded from the CDN servers – not the server you’re paying your host for. And chances are, they have servers closer to your visitor.
So it’s a win-win. It can be tricky to find a quality CDN that fits your needs and your price range since there are so many of them today. But you can use this guide to free CDNs we recently published to get started.
If you’d rather jump straight into a premium, paid options, some to consider are:
- MaxCDN (Starting at $9/month)
- Amazon AWS (Limited free plan tier for new members, then pay as you go pricing)
- KeyCDN (Flat rate, usage-based pricing)
- WPPronto (Starting at $20/month)
- CDN77 (Pay as you go pricing)
Compress your images
Image compression plays a huge role in how fast your site loads, especially if you have tons of them. Especially today when high-resolution images are the expectation, not the exception. Unfortunately, many of the plugins and services you find today only offer a fraction of the features for free or put a cap on just how much you can use it before you have to start paying.
Yep. Capitalizing on the importance of image compression and optimization is now a thing.
Of course, you could sign up to and use a number of them, bouncing from one to the other throughout the month. But first, let me tell you about Compressor.io – the most underrated tool for image compression in my opinion. And yes, it gets its section…
It’s completely free and it’s online so no plugins are adding more weight to your site, no software to download. You simply upload an image and watch as it shows you in real-time just how much compression has taken place, then download your newly optimized image.
From my experience, this most often will reduce your image’s file size from 40% to 70%, though here and there I’ve seen more or less. They claim it can reduce the file size by up to 90%.
Image compression is important for page load speed from my experience compressor shrinks image size 40- 70%
It supports JPEG, PNG, GIF, and SVG and you can choose which method you’d like to use for compression: lossless or lossy. Yes, there is a 10MB file size limit… I haven’t run into any issues there, though I guess if you’re a designer then you might.
And there’s the fact that you do one image at a time, which I’m sure will not be ideal for many people.
Of course like I said, there are many services and plugins out there for compressing images though. Here are some other options you might want to explore:
ShortPixel – Free 100 credits per month, then $4.99 per 5,000 credits, no file limit size, and you can bulk optimize images previously uploaded (along with all the thumbnails used for them)
Optimus – Free (only JPEG and PNG images less than 100kb) or paid annually (premium members get access to developer API, no file size restriction, HTTPS connection, and web conversion)
ImageRecycle – Free trial then starting at $10/month
LazyLoad – Doesn’t compress images, but only loads them when they’re scrolled into view so images not trying to be viewed aren’t trying to load, slowing down page speed
BJ Lazy Load – Uses placeholder image on images not coming into view yet, which also works within text widgets and iframes
This may seem like a lot to do, but really… if you do any one or two of the above, you’ll probably see better performance for your site. If you do them all, well, you’ve probably gone and outdone a good chunk of your competitors. If you’re still having issues then it’s probably time to talk to your host, as they should be able to help figure out what’s going on.
What’s the one thing you’ve done that had the biggest effect on increasing your site’s performance?
If you’ve found this helpful, please share! Or leave a comment here if there’s something, in particular, we didn’t cover that you’d like to see.
Is your host shaking you down?
Cheapo, sketchy shared hosts may be exaggerating or completely fabricating your CPU load woes as a ruse to get you to upgrade to a more expensive plan.
It’s difficult to prove, so don’t go around accusing your hosts of CPU load shakedowns. But if you have a gut feeling your host is pulling your leg, it may be worth exploring more reputable options.
Do you genuinely need to upgrade?
No matter how efficient the plugins you run are, no matter how aggressive your caching layer is, no matter how airtight your firewall is, some websites just simply outgrow their hosting accounts.
If the answers to all of the above questions were no, you may genuinely need a more accommodating hosting plan.