{"id":25930,"date":"2020-12-21T02:55:22","date_gmt":"2020-12-20T18:55:22","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&p=25930"},"modified":"2022-09-08T21:26:10","modified_gmt":"2022-09-08T13:26:10","slug":"how-to-fix-high-cpu-usage-in-wordpress","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/how-to-fix-high-cpu-usage-in-wordpress","title":{"rendered":"HOW TO: Fix High CPU usage in WordPress"},"content":{"rendered":"\t\t
By reading this article, you will learn to solve the problem of having high CPU usage in WordPress on your own. Besides, you can check out our Hosting services<\/a> for more information. There are several ways that we recommend you to use:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t If you\u2019re not using the latest version of WordPress\u00a0update now<\/a>. Make sure you backup your site first!<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Updating your WordPress plugins to the latest versions can often reduce high CPU usage. If you\u2019re running an old version take a moment to update now.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Whilst it\u2019s cool to be at the cutting-edge, only use stable versions of WordPress plugins. Sometimes early release versions (also known as alpha or beta) can have bugs in the code which can cause CPU spikes.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Caching plugins such as\u00a0W3 Total Cache<\/a>\u00a0and\u00a0WP Super Cache<\/a> can dramatically reduce CPU load by caching static copies of your pages on your webspace. Static files use less CPU and memory. Keeping you within your shared hosting limits.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t WP-Cron manages all the scheduled events on your WordPress site. WP-Cron is a very<\/em> common cause of high CPU loads as it is called every time someone visits your website.\u00a0Disabling WP-Cron and replacing it with a real cron\u00a0job can drastically reduce CPU-load and prevent the chances your account is suspended due to exceeding your resources.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Do you really need that plugin that constantly checks for broken links? \u2013 The more WordPress plugins you have installed, the longer your site will take to load. Deactivate and delete any plugin that you don\u2019t need. Aim for just a handful of plugins. This will speed up your site and keep your visitors happy.<\/p> If you\u2019ve disabled plugins you don\u2019t need, and still have high CPU usage you\u2019ll need to try debugging each plugin to see if it\u2019s the cause of the CPU spike. First make sure you\u2019ve taken a backup of your entire WordPress site (files and database). Now try disabling each plugin one by one until the CPU load has been resolved. Once you\u2019ve found the faulty plugin you should hopefully be able to reenable the others without seeing the CPU problems.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t If using WooCommerce, or similar resource-hungry plugins, make sure your web hosting has sufficient resources.<\/p> If you\u2019re running CPU and Memory intensive plugins on a standard shared-hosting, or budget VPS hosting you may find your site performs badly due to insufficient server resources. Symptoms include slow loading pages, database errors and increased visitor abandonment.<\/p> With many web hosts, if you try running CPU intensive WordPress plugins on a shared-hosting package you risk your site being suspended due to high-CPU loads.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t A badly written WordPress Theme or one written with demanding features such as server-side image resizing can be CPU intensive. To rule out problems with your WordPress theme try the following:<\/p> Try searching\u00a0WordPress Forums<\/a>\u00a0for answers. If there\u2019s a known problem with a plugin there\u2019s a good chance someone will have provided a solution. For example searching\u00a0yarrp cpu<\/a>\u00a0has lot\u2019s of hits.<\/p> You can disable WP-Cron by\u00a0editing your wp-config.php<\/a>\u00a0and adding the following line;<\/p> You can create a\u00a0cron job\u00a0and run wp-cron.php every hour using the following command:<\/p> Replace www.yourwebsite.com with your web address<\/em><\/p> The cron job will ensure your WordPress site\u2019s scheduled tasks get completed, such as scheduled posts, WP super cache garbage collection, etc.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Switching to PHP 7 can dramatically speed up your WordPress website, reducing loading time and freeing up CPU and memory.\u00a0We recommend testing a staging version of your website with PHP 7 before changing the production version.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t1. Update WordPress<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
2. Update Plugins<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
3. Avoid beta versions of plugins<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
4. Install a caching plugin<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
5. Disable WP-Cron<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
6. Only use plugins you\u00a0really\u00a0need<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
7. Avoid resource-hungry plugins<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
8. Avoid buggy WordPress Themes<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
9. Ask the WordPress Community for help<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
1<\/td> define(<\/code>'DISABLE_WP_CRON'<\/code>, true);<\/code><\/td><\/tr><\/tbody><\/table>1<\/td> wget https:<\/code>\/\/www<\/code>.yourwebsite.com<\/code>\/wp-cron<\/code>.php >\u00a0<\/code>\/dev\/null<\/code>\u00a02>&1<\/code><\/td><\/tr><\/tbody><\/table>10. Use PHP 7<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t