How To Fix High CPU Usage In WordPress

Recently, I find my website running slowly. And when I look at my website VPS dashboard, I found that the CPU usage is too high, it always cost 100% of CPU usage. After investigating, I finally find the reason and how to fix this issue.

1. How To Find The Reason Why VPS Server CPU Usage Is Too High.

  1. Below is my website VPS server CPU usage picture.
  2. I contact my VPS provider and they told me that there are some PHP-FPM processes that cost the above CPU usage.
  3. So I use ssh to connect my VPS Linux server, and then run the command htop to get the below output.
    CPU is high because of php process
  4. From the above result, I see that the PHP-FPM process cost so much CPU usage.
  5. But my website traffic does not increase so much these days.
  6. So I go to the www log folder to monitor each domain website’s log.
  7. And in the log, I find there are so many requests that get the URL /wp-json/wpdiscuz/v1/update?postId= like below. - - [23/Apr/2023:21:31:38 +0800] "GET /wp-json/wpdiscuz/v1/update?postId=
  8. And the request frequency is too high, so I think maybe the WordPress plugin wpdiscuz trigger the issue.
  9. So I google the keyphrase /wp-json/wpdiscuz/v1/update?postId= cost CPU too high and then get some results, they all meet the issue but do not know how to fix it.
  10. So I confirmed that the issue is because of too many requests to the WordPress plugin wpdiscuz.

2. How To Fix High CPU Usage In WordPress?

  1. To fix this issue, I deactivate and uninstall the WordPress plugin wpdiscuz.
  2. But I find the issue still exists.
  3. So I purge all the cache of my website such as the Cloudflare cache, Ezoic cache.
  4. But the issue still can not be fixed.
  5. Because I use Cloudflare as my website’s CDN, so I add a new page rule in the Cloudflare WAF.
  6. This page rule will block all the requests that the URL contains the text /wp-json/wpdiscuz/v1/update?postId=.
  7. And after I add the page rule, the issue is fixed, my VPS server CPU usage goes to normal, and I wish my website traffic comes back soon also.
  8. So you should always monitor your VPS server by look the domain log files to get the issue reason.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.