Websites on shared hosting suffer a lot if they have high CPU usage. It increases the load time of the webpages and the account can be terminated for this reason. The main reason for this problem is that the shared servers have many websites running simultaneously. If a particular website is using lots of CPU then it may trouble other websites running on the same server. High CPU usage can be because of high traffic, bad html codes or bad plugins. Following are the ways to optimize the website (specially those which are based on WordPress) to reduce CPU usage.
- You should regularly repair and optimize the SQL database. You can do it through cPanel or phpMyAdmin.
- Plugins (with poor PHP scripts) are the main cause of problem in most of the cases of poor WordPress based websites. It unnecessarily increases the communication time between database and PHP scripts. It loads each time whenever your website loads. Deactivate all plugins that you don’t need or that are not coming from a trusted source. Don’t keep the unactivated plugins. Just delete (available in wp-content/plugins)
- Try to avoid use of images,video and flash objects. It increase the time to load a particular page and utilize memory. Images can be reduced in size by using professional softwares like adobe photoshop. The images can be reused for posts on similar topics. WordPress store all images at one place in wp_content. You can also use FTP to transfer you images here which you can use to add in posts. You can also use links to add images .
- Using Google Search also reduce the CPU work as the searches is performed at Google server. Additionally, It also give chance to earn money.
- Only summaries should be shown in the feeds. To select this option go to Settings->Reading, select use Summaries in Feeds
- Use caching plugins. Some good trusted caching plugins are WP Super Cache and W3 Total Cache. Caching greatly improve the loading of your page and reduce CPU usage.
- Try to avoid getting unnecessary e-mail notifications that you really don’t need. It unnecessarily put pressure on server. For example if commnts e-mail is opted, a mail will be sent each time a visitor comments. If you really don’t read those comments in mails why ask your mail server to send you mails. To turn it off, go to Settings->Discussion.
- Turn off any formatting options. Go to Settings->Writing. Uncheck both formatting options. “WordPress should correct invalidly nested XHTML automatically” is more serious out of these two.
- Use less number of posts on each page. Similarly less number of feed should be chosen. To select it go to Settings->Reading. Reduce the number here.
- Try to avoid use of badly coded related post plugins. Related post plugins have many issues. Even good plugins in this category like ‘Yet Another Related Posts Plugin (YARPP)’ has many issues. Many web hosts have banned its use in shared hosting plans. It resulted in high load of CPU and increased query time. Think before using them
- Always update everything. If there is an update available, you should always go for it. Updates contain security improvements and bug fixes.
- There are number of plugins which offer feeds from various source like twitter tweets, facebook updates, feed of other stie, RSS widget. All these plugins try to gather information from external source every time a visitor comes to your site. You should try to keep such feeds minimum.
- After updating the WordPress psots the old revision of the posts remain there in the database which increase the database size. You should remove old revision of the posts from database.
- You should avoid changing CSS, JS and PHP without knowing the event. Excessive formatting of these files to include more and more things (visual formatting as well including external source) increases the loading time of your webpages. If you have added something on your PHP to load from external source and the external site is down then your page will also load slowly.
- Try to avoid leaving ‘writing post pages’ open without using them. It will keep your site open for such period of time. WordPress ‘auto save ‘ option use server resources and which results in higher CPU usage. Posting article through email and word also increase the use of resources. Best way to post article is write in the word processing software like wordpad, Microsoft Work and openoffice and subsequently paste it in the WordPress for publication.
- All web hosting companies has cPanel which has option to see which of the queries are taking longer time to respond. Whenever a visitor open a webpage a query is sent to the database to retrieve the data/information contained in that post. Queries that are taking longer time increase the pressure on server and your site will load very slow. You should always look for the logs which indicate which of your queries are taking longer time to responds. Subsequently you should change the script to repair PHP scripts.
If you are exceeding the allowed CPU then there is no hope for you to continue with current web host. If you have followed above recommendations but still facing the problem of high load then high traffic is the main culprit and you need more resources to continue smooth running of your website. In simple term high traffic need more CPU usage and high bandwidth which is not possible in shared hosting. If you have very high traffic, better move to virtual private hosting server /virtual dedicated server(VDS/VSH)) or dedicated server. Off course you have to pay higher, but there is no other way-out. If you want to compensate the money paid for hosting then you can monetize your traffic by adopting online money making strategies.
This particular post will be updated on regular basis to include more ways to reduce CPU usage. Guys just add your knowledge in the comment section.
Source: Article first published in InstPhil
Sandy Sah is a highly qualified blogger. He owns many blogs on variety of topics. He has expertise in the health, education and entertainment field. He did his doctorate in health sciences.