Solved

High CPU usage

Posted on 2011-02-10
8
579 Views
Last Modified: 2012-05-11
Hey I'm new to server administration and I recently moved my site to a VPS everything was fine for a few weeks, but the site has begun to go down regularly.  At these times when I check my VPS resources server usage is usually 90%+.  The entire site is written using php, javascript, and AJAX.

Could the CPU usage be causing the site to go down? and if so, do you have any tips on reducing CPU usage?

Thanks
0
Comment
Question by:Frontstart
8 Comments
 
LVL 20

Expert Comment

by:edster9999
ID: 34866434
Remember you share the CPU with other people.
Two things can cause this issue.  

If your CPU time is hitting the max then this will slow your site(s) down and may cause it to stop responding.  Drop to the shell and run 'top' to see what is running fast.
This may be a web page that is getting into some sort of loop and using all the cpu time or it may be someone messing (hacking ?) with your site.

The other thing can be in the boxes cpu is running too hot (too busy).  If you do not see your CPU time as very high call the tech support and ask them what is going on.  It could be someone sharing your VPS is getting hacked / DDos'ed and that is impacting your site.
0
 
LVL 13

Assisted Solution

by:LinuxGuru
LinuxGuru earned 250 total points
ID: 34867328
Yes, as mentioned above you need to monitor the process running. Enter the following command after logging to your server via SSH.

top -c

Now you can see the process running and memory utilization.

While in top -c you can issue the following command to check the things causing high memory and processor usage.

Hold shiftkey + m

Hold shiftkey + p

You can then kill or suspend that accounts causing high server load.
0
 

Author Comment

by:Frontstart
ID: 34872339
After running top -c, It looks like two httpd processes from the apache server are at the top of the list at around 26% each, everything else is ~1%.  Those were the highest readings I could get before it went down.

Any idea what the issue could be? (restarting the server brings the site back up for a while but it just goes down again)
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 20

Expert Comment

by:edster9999
ID: 34873540
It could be pure load.  You have too many people to run on one VPS.
Look at your logs and work out how many hits per hour you get.
If that is the case then you need to get another VPS server or a dedicated server (or two).

If it is not high then you have bad code that is getting stuck in loops.
If this just started happening did you update the code or change anything ?

0
 

Author Comment

by:Frontstart
ID: 34873976
The site is still being developed so new code is added everyday, but our users also doubled around the time this started happening.  What type of numbers would be too much for a VPS?
0
 
LVL 20

Accepted Solution

by:
edster9999 earned 250 total points
ID: 34878042
There is no set answer to that.

You dont need to answer these questions just think about them -
How much cpu does each page of your site take to display?  A simple static text only site would be far different to a site that is looking up lots of info from databases for each page.
How busy is the box?  Remember you share it with other people.  If you are sharing it with 20 high users who all run multiple sites then it will run differently to it hosting 10 light users. Maybe talk to the hosting company and get their view on this.  They could look at your usage compared to others on the same box and see how it looks.

A good idea would be to install the same code on a pc (not a public hosted one just a pc on your network) and run jMeter or similar on another box and try different numbers of users (jMeter can pretend to be multiple users all using the site).
Maybe ramp up the users over time.  20 minutes of 10 users, then 20 minutes of 50, then 20 minutes of 100 etc until you kill the code / box.
This does not give you the final figure of number of users you can run as the test box will be different to the real box but it will show you if your code 'leaks' memory or cpu usage over time and will give you some idea about how it scales up.
Oh and DO NOT do testing like this on your live box as you will probably kill the VPS and your hosting company will ban you :(
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 35414457
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The 6120xp switches seem to have a bug when you create a fiber port channel when you have a UCS fabric interconnects talking to them.  If you follow the Cisco guide for the UCS, the FC Port channel will never come up and it will say that there are n…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now