vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   Delay reindexing as necessary to control server load (https://vborg.vbsupport.ru/showthread.php?t=255673)

Philip 12-21-2010 10:00 PM

Delay reindexing as necessary to control server load
 
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) { .....

abualjori 12-23-2010 09:48 PM

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.

KProjects 04-06-2011 06:47 PM

Good idea

Zachery 04-06-2011 08:09 PM

I'd just switch to sphinx


All times are GMT. The time now is 05:51 AM.

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.00913 seconds
  • Memory Usage 1,712KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete