Ok, I know you can simply write a script that detect if a database is up or not, and then reconnect to another like so:
$con = mysql_connect($host, $user, $pass);
if (!$con) //try to connect to another database now
My question is, sometimes one of our databases is overloaded, it is still responsive but simply waits to connect because the load is to high. So the connect script just keeps loading, because the database is there. It just will never stop loading the php script because the database is alive, but is to overloaded to connect fast, so it just waits untill the load passes and then connects after its done.
Is there any way to modify it, where it'd say, if it can not connect within 5 seconds, for instance (because its overloaded) then try connecting to a different one.
if ( can't connect within 5 seconds to this database ) do something else?