How to Diagnose and Fix Web Hosting CPU Performance Issues
This guide will show you how to improve web hosting CPU performance and fix database issues, highlighting steps to tackle inefficient scripts and optimize queries for a smoother website operation. Bluehost uses a CPU protection system on our shared server.
What is CPU Protection
Bluehost employs a system that monitors server resources like the CPU and memory. It makes sure that every user on a shared server gets their fair share of the system resources. It also prevents other users from causing performance issues for other accounts. This system is in place on our shared servers so that each user has the least chance of being affected by issues caused by another user. If a user is found to be abusing the server and it is somehow affecting other customers, we will identify the user and take corrective action. This sometimes means suspending the user. Dedicated and VPS servers do not have this protection system.
Performance issues and Suspensions are usually caused by:
- Poorly coded PHP scripts, such as multiple nested loops or infinite loops.
- Themes, Addons, or Plugins (if you just added a new component to your script, you may want to remove it to see if that new component caused your site to suddenly perform slowly)
- Queries that return inordinately large dataset results (e.g., 100,000 records) are included in the response object of a round trip to the server.
- Queries that take too long to execute due to heavy aggregation commands like SUM and COUNT over very large datasets without proper indexing.
- Queries that are doing complex, unoptimized nested joins.
- Queries that execute large batch commands like INSERTS, UPDATES, OR DELETES - these types of SQL calls are 10 times more expensive and resource-intensive than the SELECT query command.
- DDoS Attacks
- Any process that uses too much memory, like a rogue cron job
- Too many simultaneous connections, like Downloads, FTP, IMAP, or PHP
To see the status of your server, please refer to the Bluehost Server Status page.
How can you Troubleshoot Performance Issues?
The MySQL Slow Queries log can help determine which queries or scripts are unoptimized.
- Log in to your Bluehost Account Manager.
- Click Hosting in the left-hand menu.
The details of your hosting plan will be displayed.
- In the hosting details page, click the CPANEL button.
- Your cPanel will open in a new tab.
- Look for the section called Files and click the icon called File Manager.
- Once in the File Manager, on the upper left, click Settings.
- In the pop-up window, check Show Hidden Files, and then click Save.
- On the right side, locate the folder called tmp and navigate into that folder.
- Once inside the tmp folder, find a folder called mysql_slow_queries. Navigate inside that folder.
- Look for the files with recent dates, right-click on one of those files, and choose Edit.
- This will show the log details. Look for the logs where the Query_time is over 2 seconds. Queries that take over 2 seconds to execute usually need to be refactored.
These logs are generated to help troubleshoot database programming queries that are not optimized. Locate the query and database causing the problem, then optimize the query or queries by rewriting the query, creating an appropriate Database Index, repairing any damaged databases, etc. If you are not familiar with database programming, you may need to seek help from your web developer/programmer.
Simple Steps You Can Take to Fix Database Issues
You can perform this optimized routine on all of the tables in all of your databases.
Repair Your Databases
You can run a repair on all your databases.
- In the cPanel, scroll down to the Databases section.
- Click on the MySQL Databases icon.
- In the Repair section, choose a database to repair, then click the Repair Database button.
You can safely run a Check and Repair routine on all of your databases.
Optimize Your Databases
You can try to optimize all of your databases.
- In the cPanel, scroll down to the Databases section.
- Click the phpMyAdmin icon.
- On the next screen, choose a database name from the left side column.
- When the tables appear on the main screen, scroll to the bottom and tick the checkbox Check all.
- Use the drop-down menu next to the checkbox, then select the Optimize option.
Performing these two simple steps will not harm your important data, as these steps above are non-intrusive maintenance routines. As such, they may not fix the core issue as well. For instance, if you have severe data corruption, it can cause your queries to time out before they fully execute. Data corruption can be difficult to detect and repair. Database corruption can occur if a database operation does not completely succeed. Partial data is a form of corruption that can break Referential Integrity, causing your web application to fail as well. In short, the free Repair or Optimization routines that were just mentioned may not be sufficient to fix severe database corruption.
Advanced Steps You Can Take to Fix Database Issues.
- You can download your websites onto your own local machine and create a local web development environment to test your sites. You can then set Break Points in your scripts and watch your computer's CPU performance as you step through your stack and heap. Try to stress test your queries as well to see how they respond under a load.
- You can empty tables that are merely statistical tables. When viewing your tables, you can see how many entries each one has and how many KB or MB it is using. Sometimes tables get thousands or millions of entries that just log statistical types of data, like what searches people have done on your site or what people have logged in, etc. If you have very large statistical tables, it may help optimize your site if you remove the records or rows within those tables.
Warning: You should always consult the vendor of your scripts or your web developer before you attempt this - deleting any data in your database can potentially break your web application. - You can refactor your scripts so that heavy-duty aggregation or crunching is not all being done server-side. For example, you can rewrite your scripts so that they use Ajax calls, where your scripts are doing some of the CPU crunching in your JavaScript. This way, you are leveraging your client's CPU time instead of just your server's.
- You can ask our team to restore a courtesy system backup if we have one on file for you. The system backup is a snapshot of exactly how your site performed on a certain date. Doing a restore will not guarantee that your sites will be fixed, as your core issue may have existed at the time our System Backup Tool created your backup. Rolling back to a system backup will restore all of your sites and not just a portion. Feel free to contact us to see if we have a System Backup available.
- You can also ask us to reset your account completely. This will delete everything on your account, like it was on day one when you first signed up with us. Your account would be empty, containing no files, databases, email accounts, etc. This would ensure a fresh start so that you can reinstall all of your scripts with clean installations and clean databases. If you think that this is an option for you, please create backups of your data first.
Summary
This guide explains how to improve your website’s CPU performance and resolve database-related issues on shared hosting. It covers how Bluehost’s CPU Protection System ensures fair resource usage across accounts, what commonly causes performance slowdowns, and the steps you can take to identify and fix them.
You’ll learn how to use tools like the MySQL Slow Queries log to locate unoptimized scripts, perform simple database repairs and optimizations through cPanel, and apply advanced techniques such as refactoring queries, testing scripts locally, and cleaning up large tables. The article also highlights when to contact support for options like restoring backups or resetting your account for a fresh start.
If you need further assistance, feel free to contact us via Chat or Phone:
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.