Intermittent Server Error – MySQL or Apache? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, mysql, php, performance, 500-error.
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?
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.
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?
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.