Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache using all CPU anc causing server hang

Status
Not open for further replies.

andreaspom

Programmer
Dec 8, 2014
5
CY
Hello,

I apologize if something similar has been asked already. I went through the forum and i didn't see anything.

I have a dedicated server with the following specs

HDD 1500 GB SATA II-HDD 7.200 rpm
CPU AMD Athlon II X4 605e, Quad-Core
Template CentOS 6 - Plesk 10 - RAID 1 On the server I have 3 websites all of them in Wordpress. One of them receives very high traffic (up to 4 million views per month) , the other two receive insignificant traffic (less than 1000 views per month). Until a couple of months ago, the server could handle anything. There were days we would receive 60-70000 visits and 250k views with no problem at all. About 2 or 3 months ago something changed. Every time we have increased traffic (note: the website is a sports website. So on Saturdays or Sundays when there's a match traffic increases) Apache uses all CPU, load average goes up to 100 (!!!), the server hangs and sometimes "dies".


I do not remember changing anything in configuration and I could not determine whether it is a piece of bad code that might be causing it. I am trying to figure out what exactly is causing Apache to require all that CPU and since I am not a server configuration expert (I am a programmer/web developer) I am looking for some help. I have already enabled server status (anyone interested in seeing please let me know. ) but i do not know how to read it and understand it, so I am looking for answers there too. Could this be an error in configuration or something else?? I would be obliged if someone offered some guidance or would be willing to take a look.

I am also attaching my terminal when top is run, but not at peak hour. Maybe an expert's eye will see something off.


Andreas

2j1o39k.png
 
 http://files.engineering.com/getfile.aspx?folder=cc8e8834-621d-4bec-b996-600a3dfdc819&file=loadaverage.png
'top' can be a useful tool for someone "on the ground" when you can 'watch' the changes, but as a screenshot it is somewhat less than useful, particularly when it is not especially relevant to the actual problem, ..."but not at peak hour." what it shows AT peak times is more useful. However I would suggest that MySQL 'hanging' may be the real culprit.

I have one server (out of five) with similar problems and it is caused by MySQL/PHP/Apache "running out of space" to store sessions.

check /var/lib/php/session/ for any that are significantly 'older' than the session time out (usually 20 mins) and delete them.





Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hello ChrisHirst and thanks for the reply.

Well all the sessions in the folder you have suggested are significantly older than the session time out. I am attaching a screenshot of the folder just in case I didn't understand what you meant. Should I delete all those files?

 
 http://files.engineering.com/getfile.aspx?folder=31228d9e-95c8-4a5f-8b5a-2ebebab3bfb5&file=session.png
yep delete them

Do not try rm -f * because it WILL only result in a "command too long"

I have;

Bash:
find /var/lib/php/session/sess_* -mmin +45 -exec rm {} \; > /dev/null 2>&1

in the root crontab that runs every six hours and deletes any that were modified more than 45 minutes before. The problem seems to be related to 'bot' type user agent activity (search engines or harvester types) because they open a new session on each and every access, but unlike browsers, have no means of closing them, so they just 'pile up' and some never seem to time out.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hey again Chris,

Ok so i ve used that command you provided me with. Let's see if that makes a difference!

Thank you so much for taking the time to reply and try to help.

One more question: how do I set up a cron to run that every six hours?

Thanks,

Andreas
 
ok so i did a bit of research my self. I used 360 * * * * find /var/lib/php/session/sess_* -mmin +45 -exec rm {} \; > /dev/null 2>&1

I guess that should do the trick!

Thanks again,

Andreas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top