To get around the DB user exceeded problem, it has been mentioned that we can create some kind of a loop script for multiple DB users so as to distribute the load. Can anyone tell me how to do that?
Thanks a lot
Printable View
To get around the DB user exceeded problem, it has been mentioned that we can create some kind of a loop script for multiple DB users so as to distribute the load. Can anyone tell me how to do that?
Thanks a lot
If you're having a "db user exceeded" problem, then your hosting account is slightly underpowered for your site. The *best* solution is to switch to a hosting company that doesn't impose unrealistically low restrictions on your account. (Some hosts will tell you that you need to "pay more" to get allowance for more queries ... but that's still marrying you to an underpowered solution, and lining the pockets of your hosting company instead of giving you better performance. Be wary of their upsell ploys.)
However, if you can't or won't change to a more solid hosting service, the following may help you:
1. Create 4 database-users for your database.
It's okay to use the same password for each if you wish.
Be sure to grant all 4 the same permissions to the same database.
2. Open your /includes/configure.php file and make this code change:
Around line 60 or so you have:Code:// define our database connection
define('DB_TYPE', 'mysql');
define('DB_PREFIX', '');
define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty
define('DB_SERVER_USERNAME', 'my_db_username');
define('DB_SERVER_PASSWORD', 'my_db_password');
define('DB_DATABASE', 'zencart');
Replace the following 2 lines:with the following, substituting your new database usernames and passwords in the $dbuser[]= and $db_pwd[]= lines:Code:define('DB_SERVER_USERNAME', 'my_db_username');
define('DB_SERVER_PASSWORD', 'my_db_password');
Code:/********************************************************************************
* The following code block alternates database users based on 15-minute segments
* It supports separate users for each 15-minute segment of a given hour
*/
// Enter your 4 database usernames here.
// If you have only two, then repeat them: first, second, first, second
$dbuser[] = 'username1';
$db_pwd[] = 'password1';
$dbuser[] = 'username2';
$db_pwd[] = 'password1';
$dbuser[] = 'username3';
$db_pwd[] = 'password1';
$dbuser[] = 'username4';
$db_pwd[] = 'password1';
// NO NEED TO DO ANYTHING IN THIS SECTION:
// calculate the current "minute"
$current_minute = date('i');
// calculate which "quarter of the hour" we're in
$db_user_active = (int)($current_minute/15);
define('DB_SERVER_USERNAME', $dbuser[$db_user_active]);
define('DB_SERVER_PASSWORD', $db_pwd[$db_user_active]);
//echo $db_user_active;
/**
* END OF rotating db-users code
*******************************************************************************/
Hi,
Could I modify the code to 10 mins and use 6 sql users - would that work?
Thanks
yes .
That works great - thanks so much