We have a MySQL server which handles queries for 4 web servers. On the server we have max_connections set to 1600 (400 connections per web server). Anyway, this usually works great - and our app gracefully gives the users a ‘sorry’ message if the max_connections has been exceeded.
The problem we have is that if for some reason the web servers are making a lot of expensive queries (this just happened when our sql cache mechanism failed - no queries were cached!) then the server gets really overloaded. And because the max_connections has not been met - it takes on even more queries, even though it’s already really stressed.
So, my question is - is there any way to make MySQL refuse connections based on how high it’s load is (and not simply based on the number of current connections) ??
Or are there any clever tricks at the app level to do this? (we are using PHP).
Thanks!
Hamish