Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Delay reindexing as necessary to control server load
Philip
Join Date: Jan 2002
Posts: 3

 

Earth, the Solar System
Show Printable Version Email this Page Subscription
Philip Philip is offline 12-21-2010, 10:00 PM

It is sometimes necessary to rebuild the search index, and it can be quite resource-intensive and time-consuming with larger boards. It takes a few hours on my forums, so I just came up with the following code to keep the server load from spinning out of cotrol. It should work under most linux distributions, as long as you have access to /proc/loadavg from PHP (if not, see notes below).

In /admincp/misc.php, find the following lines (around line 184 in the latest vB 4.1 PL1 build):

Code:
if ($vbulletin->GPC['autoredirect'] == 1)
{
Right after, add this code:
Code:
  $load = explode(' ',@file_get_contents('/proc/loadavg')); // find out load
  if ($load[1] > 8) {    // if 5-min load average is over 8...
        usleep(3000000); // in millionths of a second - adds 3 second delay 
  }

The idea is that this only adds a delay to redirects when/if server load exceeds some value (8 in this example).
The only downside I can see is checking the load average after each redirect... But it seems to work much better than the default reindexing on my server.


I hope it helps someone.


Notes:
If you do not have access to /proc/loadavg from PHP, you can try to execute `uptime` instead, or just add the "usleep ..." line to delay each redirect (even though it's a crude solution as it would slow down reindexing by a lot regardless of server load).

The uptime code variant of the above should be something like:
$load = explode(' ', `uptime`)
$load_5min = $load[count($load)-1];
if ($load_5min > 8) { .....
Reply With Quote
  #2  
Old 12-23-2010, 09:48 PM
abualjori abualjori is offline
 
Join Date: Feb 2010
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much for sharing.

will test it out this morning.


the same line of code could be found in line 167 for vb3.
Reply With Quote
  #3  
Old 04-06-2011, 06:47 PM
KProjects KProjects is offline
 
Join Date: Feb 2006
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good idea
Reply With Quote
  #4  
Old 04-06-2011, 08:09 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd just switch to sphinx
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 01:58 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03743 seconds
  • Memory Usage 2,222KB
  • Queries Executed 19 (?)
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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete