Page Index Toggle Pages: [1] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) [YaBB2.1] Limit Concurrent Users V1.0b (Read 17098 times)
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
[YaBB2.1] Limit Concurrent Users V1.0b
Feb 12th, 2007 at 9:28am
Print Post  
Limit Concurrent Users Y2.1

Version 1.0b beta

Languages:
Dutch, English (Spikecity)
German (JetLi)

This mod sets a hard deck on the amount of concurrent users on a forum (read: simultaneous perl processes), to avoid bringing a server down due to excessive hammering on the script.
The code keeps track of the started processes by increasing a counter value in a one line file in /Variables, called concurrent.db, and decreasing this value again on exiting the script.
As soon as the value reaches the hard deck set in the Flood/Security center the script diverts to a low load exit, only displaying a message telling the forum has reached max users.
After the number of users decreases the forum comes back to original operation.

Restrictions
As the correct functioning of this code is based on a clean exit of the script it could happen that the counter does not completely reset on a script crash.
To avoid the counter from overflowing there is a small check in Board Index that resets the counter if the number of connections is higher then the number of users online.
Also in Admin Center a Clear online log will reset the connection counter to zero.
If the settings are not saved the hard deck is set to 500 concurrent connections.
The Admin Center does not allow the value to be set higher then 10000 connections (which is far beyond a DDoS attack)
The script does not take into account what a user is doing if the hard deck is reached, so it could happen that posting of a message results in the overload message and resulting in loss of the text typed.

Installation
Apply the mod, upload the changed YaBB.pl, Subs.pl, Admin.pl, Admin.lng, BoardIndex.pl
Upload Concurrent.lng in the correct language dir

Testing
Go to admin center -> Flood/Security and set the value for concurrent to -1
Now go to your forum and you should get the low load message telling you the forum has reached it's max concurrent users.
Go back to admin center and set the value anywhere between 50 and 500.
Monitor your site and if users start complaining that this error comes too often, increase the value.

Version History
1.0
First release

1.0a
- Made board index counter fix relate to $totalusers instead of $numusers (Thanks Zoo)
- Added German version (Thanks JetLi)

1.0b
- Changed inclusion of concurrent.db to a file read to avoid corruption (please delete any old concurrent.db before using this version)

Download link: Click here
« Last Edit: Feb 22nd, 2007 at 12:32pm by Spikecity »  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Jeff
God Member
*****
Offline


There are no bugs there
are only features

Posts: 2552
Joined: Jan 14th, 2005
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #1 - Feb 12th, 2007 at 9:53am
Print Post  
Hi Ron
that a cool mod, and useful for YaBBServer 2 in the future.  8)
  

greetings
Jeff
Back to top
WWW  
IP Logged
 
Outumuro
God Member
*****
Offline


Publisher - YaBB Toolbar

Posts: 569
Location: Los Angeles
Joined: Apr 14th, 2004
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #2 - Feb 12th, 2007 at 10:55am
Print Post  
Okay... Birthday Boy has been tickling that extra neuron! Wink

Great idea Ron!  This could potentially be very helpful for those user admins that have certain host providers complaining about high CPU usage.

Nice one. Wink
  


Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #3 - Feb 12th, 2007 at 10:57am
Print Post  
Quote:
Hi Ron
that a cool mod, and useful for YaBBServer 2 in the future.  8)

Thanks JetLi,
Actually I wrote this one because I do some custom work for a super high traffic YaBB2.1 and a guy running the server being over protective of his server.
Just to assure him I can limit the amount of concurrent perl sessions running I is happy again Wink
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #4 - Feb 12th, 2007 at 11:03am
Print Post  
Outumuro wrote on Feb 12th, 2007 at 10:55am:
Okay... Birthday Boy has been tickling that extra neuron! Wink

Great idea Ron!  This could potentially be very helpful for those user admins that have certain host providers complaining about high CPU usage.

Nice one. Wink

It's just too bad that there isn't a universal env variable within perl that returns the number of perl processes running, or the mod would probably be reduced to only a few lines.

"Weak" point for this mod is that is has to keep track of connections using a flatfile database (one line only), meaning an extra file open/close.

Good thing for this mod compared to the Guardian is that it is ultra light, barely loading up stuff and not even bothering to make an entry in the error log.

I've hammered a little on my test forum and the CPU load barely changed Wink
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Jeff
God Member
*****
Offline


There are no bugs there
are only features

Posts: 2552
Joined: Jan 14th, 2005
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #5 - Feb 12th, 2007 at 3:25pm
Print Post  
Hi Ron
here a german translation.

Code
Select All
<edit file>
Languages/German/Admin.lng
</edit file>

<search for>
'9' => "Transparenter Bildhintergrund des Codes ?",
</search for>

<add after>
'19' => "Anzahl der gleichzeitigen Online Benutzer (Perl Prozesse) beschränken auf",
</add after> 



German/Concurrent.lng
Code
Select All
###############################################################################
# Concurrent.lng (Limit concurrent processes text definitions)		    #
###############################################################################
# YaBB: Yet another Bulletin Board							  #
# Open-Source Community Software for Webmasters					 #
# Version:	  YaBB 2.1								    #
# Released:	 November 8, 2005							  #
# Distributed by: http://www.yabbforum.com						#
# =========================================================================== #
# German Translation for this file by Jet Li and ThM.				 #
# =========================================================================== #
# Copyright (c) 2000-2005 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by: The YaBB Development Team						  #
#		  with assistance from the YaBB community.			     #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com		#
#		   Your source for web hosting, web design, and domains.	   #
###############################################################################

$conncurlngver = 'YaBB 2.1 $Revision: 1.2 $';

