Register Members List Search Today's Posts Mark Forums Read

Article Options
Delay reindexing as necessary to control server load
Join Date: Jan 2002
Posts: 3

Earth, the Solar System
by Philip Philip is offline 22 Dec 2010

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):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Right after, add this code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.

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) { .....

Last edited by Philip; 23 Dec 2010 at 05:50..
Views: 2223
Reply With Quote
Old 23 Dec 2010, 23:48
abualjori abualjori is offline
Join Date: Feb 2010
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
Old 06 Apr 2011, 20:47
KProjects KProjects is offline
Join Date: Feb 2006
Good idea

Stop Spammers
Reply With Quote
Old 06 Apr 2011, 22:09
Zachery's Avatar
Zachery Zachery is offline
Join Date: Jul 2002
Real name: Zachery Woods
I'd just switch to sphinx
Looking for ImpEx?
Reply With Quote

Similar Article
Article Author Type Replies Last Post
[Linux] loadsock (retrieve server load from remote server) fastforward vBulletin 2.x Full Releases 5 18 Mar 2002 11:55

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Article Options

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

New To Site? Need Help?

All times are GMT. The time now is 01:41.

Layout Options | Width: Wide Color: