I have a web application with a mysql db master and four slave dbs. I want to process all (or almost all) of the read-only (SELECT) queries from subordinates. Our load balancer automatically sends the user to one of the slave machines, since they also use Apache / PHP and serve web pages. I use the include file to configure the database connection, for example:
$Host = "10.0.0.x";
$User = "xx";
$Password = "xx";
$Link = mysql_connect( $Host, $User, $Password );
if( !$Link ) )
{
die( "Master database is currently unavailable. Please try again later." );
}
$Host_Local = "localhost";
$User_Local = "xx";
$Password_Local = "xx";
$Link_Local = mysql_connect( $Host_Local, $User_Local, $Password_Local );
if( !$Link_Local ) )
{
$Link_Local = mysql_connect( $Host, $User, $Password );
}
$Link $Link_Local SELECT. , . db , $Link_Local = mysql_connect() 30 , script. , (- ).
- , PHP? , mysql_connect 2-3 ?
. mysql_connect, .