Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Restrict search when the server load is high Details »»
Restrict search when the server load is high
Version: 1.00, by UK Jimbo UK Jimbo is offline
Developer Last Online: Mar 2013 Show Printable Version Email this Page

Version: 3.0.6 Rating:
Released: 02-15-2005 Last Update: Never Installs: 5
 
No support by the author.

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:
PHP Code:
if (!$vboptions['enablesearches'])
{
        eval(
print_standard_error('error_searchdisabled'));

add below it:
PHP Code:
// 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:

Quote:
Searching has been disabled. This is most likely automatic and due to high server load. Please try again later.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 02-16-2005, 10:14 PM
babolo babolo is offline
 
Join Date: May 2004
Location: California
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nice hack maybe i'll install it
Reply With Quote
  #3  
Old 02-16-2005, 10:36 PM
yoyoyoyo's Avatar
yoyoyoyo yoyoyoyo is offline
 
Join Date: Dec 2004
Location: USA
Posts: 1,612
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm.. interesting. thanks for sharing. I may install this later, though my site is on a shared server and loads can get pretty dang high
Reply With Quote
  #4  
Old 02-16-2005, 10:40 PM
UK Jimbo's Avatar
UK Jimbo UK Jimbo is offline
 
Join Date: Sep 2002
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Be really interested to get everyone's feedback on how well this has worked for you.
Reply With Quote
  #5  
Old 02-17-2005, 01:49 AM
Jen's Avatar
Jen Jen is offline
 
Join Date: Apr 2002
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just installed it.. and the search feature stopped working alltogether. All I get now is a blank page.

Did some debugging and it's harfing somewhere after the first IF, won't even display a print after the if statement and nothing inside it.

Here's where it seems to die on me: @file_get_contents('/proc/loadavg').
Reply With Quote
  #6  
Old 02-17-2005, 08:22 AM
UK Jimbo's Avatar
UK Jimbo UK Jimbo is offline
 
Join Date: Sep 2002
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jen
I just installed it.. and the search feature stopped working alltogether. All I get now is a blank page.

Did some debugging and it's harfing somewhere after the first IF, won't even display a print after the if statement and nothing inside it.

Here's where it seems to die on me: @file_get_contents('/proc/loadavg').
I should have pointed out that this will only work on Linux machines or *NIX flavours that support the proc file system and specificially /proc/loadavg

It'd be great if you could drop me a PM with some further error message/debug Jen. It definitely shouldn't present you with a blank page.
Reply With Quote
  #7  
Old 02-17-2005, 04:22 PM
Jen's Avatar
Jen Jen is offline
 
Join Date: Apr 2002
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PM Inbound UK. I'm running Redhat and /proc/loadavg exists, I'm wondering if it can get the file contents though.
Reply With Quote
  #8  
Old 02-17-2005, 08:05 PM
Polo's Avatar
Polo Polo is offline
 
Join Date: Jun 2004
Posts: 893
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Interesting...
Reply With Quote
  #9  
Old 04-07-2005, 07:31 AM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

where do I set the average server load number?
Reply With Quote
  #10  
Old 04-07-2005, 07:51 AM
UK Jimbo's Avatar
UK Jimbo UK Jimbo is offline
 
Join Date: Sep 2002
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by hollyboy
where do I set the average server load number?
$search_load_trigger=5;

at the top.

Where 5 is a one minute load average of 5.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05599 seconds
  • Memory Usage 2,298KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete