How to Tell When PHP or Mysql Processes are Killing Performa

I just had an issue with a Linode that I thought I'd ask for some advice on.

I have Drupal site that all of a sudden slowed to an unbearable trickle. Pages were taking literally minutes to load.

I checked the memory but nothing seemed out of the ordinary:

             total       used       free     shared    buffers     cached
Mem:           630        569         60          0         89        304
-/+ buffers/cache:        175        454
Swap:          255          0        255

I checked the memory (which I didn't save) but there were about 10 apache processes averaging about 4% MEM and 6% CPU as well as one mysqld averaging about 7% MEM and 5% CPU.

I tried pruning apache and mysql but nothing. The various logs in /var/log didn't indicate anything. After a couple of hours of playing around I discoverd that the sessions table in the database was about 10 times the size it had been the day before. The culprint was a 'single signon' module that was writing a couple hundred rows to the sessions table for every site visitor. Once I removed the module things went back to normal immediately. Mini-crisis averted.

My question is, 'Is there a way to tell that a PHP or Mysql process is responsible for slowing things down so drastically?' Or was there a better way to troubleshoot this?

2 Replies

You pretty much have to do the kind of detective work you described. One thing you didn't mention was looking at the MySQL logs. Often the general query log is not enabled, but binary logs are, which you can view with mysqlbinlog.

Thanks Vance. I appreciate the feedback.

I'm turning on the slow mysql log so if I have similar problem in the future I will have some history there.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct