My server has a max_connections value of 400 and a max_user_connections of 250. Since I am always connecting with the same user name, my effective max_connections is 250 instead of 400. To solve this, I though to connect with one username 50% of the time, and another username 50% of the time:
if(mt_rand(1,2) == 1){
$con = mysqli_connect(DB_SERVER, DB_USER_1, DB_PASS) or die(mysql_error());
}
else{
$con = mysqli_connect(DB_SERVER, DB_USER_2, DB_PASS) or die(mysql_error());
}
My question is, are there any downsides to doing this relating to the fact that the same person might alternate back and forth between different users? Or is this not a problem as the previous connection is "forgotten" and when the user refreshes we are starting a new connection and there is no relation to what user he/she connecting with last page refresh.
In general, is there a better way to deal with this?