July 06, 2008 | 01:05 PM  
Welcome

Don't have an account yet? You can create one, it is free, just click here

as a registered user you have some advantages like free downloads, comments and posting on our forums, depending upon this site's configuration and options.

 • •  Control Panel - Register - Login  • • 
Current Stable MDPro Lite 1.0821 Download
  Forum FAQForum FAQ   SearchSearch  UsergroupsUsergroups  PreferencesPreferences  Options forumOptions forum  Watched TopicsWatched Topics  Watched ForumsWatched Forums
Latest forum posts Latest forum posts  Log in to check your private messages Log in to check your private messages    Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
SpeedRacer
MD user level 2
MD user level 2


Joined: May 31, 2005
Posts: 23
Location: Houston, TX
Member
Post  Posted: Nov 19, 2007 - 03:57 PM Reply with quote Back to top
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
View user's profile
SpeedRacer
MD user level 2
MD user level 2


Joined: May 31, 2005
Posts: 23
Location: Houston, TX
bannato
Post  Posted: Nov 26, 2007 - 02:53 PM Reply with quote Back to top

Anyone?..... Bueller?

_________________
Greg
~`~`~`~`~
I race at www.hsarc.net
View user's profile
Display posts from previous:     
Jump to:  
All times are GMT + 13 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by MDForum 2.0.8© 2003-2007 MAXdev Team
Credits