Tip: If your host has a low user_max_connections

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
crashman79
Registered User
Posts: 1
Joined: Tue Jun 06, 2006 8:34 pm

Tip: If your host has a low user_max_connections

Post by crashman79 »

Here's something I had to cook up to keep my forums going. Lots of mods installed, and various other things using the same database for data-sharing. My biggest problem was the number of queries the main forum used, with all the mods installed... it was around 20-30 queries for the index. Rather than trying to pare down the mods, as I had just gotten it to the point where I was satisfied with the features and cosmetic look, I went hunting for a remedy to user_max_connections (an error I was getting a -lot- when more than 5 people were on the forums at the same time). This is what I ended up cooking up, using information from a phpbb.com knowledgebase article involving a 'question limit per hour' workaround.

I took that code and modified it to use a random username/password for the database, instead of a list of user/pass in sequence over the course of an hour.

Open your forum's config.php and replace

Code: Select all

      $dbuser='username'; 
      $dbpasswd = 'password';
with

Code: Select all

$dbuser_temp = rand() % 9; // randomize db username used for queries
switch ($dbuser_temp) 
{ 
   case 0: 
      $dbuser='username1'; 
      $dbpasswd = 'password1'; 
      break; 
   case 1: 
      $dbuser='username2'; 
      $dbpasswd = 'password2'; 
      break; 
   case 2: 
      $dbuser='username3'; 
      $dbpasswd = 'password3'; 
      break; 
   case 3: 
      $dbuser='username4'; 
      $dbpasswd = 'password4'; 
      break; 
   case 4: 
      $dbuser='username5'; 
      $dbpasswd = 'password5'; 
      break; 
   case 5: 
      $dbuser='username6'; 
      $dbpasswd = 'password6'; 
      break; 
   case 6: 
      $dbuser='username7'; 
      $dbpasswd = 'password7'; 
      break; 
   case 7: 
      $dbuser='username8'; 
      $dbpasswd = 'password8'; 
      break; 
   case 8: 
      $dbuser='username9'; 
      $dbpasswd = 'password9'; 
      break; 
   case 9: 
      $dbuser='username10'; 
      $dbpasswd = 'password10'; 
      break; 
}
I settled on 10 user/pass combinations to allow for more traffic later on. I figured if 6 users could max out one username, then in the (unlikely) event that we had 50+ simultaneous users I wanted to be covered.

I apologize if this has been covered elsewhere here, or if it's in the wrong forum for a tip. I tried using the search but kept getting a 0-byte reply from the form (Opera 8.5).

The knowledgebase article that has the original code that I modified is here: http://www.phpbb.com/kb/article.php?article_id=371
dataguru
Registered User
Posts: 39
Joined: Thu Dec 28, 2006 5:02 pm
Location: Oklahoma
Contact:

Re: Tip: If your host has a low user_max_connections

Post by dataguru »

This looks like an interesting workaround and I would like to try it.
Problem is, I don't see any way to add users to the board's mysql database. I've checked the host's account control panel as well as phpmyadmin and no cigar. Would I need to ask my host's tech support people to create them? or is there something I can do to create them?

Thanks,
Betty
moh.elmadany
Registered User
Posts: 441
Joined: Fri Nov 23, 2007 1:25 pm

Re: Tip: If your host has a low user_max_connections

Post by moh.elmadany »

i have 'max_connections_per_hour' daily :(

i will try this code
User avatar
RMcGirr83
Former Team Member
Posts: 22016
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Tip: If your host has a low user_max_connections

Post by RMcGirr83 »

Be forewarned, many hosts will frown upon this practice and may terminate your service. Just an fyi.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beer Image
Locked

Return to “2.0.x Support Forum”