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.
- Below is my website VPS server CPU usage picture.
- I contact my VPS provider and they told me that there are some PHP-FPM processes that cost the above CPU usage.
- So I use ssh to connect my VPS Linux server, and then run the command htop to get the below output.
- From the above result, I see that the PHP-FPM process cost so much CPU usage.
- But my website traffic does not increase so much these days.
- So I go to the www log folder to monitor each domain website’s log.
- And in the log, I find there are so many requests that get the URL /wp-json/wpdiscuz/v1/update?postId= like below.
35.153.213.11 - - [23/Apr/2023:21:31:38 +0800] "GET /wp-json/wpdiscuz/v1/update?postId=
- And the request frequency is too high, so I think maybe the WordPress plugin wpdiscuz trigger the issue.
- 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.
- 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?
- To fix this issue, I deactivate and uninstall the WordPress plugin wpdiscuz.
- But I find the issue still exists.
- So I purge all the cache of my website such as the Cloudflare cache, Ezoic cache.
- But the issue still can not be fixed.
- Because I use Cloudflare as my website’s CDN, so I add a new page rule in the Cloudflare WAF.
- This page rule will block all the requests that the URL contains the text /wp-json/wpdiscuz/v1/update?postId=.
- 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.
- So you should always monitor your VPS server by look the domain log files to get the issue reason.