| Author |
Message |
SpeedRacer
MD user level 2


Joined: May 31, 2005
Posts: 23
Location: Houston, TX
Member
|
 Posted:
Nov 19, 2007 - 03:57 PM |
|
| Post subject: Multiple Users for MySQL in the config file? |
A while back I ran across a message here in the forum for multiple users/passwords in the md-config file.
Can someone point me to it or post it back, as I cant seem to locate it in searching.
The problem that I am trying to overcome is this, and this work around works on several other PHP based sites that rely heavily on MySQL.
Abour every 2 weeks, my site gets heavily spidered by the search engines.
When those spiders run, it always max's out the MySQL cap within a given period.
The current max_questions resource is set at 50000.
Once that's hit, the site starts throwing "session initialization" errors.
A workaround that someone posted a while back basically had several users/passwords setup i the config file, and each new db query would use the next ID, then the rotation through the IDs would continue. So in essence if 1 ID had a max resource cap of 50K, then 4 IDs would have a theoretical cap of 200K, so in essence the site would never hit the limit.
I found a script for ZenCart that rotates them every 15min, but I cant seem to get it to work in MDPro. The ZenCart snippet is below if you want to see what I am talking about.
Thanks in advance for your thoughts and responses.
G
| Code:
|
// define our database connection
define('DB_TYPE', 'mysql');
define('DB_PREFIX', 'mystore_');
define('DB_SERVER', 'localhost');
// define('DB_SERVER_USERNAME', 'my_username');
// define('DB_SERVER_PASSWORD', my_password');
/********************************************************************* ***********
* 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[] = 'my_username1';
$db_pwd[] = 'my_password';
$dbuser[] = 'my_username2';
$db_pwd[] = 'my_password';
$dbuser[] = 'my_username3';
$db_pwd[] = 'my_password';
$dbuser[] = 'my_username4';
$db_pwd[] = 'my_password';
// 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
********************************************************************* **********
/
|
|
_________________ Greg
~`~`~`~`~
I race at www.hsarc.net |
|
|
 |
SpeedRacer
MD user level 2


Joined: May 31, 2005
Posts: 23
Location: Houston, TX
bannato
|
 Posted:
Nov 26, 2007 - 02:53 PM |
|
|
Anyone?..... Bueller? |
_________________ Greg
~`~`~`~`~
I race at www.hsarc.net |
|
|
 |
|
|
| |