%conn_txt = (
'error' => "Das Forum hat die maximale Anzahl gleichzeitiger Benutzer erreicht. .... Bitte kommen Sie später zurück!",
);

1; 



German_Du/Concurrent.lng
Code
Select All
###############################################################################
# Concurrent.lng (Limit concurrent processes text definitions)		    #
###############################################################################
# YaBB: Yet another Bulletin Board							  #
# Open-Source Community Software for Webmasters					 #
# Version:	  YaBB 2.1								    #
# Released:	 November 8, 2005							  #
# Distributed by: http://www.yabbforum.com						#
# =========================================================================== #
# German Translation for this file by Jet Li and ThM.				 #
# =========================================================================== #
# Copyright (c) 2000-2005 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by: The YaBB Development Team						  #
#		  with assistance from the YaBB community.			     #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com		#
#		   Your source for web hosting, web design, and domains.	   #
###############################################################################

$conncurlngver = 'YaBB 2.1 $Revision: 1.2 $';

%conn_txt = (
'error' => "Das Forum hat die maximale Anzahl gleichzeitiger Benutzer erreicht. .... Bitte komm später zurück!",
);

1; 

  

greetings
Jeff
Back to top
WWW  
IP Logged
 
Zoo
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 290
Joined: Jan 22nd, 2003
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #6 - Feb 12th, 2007 at 8:56pm
Print Post  
Code
Select All
	## fix the concurrent counter to match number of users online if the number of connections is higher ##
	if ($max_conn > $numusers){ &concurrent("fix",$numusers); } 



2 remark
- $numusers contain the online logged in users
- replaced with $totalusers is far better, but isn't perfect, becasue online log storing 1 entry per ip/user only
  
Back to top
 
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #7 - Feb 12th, 2007 at 9:28pm
Print Post  
Zoo wrote on Feb 12th, 2007 at 8:56pm:
Code
Select All
	## fix the concurrent counter to match number of users online if the number of connections is higher ##
	if ($max_conn > $numusers){ &concurrent("fix",$numusers); } 



2 remark
- $numusers contain the online logged in users
- replaced with $totalusers is far better, but isn't perfect, becasue online log storing 1 entry per ip/user only

I know it is far from perfect, but it is the only brake I have to prevent the connections counter to go ballistic on script crashes.
On a crash the connection counter is not lowered, so this means it keeps ghost connections alive.

I think $totalusers is better indeed, as at least the counter will not exceed the total guests+bots+members.

But if you have some brilliant idea I'm all ears Wink
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0
Reply #8 - Feb 13th, 2007 at 10:06am
Print Post  
New version behind the link in the first message

Enjoy and test please.
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Jeff
God Member
*****
Offline


There are no bugs there
are only features

Posts: 2552
Joined: Jan 14th, 2005
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #9 - Feb 13th, 2007 at 10:55am
Print Post  
Hi
thnx for update.

in ModList.pl a $ missing.

     push (@installed_mods, "$conn_lim");
  

greetings
Jeff
Back to top
WWW  
IP Logged
 
Zoo
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 290
Joined: Jan 22nd, 2003
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #10 - Feb 14th, 2007 at 12:17pm
Print Post  
Quote:
This mod sets a hard deck on the amount of concurrent users on a forum (read: simultaneous perl processes), to avoid bringing a server down due to excessive hammering on the script.

I think this isn't good idea to prevent crash.

To a very base approximation
The limit on the number of simultaneous requests, concurrent connections that will be served is server directive. Normally, the connection between a browser and a Web server is only valid for a single request/response pair. The server closes the TCP connection after each response.  
(Now I don't care with keep-alive, max thread per connection, because yabb do a simple thread.)
Once the max connections number is reached, new connections are not allowed. You script never increse over this server parameter.

In a normal site when run 500 (10000 Shocked) yabb thread at same time?
I have high traffic yabb in intranet. We have ~ 15000 post per month.
Average users online  400-600. (online setting 15 min.)
I to look at my online log: max 8-10 logentry per second, every run time less 1 second.
Thus concurrent connections (yabb perl thread) ~ 10.

Quote:
But if you have some brilliant idea I'm all ears Wink
Have not - on this point Wink
« Last Edit: Feb 14th, 2007 at 1:31pm by Zoo »  
Back to top
 
IP Logged
 
Larian
Senior Member
****
Offline



Posts: 316
Location: Leipzig
Joined: Oct 22nd, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #11 - Feb 14th, 2007 at 2:51pm
Print Post  
Installs and works perfect! Good idea!

Thanks!
  
Back to top
 
IP Logged
 
MF-B
Senior Member
****
Offline



Posts: 410
Location: Moscow
Joined: Apr 11th, 2006
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #12 - Feb 14th, 2007 at 6:16pm
Print Post  
A... for what need write number of connection in .db file if this value read from log file?
  
Back to top
WWW  
IP Logged
 
Larian
Senior Member
****
Offline



Posts: 316
Location: Leipzig
Joined: Oct 22nd, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #13 - Feb 15th, 2007 at 7:08am
Print Post  
Today i got the message "Too many users". To log in i wrote a lesser value in concurrent.db. After that i logged in and nobody was online!
Seems that the mod has an error!

Larian
  
Back to top
 
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: [YaBB2.1] Limit Concurrent Users V1.0a
Reply #14 - Feb 16th, 2007 at 6:48pm
Print Post  
MF-B wrote on Feb 14th, 2007 at 6:16pm:
A... for what need write number of connection in .db file if this value read from log file?

It's not read from the log, it is only corrected if the db value is higher then the online log total (only to prevent this counter from ever increasing in case a script is not ended correctly)
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint