We are hosted at Squidix semi dedicated hosting and it’s pretty reliable
. We never faced any issue with them. But recently we noticed higher CPU and Memory usage on our server.
There might be multiple reasons
for higher CPU and Memory usage:
- Crunchify is a mature site and started getting very higher traffic
- Couple of recent plugin updates
- Recently theme upgrade and custom modification which includes Custom Post Type and more.
- may be something else…
Let’s get started –
Check Point-1: Memory and CPU usage
Here is a problem definition. Why these much Memory and CPU usage? Checkout below ~50% CPU usage
and ~4GB Memory usage
graph.

We have an open bug on official disqus github repo.
Check Point-2: Entry Processes
Once we looked at our cPanel
stats then we noticed the same high number of entry processes.
Seriously?? ~228 entry process
at a time??? Bluehost and Hostgator by default allows maximum 25 entry
process at a time compare to Squidix allows 400
. There is no way you could have survived with Bluehost or Hostgator hosting in this case.
Point here is ==> ~228 entry processes are toooo much
.
Checkout stats (before):

In order to fix this higher WordPress CPU, Memory and Entry process usage we started looking at all possibilities.
Precaution Step-1
First we eliminated higher traffic pattern
as a cause because we use WP Super Cache WordPress plugin and it handles this situation very well. In fact – page loads in near half a second
.

With ~16 millions calls per month
we didn’t see any degradation on site loading metrics. Let’s move on.
Precaution Step-2
Any recently plugin
and theme
update?
Hmm… those updates were from very reliable WordPress contributor and after spending significant amount of time we also ruled out this possibility too. We do have local WordPress setting using MAMP and after disabling
and enabling
those plugins we didn’t notice any page load time or higher CPU issue.
Precaution Step-3
Now I left with only my last doubt
about plugin Disqus
. I googled it and found couple of very interested threads about higher CPU usage
and Disqus
.

On Crunchify, we do have Disqus Sync enabled by default
.
Now think about this scenario:
When you have normal traffic like ~2000 active users at at time then Disqus’s sync job also executes ~2000 times at given time and that’s not good
.
1 Sync job = 1 Cron job call
. And finally we found the actual problem.

