Tips to Decrease CPU Usage
CPU time, also known as processing time, is when the central processing unit (CPU) is used to process instructions in a program.
This contrasts with the system that is waiting for input or output operations.
Your web pages are constructed and sent by the server’s CPU, whether the pages are static or dynamic.
More CPU resources are used when your web pages are served dynamically from a script or database. This is because the visitor’s pages must be processed in accordance with the data.
It loads the web template, gets the data for that specific page from the database, runs any modules or plugins you have installed and serves the page to your visitors.
The CPU’s time is limited and shared by all websites on a web server. If one site uses the CPU in excess, It deprives other websites on the same server and even if the website is hosted on the server on its own, the website’s performance will decrease if it uses too much CPU and users won’t be served properly. In the worst-case scenario, Your server might crash and your website will go down.
To avoid this, web hosts monitor the CPU usage of their site with shared web hosting plans.
This avoids issues when a website is using CPU time too much and has adverse effects on other websites.
To reduce CPU usage on your server, there are some rules you can follow:
- Third-party web apps should be upgraded to the most current stable release, such as WordPress, Joomla, Drupal, or any other management software or scripts on your account.
- This applies to your add-ons and plugins as well – ensure they are up-to-date.
- Make sure your website is clean. Remove any outdated or inactive add-ons or plugins.
- If you developed your own scripts, try lessening the number of PostgreSQL/MSSQL/MySQL queries and adjusting them to reduce processing time.
You must first determine the cause of high CPU usage in order to reduce it on your hosting account. This may seem difficult.
This is especially true if you are using third-party web apps. These could include blogs or content management systems or forums that you haven’t developed yourself.
There are some things you can do to help you get started and then eventually fix the problem.
If you have multiple websites, find the website most likely to be the cause of high CPU usage
If you have more than one website in your account, it is worth determining which one is most visited and drives the most traffic.
This is why CPU usage is so high. Your CPU can be affected by simultaneous hits to all your websites.
Visit Live Stats You can find out which subdomains and domains are generating the most traffic in the Bandwidth Stats section and consider moving it to a different host or optimizing it.
Look deeper to identify CPU-intensive files.
Once you’ve determined which website generates the most traffic via Bandwidth Stats, visit the Live Stats Traffic Section.
The traffic statistics for the subdomain or domain can be viewed at the moment.
Find the file that brought you the most traffic. This can be found by looking at the Total URLs per Kbytes table and Top 10 apps.
Find any PHP/CGI script files. It could be responsible for high CPU usage if it generated a lot of traffic. If so, consider optimizing it.
Identify malicious visitors
Check out the monthly statistics of your subdomain or domain. Look for the visitors that brought in high amounts of traffic and analyze their traffic patterns, as you might be a target for a DOS or a DDOS attack. Once you identify a malicious visitor, block their IP address/ range.
The list can be found at Top 10 of XX Sites by Kbytes. It will return a hostname, an IP address, or a domain.
Once you have identified the host, block them from your website.