Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been having a pretty annoying problem with a website I work on, and I'm having difficulty saying whether the problem lies with PHP, Apache or MySQL.

System setup: cloud hosted solution (moved from dedicated servers last year) with two VMs: Apache VM and MySQL VM. The Apache VM has 1 core (2GHz),4GB RAM, the MySQL VM has two of the same core, 8GB RAM. The site doesn't get a large volume of traffic, due to its nature.

Problem: when viewing an account report, sometimes the page times out and fails to load. The page runs a lot of queries, and returns quite a lot of data (mostly text, still <1MB), so my first thought was a problem with MySQL. I've monitored the server during these time-outs, and nothing stands out. I've also run the queries isolated (both direct to DB and through a test page), and they run fairly quickly.

Apache also shows nothing out of the ordinary, and I never get PHP timeouts or memory errors. I've also run this on local systems, without experiencing the same issue (though these systems obviously have no competition, unlike the live box.

The strangest thing is that when I get this problem on one browser (say, Firefox), I can't load any other pages on the site through Firefox, but I can through another browser (say, Chrome). It suggests there's some kind of connection or queue issue with the server and that session?

Can anybody give me any idea what they think could cause something like this? Or is there any more info I can give you to help?

Thanks

share|improve this question
    
First of all I'd inspect the apache error and access logs. I had the same similar issue twice not too long ago, the first time apache was randomly seg-faulting and required a restart (Not a graceful one but a full on "kill it dead and resurrection") the second time was harder as it was php with the fault being memory allocation issues. –  Dark Star1 Jan 23 '13 at 9:57

3 Answers 3

Have a look at New Relic newrelic.com. It is made specifically for this. When you sign up you get a free trial of Pro ($150 per server). It allows you to monitor mysql, php, apache, and the whole system. It shows you graphs and other useful features that can be used at debugging the system. It can show where the bottlenecks are in you application.

I use it on a few of my servers and it works great at monitoring the performance of each.

share|improve this answer

There are multiple things going wrong here - and potentially multiple causes, not least the performance thing.

Blaming PHP, MySQL and Apache is not a very constructive way to approach the problem.

Apache also shows nothing out of the ordinary, and I never get PHP timeouts or memory errors

What does Apache show for these requests? Have you confirmed that PHP is logging errors? What about your application logging?

when I get this problem on one browser (say, Firefox), I can't load any other pages on the site through Firefox, but I can through another browser (say, Chrome).

You've not provided any details on what's happenning on the browser / network. Have you only demonstred this with Firefox failing and Chrome succeeding? If so, have you tried enabling SPDY in Firefox? Have you tried tracking the request with a packet monitor to see which end is closing the conection / how the connection is closed?

share|improve this answer

Two things to try.

First, turn on and monitor the mysql slow query log. This example sets the slow query time to 5 sec, you can play with this until you get information that is helpful. This is typically /etc/my.cnf, with lines under [mysqld]:

log_slow_queries        = /var/log/mysql-slow.log
long_query_time         = 5
log-queries-not-using-indexes

Next, when you encounter the problem in firefox, clear your cache. If you're using chrome, try doing the testing with an incognito window, and see if that makes a difference.

share|improve this answer
    
There's a huge number of reasons why 5 is much too long a threshold. Really this should be 0 (but a literal zero will disable logging in older versions of MySQL). –  symcbean Jan 22 '13 at 13:06
    
@symcbean: I don't disagree, but if he's doing reporting that's probably a good starting place. –  chris Jan 22 '13 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.