How to fix Disqus High CPU usage issue caused by dsq_sync_forum Sync Job?
Solution-1.
Step-1
- Go to
Plugins
->Editor
- Choose Plugin
Disqus Comment System
from combo box - Search for line 514
wp_schedule_single_event($ts, 'dsq_sync_forum');
- Replace it with this code block and
save
file.
$next_scheduled = wp_next_scheduled('dsq_sync_forum'); if($next_scheduled) { // do nothing } else { // It's time to sync now wp_schedule_single_event($ts, 'dsq_sync_forum'); }
Step-2
- Go to
Comments
->Disqus
- Click on
Plugin Settings
- Uncheck box for
Disable automated comment importing
Save
changes

So, How to sync comments now?
Now after this whenever you want to sync Disqus comments with WordPress Database then just check above box and save settings. All comments will be imported to your Database within 10 minutes.
Solution-2. How to Disable wp-cron.php via .htaccess trick?
- Load Disqus only on
onClick event
– That means, user have to click onLoad Comment button
to load comments. But there are somedisadvantages
.- If a visitor’s sees comments right served up to them, they may be more likely to read them.
- Contribution in comments section is also more likely if comments section is seen by default.
- Block Disqus sync on every page load by adding
.htaccess
rule.- I tried this approach and it worked too.
In order to achieve point-2
above I’ve add below mod rewrite rules
into .htaccess
file.
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{QUERY_STRING} !="" RewriteCond %{QUERY_STRING} !^s=.* RewriteCond %{QUERY_STRING} !^q=.* RewriteCond %{QUERY_STRING} !^url=.* RewriteCond %{QUERY_STRING} !^ver=.* RewriteCond %{REQUEST_URI} !^/wp-admin.* RewriteRule ^(.*)$ /$1? [R=301,L] </IfModule>
Basically above code will block all wp-cron.php jobs
🙂
NOTE:
we have recently added url pattern
which is required for all WordPress Embed functionality and ver pattern
which is required to load style.css
or other files with version number as parameter.
Let’s understand this block:
- Ignore all query string in URL and redirect to your blog URL
- If query string contains
?s=
and?q=
then only it’s allow. Sample:- https://crunchify.com/search/?q=wp%20super%20cache
- https://crunchify.com/?s=wordpress
- Ignore this rule if URL contains
wp-admin
After enabling above rule too, I saw significant improvement
on Memory and CPU usage and it's nearly zero
. Also – entry process
was almost reached to zero(0)
. That means visitors were served cached page almost all the time.
This post will helps you also if you have below problem and it’s part of WordPress optimization tips.
- WordPress High CPU usage?
- WordPress High Memory usage?
- wordpress high cpu usage fix
- wordpress excessive resource usage
- wordpress cpu usage problem
- Fix dsq_sync_forum high CPU issue
- wordpress plugin cpu usage
- reduce wp cpu usage
- How to monitor and reduce WordPress memory usage
- wordpress memory usage exceeded
- wordpress memory usage optimization
- wordpress disqus plugin memory usage
Check out the difference (After):

Update:
On July 15h, 2017 we moved over to Default WordPress comment system. Get some idea why on that post 🙂
What is the best spec for wordpress site, higher CPU or RAM?
What is the best spec for wordpress site, higher CPU or RAM?
Hi, I have a website with 300 users at a time. I am using wordpress with 2 CPU and 4 GB and seeing performance issues. Wondering when you had 2000 active users how much CPU and Memory you were using for your site?
Nice Article, I have Ecommerce books website.
After using cache plugin like lite speed cache & W3 total cahe – my website hosting & memiory usage is very high please help for resolve issue
Good post but not for the problem I have unfortunately. I’m seeing connection lost/high CPU caused by ajax. Already added heartbeat and disabled it on the dashboard. Still the same. So when I have a longer page, not very long but long enough and I try to update it, it hangs. Shared hosting. Godaddy tech is clueless, they only point to plugins which I only have just a few. Other sites with same plugins work fine no issues, only this one on shared hosting. Can’t find the culprit….
Hi Oxana Ox – sorry to hear about your site issue. To be honest, in my case most of the time, shared hosting caused us so many issues in the past.
After migrating to Kinsta and Google Cloud have been better.
One more point is to move to latest version of PHP. At least PHP 7.3+. Which PHP version are you on? Having long post shouldn’t have any issue.
Thank you for these tips on how to fix higher CPU usage, I can now apply this on my website. Also, if you find that high CPU usage persists even in support of standard processes, you may simply need a faster computer. You can also reduce CPU load by adding more RAM, which allows your computer to store more application data.
You are welcome Jonathan. Happy to help!
It didn’t answer the Question Specified in the title, How to Fix High memory usage on WordPress ?
it just gave solution to disqus problem, what with other many millions people ? atleast you could give us any clue of how to find the culprit code ?
Hi James – good point. This post is mainly focusing on Disqus issues. There might be multiple reasons you face Higher CPU and Memory at your end.
One of the main reason I see is unwanted plugins. On Crunchify we have published multiple WordPress enhancement tutorial which you may need to look to find culprit code and tuning tips:
1. Optimize WordPress Database
2. Top 5 tips to boost WordPress Performance
3. WordPress Speed Optimization Tips and Goals
Let me know if you have any more question.
Good article! About analyzing GC logs, gceasy is also good. It is free web tool. You have to upload your GC logs to their server, and results are provided online.
Great. Thanks for sharing GCEasy with audience Surya.
RewriteEngine On
RewriteCond %{QUERY_STRING} !=””
RewriteCond %{QUERY_STRING} !^s=.*
RewriteCond %{QUERY_STRING} !^q=.*
RewriteCond %{QUERY_STRING} !^url=.*
RewriteCond %{QUERY_STRING} !^ver=.*
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteRule ^(.*)$ /$1? [R=301,L]
not working on https(SSL) site
What error are you getting?
This should work with HTTPS also.
thanks working so good… now CPU load average less than 1.000xx
view on the status plugin server-status-littlebizzy.
Hi Karim – it’s really great to hear it’s working perfectly fine for you. Checkout some more optimization articles on Crunchify and let me know your feedback. Happy blogging.
thanks for providing a information which I found to be quite accurate and useful. I think it is a genuine problem Memory Usage for WordPress site?
Ideally hosting provider should take care of Memory settings and all. Kinsta and WPEngine are my favorite.
it’s very detailed… good guys. please try our plugin next time for test CPU and memory limit and free statistics if you interest:
https://wordpress.org/plugins/server-status-littlebizzy/
Server Status plugin. thanks mate 🙂
I think Disqus must’ve recently changed something, as it’s hammering our CPU at the moment. Totally nuts. Our traffic hasn’t increased proportionately, so I am stumped as to what’s going on.
Yeah. I still have below code in .htaccess file.
Auto syncing by creating cron jobs entry is not the right way to do it and unfortunately Disqus still hasn’t fixed that 🙁
I emailed disqus about the issue. Here’s what they said so far:
“We’re taking a closer look into this now with the rest of our team. It might take a little longer to figure out what’s happening, but we’ll get back to you as soon as we can with what we find. Thanks for your patience!”
Wonder if I’ll ever hear back…
Thanks for an update Will.
Does this still work? Have they responded?
This .htaccess trick still works very well. Disqus never got back to us with solution. Between – we moved away from Disqus on Crunchify since last month.
Bundle of thanks for this tutorial. Due to this tutorial I get rid of excessive usage of CPU.
Keep sharing like this..
That’s a great tutorial which help me.,
-Humna
Thanks for taking a time to comment. Appreciate it. Happy blogging.
Thanks!
You are welcome Sarang.