Disabling resource intensive features based on server load

Started by Ben_S, March 14, 2006, 04:33:04 PM

Previous topic - Next topic

qtime

yes it's working at 1.1.2

don't be afraid if your serverload is 10 and your forum is fast.

Dzonny

Quote from: qtime on January 01, 2011, 01:16:26 PM
yes it's working at 1.1.2
U mean 1.1.12?  :D

Quote from: qtime on January 01, 2011, 01:16:26 PM
don't be afraid if your serverload is 10 and your forum is fast.
Serverload is currently below 1.5 for each 5, 10 and 15min. As i can get, it is fine, right?

qtime

yes working at 1.1.2 and serverload is very nice.
To protect overloading of the server, you could setup search to 5 for example. If the server is higher loaded, it will avoid searching and serverload could drop.

青山 素子

Quote from: Dzonny on January 01, 2011, 01:00:44 PM
This is really work?
It would be very helpflu to have somthing like this in admin panel.

Bad idea. Most users would be somewhat clueless on the settings and could easily enter them in low enough that they would effectively shut down their forum. The only way to recover would be to edit the settings directly in the database. Someone who didn't know enough to use the settings correctly would likely not know how to make the necessary database edits to fix the damage.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Dzonny

Hm right, but i just have my own forum on vps, and dont plan any clients there for now.

Aleksi "Lex" Kilpinen

Actually, 2.0 has this built into the Admin CP, as part of the server settings... ::)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

青山 素子

Quote from: LexArma on January 01, 2011, 02:15:50 PM
Actually, 2.0 has this built into the Admin CP, as part of the server settings... ::)

Indeed it does (Configuration -> Server Settings -> Load Balancing), albeit with a red warning. I recall a push to get many of the "hidden" settings added to the UI.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Dzonny

Hm, ok, is it the same system as posted here in the first post?
Im using 1.1.12, and i will try it to see if its working.

青山 素子

Quote from: Dzonny on January 01, 2011, 06:33:57 PM
Hm, ok, is it the same system as postet here in forst post?
Im using 1.1.12, and i will try it to see if its working.

Yes. Be careful, you can make your forum unusable.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Paracelsus

Sorry to push this old thread up, but I want to use this to disable the feature that allows guests to browse the forum abobe a certain load. Would it be possible to do it and if so what is the parameter/function?

青山 素子

As far as I know, that is not currently an option. The load options allow one to disable certain high-load-causing features, but browsing is not one.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


emanuele

In 2.0 the threasholds are:
Threshold to disabling automatic database optimization
Threshold to disabling search
Threshold to disabling all unread topics
Threshold to disabling unread replies
Threshold to disabling showing user posts
Threshold to disabling the forum completely
Details: Load Balancing.

The last one seems what Paracelsus is looking for, but it affects all the users, not only guests.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

青山 素子

Quote from: emanuele on July 18, 2011, 05:45:58 PM
Threshold to disabling the forum completely
Details: Load Balancing.

The last one seems what Paracelsus is looking for, but it affects all the users, not only guests.

Exactly. That one shouldn't be used as a default. It effectively does the same thing as setting maintenance mode to 2, which makes the forum inaccessible to everyone, even admins.

Potentially, the system could be extended to allow this, but I'm not sure how big a benefit would be provided since you'd still have to allow logins, which would increase load anyway.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Paracelsus

Well, since we are dedicated to a sports, mainly football (soccer) club, the loads tend to peak in specific periods, ie, during the club's football matches. In our experience, disabling browsing to guests in these couple of hours allows the forum to become much more responsive and faster than without this option.

Paracelsus

The only function I can find on smf_settings.php that might do the trick is this one: allow_guestAccess, but Subs-Auth has the KickGuest function also.

Could this actually work?
REPLACE INTO smf_settings
   (variable, value)
VALUES ('loadavg_enable', '1'),
   ('loadavg_allow_guestAccess', '40.0');


Subs-Auth.php has this piece of code:
// Kick out a guest when guest access is off...
function KickGuest()
{
global $txt, $context;

loadLanguage('Login');
loadTemplate('Login');

$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];

$context['sub_template'] = 'kick_guest';
$context['page_title'] = $txt[34];
}


Would it make sense to be like this:
REPLACE INTO smf_settings
   (variable, value)
VALUES ('loadavg_enable', '1'),
   ('loadavg_KickGuest', '40.0');

Paracelsus

Ok, maybe the above isn't such a good solution after all...

What about this one: install this MOD - High Server Load Warning (http://custom.simplemachines.org/mods/index.php?mod=2699) and then on index.template.php replace this:

$load = sys_getloadavg();
if ($load[0] > $modSettings['amount_server_load_check'] && !empty($modSettings['enable_server_load_check'])) {
    echo '<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/hslw.js"></script>

<div id="topbar">
<table width="100%">
<tr>
<td width="99%">
', $txt['text_server_load_check'], '&nbsp;&nbsp;&nbsp; </td><td width="1%"><a onclick="closebar(); return false"><img style="float: left" src="', $settings['images_url'], '/icons/hslw-close.gif" border="0"></a>

</td>
</tr>
</table>
</div>';
}


with something like this:
$load = sys_getloadavg();
if ($load[0] > $modSettings['amount_server_load_check'] && !empty($modSettings['enable_server_load_check']))
{
require_once($sourcedir . '/Subs-Auth.php');
return 'KickGuest';
}


???

Paracelsus

So, in the end, it was even easier and simpler. This worked for me:

Put somewhere in Index.php between the if's this piece (I've put after the line "// Is the forum in maintenance mode?"):
$load = sys_getloadavg();

in Index.php turn this:
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'smstats', 'help', 'verificationcode'))))
{
require_once($sourcedir . '/Subs-Auth.php');
return 'KickGuest';
}


into this (the load 15 is just an example that can be adjusted to whatever value people want to):
// If guest access is off, a guest can only do one of the very few following actions.
elseif ((empty($modSettings['allow_guestAccess']) || ($load[0] > 15)) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'smstats', 'help', 'verificationcode'))))
{
require_once($sourcedir . '/Subs-Auth.php');
return 'KickGuest';
}

humbleworld

Can I use this option for our VPS? Memory is 1.2 GB. Bandwidth is 3,500GB. Space is 60GB.

Arantor

...it's built into SMF since 1.1 and even has the Load Balancing page in the admin panel since 2.0 RC2...

Advertisement: