SMF 1.1 introduces a new feature.
This new feature can be used to disable certain other features that can be hard on the server depending upon the server load.
Note, it is not recommended that you use these options if you are on a shared server as other users load will affect your board and you may find it being disabled when it doesn't need to be.
There is no admin interface for this feature to prevent people enabling the feature and locking themselves out of their forum. You will need to enable it with phpMyAdmin (What is phpMyAdmin? (http://www.simplemachines.org/community/index.php?topic=21919.0)). This way you can just go back to phpMyAdmin and undo the changes.
To enable it, run the following query (you may with to adjust the values before hand)
REPLACE INTO smf_settings
(variable, value)
VALUES ('loadavg_enable', '1'),
('loadavg_forum', '40.0'),
('loadavg_auto_opt', '1.0'),
('loadavg_search', '2.5'),
('loadavg_allunread', '2.0'),
('loadavg_unreadreplies', '3.5'),
('loadavg_show_posts', '2.0');
This will disable the forum completely if the server load is above 40, automatic database table optimization with a load above 1, search with a load above 2.5, users "show all unread posts" at 2, users "show all unread replies" at 3.5 and the profile > show users posts at a load of 2.
If you need to tweak any of the settings, you can just do a REPLACE INTO, e.g. to turn the feature off, you can run
REPLACE INTO smf_settings
(variable, value)
VALUES ('loadavg_enable', '0');
Sweeet!! Cant' wait till SMF 1.1. This is going to rock!
hi there, are the dots in the values required at all?
The dot's aren't required mainly there if you want to get to an exact limit
Is it possible to set different values according certain membergroups?
No
Quote from: Ben_S on March 14, 2006, 04:33:04 PM
REPLACE INTO smf_settings
(variable, value)
VALUES ('loadavg_enable', '1'),
('loadavg_forum', '40.0'),
('loadavg_auto_opt', '1.0'),
('loadavg_search', '2.5'),
('loadavg_allunread', '2.0'),
('loadavg_unreadreplies', '3.5'),
('loadavg_show_posts', '2.0');
This will disable the forum completely if the server load is above 40, automatic database table optimization with a load above 1, search with a load above 2.5, users “show all unread posts” at 2, users “show all unread replies” at 3.5 and the profile > show users posts at a load of 2.
Discussion around this feature (which I was completely unaware of) has come up again in the MODs forum again and I would just like to ask:
1. The feature "Disable Forum" means that forum goes to Maintenance Mode?
2. Does anyone know the "best" tweaking values for each option? I'm not familiar with server load values, so I really don't know if values should be tweaked according to server-type, to forum size, to forum bandwidth, or if any other parameter should be taken into account.
1. Not Maintenance Mode, it uses a fatal error message (as far as I remember) to show the server load is currently too high, all access will be denied including admins.
2. There are no best values, they are entirely dependent upon the server you are on, if you are not on a dedicated server, I'd suggest you don't even bother with this feature since 90% of the time, the load will not be caused by your forum.
Tkx ;).
I just wondered if I should get worried with that.
Our forum, which consumes about 50 Gb bandwidth / month, had 1Gb disk space to use - 250 Mb for MySQL database and 410 Mb free space - and it crashed twice because of not enough disk space to execute those "temporary" MySQL table operations... but now it was upgraded to 5Gb and everything is smooth now.
But it's surely too small yet to cause any server load... ;D
Hi Ben,
I understand that this should not be used in shared server environment, but what if the server has mod_perl2 installed? This enables resources to be assigned to individual accounts - might it be possible to use the individually assigned resource levels so that peoples' forums aren't being disabled because of a high total server load?
mod_perl doesn't have anything to do with resource assignment, it is merely a way to run perl scripts inside the Apache process instead of as a CGI.
it show this error
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'loadavg_forum', '7.0'' at line 1
se7o.com, this post is quite old, MySQL probably had revisions and the code has probably changed, that is why it probably wont work.
Quote from: Kill Em All on February 07, 2010, 09:59:32 PM
se7o.com, this post is quite old, MySQL probably had revisions and the code has probably changed, that is why it probably wont work.
That's standard SQL that's been around for decades. It's possible that he copied and pasted incorrectly.
I know this post is quite old but its very helpful as it saves your forum if there is sudden spike or something. However, is there way to customize message it shows and also to not to lock down forum for Admin?
You can probably customize the message somehow, can't remember how this worked on 1.1 - but you can not make it so that it would care about your membergroup.
Ok, which part or what files deal with this settings.. .. that way I can look into myself !
This is really work?
It would be very helpflu to have somthing like this in admin panel.
Quote
This will disable the forum completely if the server load is above 40, automatic database table optimization with a load above 1, search with a load above 2.5, users "show all unread posts" at 2, users "show all unread replies" at 3.5 and the profile > show users posts at a load of 2.
by "server load above 40", u mean if server ram memmory is above 40% or what? :D
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.
Quote
This will disable the forum completely if the server load is above 40, automatic database table optimization with a load above 1, search with a load above 2.5, users "show all unread posts" at 2, users "show all unread replies" at 3.5 and the profile > show users posts at a load of 2.
by "server load above 40", u mean if server ram memmory is above 40% or what? :D
please check this http://www.lifeaftercoffee.com/2006/03/13/unix-load-averages-explained/ to find out.
Right, thank you, just read that, and get it :) I didnt know about that, couse i just moved from share to vps server.
So, anyone is using this on public forum? Is it working? Can it work with 1.1.12 version? :)
yes it's working at 1.1.2
don't be afraid if your serverload is 10 and your forum is fast.
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?
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.
Hm right, but i just have my own forum on vps, and dont plan any clients there for now.
Actually, 2.0 has this built into the Admin CP, as part of the server settings... ::)
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.
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.
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.
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 (http://wiki.simplemachines.org/smf/Server_Settings#Load_Balancing).
The last one seems what Paracelsus is looking for, but it affects all the users, not only guests.
Quote from: emanuele on July 18, 2011, 05:45:58 PM
Threshold to disabling the forum completely
Details: Load Balancing (http://wiki.simplemachines.org/smf/Server_Settings#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.
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.
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');
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'], ' </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';
}
???
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';
}
Can I use this option for our VPS? Memory is 1.2 GB. Bandwidth is 3,500GB. Space is 60GB.
...it's built into SMF since 1.1 and even has the Load Balancing page in the admin panel since 2.0 RC2...