UK Jimbo
02-15-2005, 10:00 PM
From experience searches on large forums can slow the server down a lot.
Here's a dead simple hack that lets you disable searches when the load average reaches a defined level. Moderators are exempt from the search ban.
There's are just two changes to be made:
in search.php find:
if (!$vboptions['enablesearches'])
{
eval(print_standard_error('error_searchdisabled')) ;
}
add below it:
// automatically block search requests when the server is busy
$search_load_trigger=5;
if ( (!($permissions['adminpermissions'] & ISMODERATOR)) AND PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $filestuff = @file_get_contents('/proc/loadavg'))
{
$loadavg = explode(' ', $filestuff);
if (trim($loadavg[0]) > $search_load_trigger)
{
eval(print_standard_error('error_searchdisabled')) ;
}
}
The trigger level is based on the current (1 minute) load average. It can be changed by editing the $search_load_trigger variable.
You may also wish to change the searchdisabled phrase to something like:
Searching has been disabled. This is most likely automatic and due to high server load. Please try again later.
Here's a dead simple hack that lets you disable searches when the load average reaches a defined level. Moderators are exempt from the search ban.
There's are just two changes to be made:
in search.php find:
if (!$vboptions['enablesearches'])
{
eval(print_standard_error('error_searchdisabled')) ;
}
add below it:
// automatically block search requests when the server is busy
$search_load_trigger=5;
if ( (!($permissions['adminpermissions'] & ISMODERATOR)) AND PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $filestuff = @file_get_contents('/proc/loadavg'))
{
$loadavg = explode(' ', $filestuff);
if (trim($loadavg[0]) > $search_load_trigger)
{
eval(print_standard_error('error_searchdisabled')) ;
}
}
The trigger level is based on the current (1 minute) load average. It can be changed by editing the $search_load_trigger variable.
You may also wish to change the searchdisabled phrase to something like:
Searching has been disabled. This is most likely automatic and due to high server load. Please try again later.