Results 1 to 5 of 5
  1. #1

    Default Rotating Db Users

    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

  2. #2
    Join Date
    Jan 2004
    Posts
    66,385
    Blog Entries
    7
    Plugin Contributions
    81

    Default

    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:
    Code:
     define('DB_SERVER_USERNAME', 'my_db_username');
     define('DB_SERVER_PASSWORD', 'my_db_password');
    with the following, substituting your new database usernames and passwords in the $dbuser[]= and $db_pwd[]= lines:
    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
     *******************************************************************************/
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3

    Default Re: Rotating Db Users

    Hi,

    Could I modify the code to 10 mins and use 6 sql users - would that work?

    Thanks

  4. #4
    Join Date
    Jan 2004
    Posts
    66,385
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Rotating Db Users

    yes .
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5

    Default Re: Rotating Db Users

    That works great - thanks so much

 

 

Similar Threads

  1. Migrating Oscommerce users to Zencart Users
    By voodoo1967 in forum General Questions
    Replies: 1
    Last Post: 2 Jul 2009, 12:59 PM
  2. Redirecting google users to yourdomain/shop users that came to yourdomain.com
    By Zebra- in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 21 Apr 2009, 10:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR