Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Deferred Threadviews v1.00 (to reduce server load) Details »»
Deferred Threadviews v1.00 (to reduce server load)
Version: 1.00, by Jujubee Jujubee is offline
Developer Last Online: May 2009 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 06-21-2002 Last Update: Never Installs: 34
 
No support by the author.

Hack name: Deferred Threadviews
Version: 1.00
Purpose:
To reduce server load by not updating the view count on every page view but instead keeping the it in memory and writing to the db only occasionally.
Functions:
? Logs threadviews to a temporary table, and periodically commits data to the thread table.
? Frequency of writes controlled by server load and a random number.
? Includes optional email notification.
vB version tested on: 2.2.6
PHP version tested on: 4.2.0
Acknowledgements: Thanks to MattR for the "store threadviews as list of non-unique ids and use count(*)" suggestion that removed 1 query per pageview.



The updating of threadviews has been identified as a main cause of high server loads. This hack basically writes threadviews to a HEAP table (i.e. temporary table residing in memory) and will only update the thread count when the load is below a specified value and a random # value is hit.

(The impetus for this hack was an email from my host: They threatened to boot me off my server due to CPU usage "abuse", so as part of a larger effort, I decided to write this hack. *crossing fingers*)

SUMMARY of changes:
1) Set 1 Admin CP option
2) Create MySQL table
3) Insert code into SHOWTHREAD.PHP

The code will optionally send you an email every time the threadviews are committed to the thread table.

More details are in the text file.


This is what the email you'll get looks like:
Quote:
2395 Total Views (original number of write queries)
170 Threads (new number of write queries)

93% of Writes Avoided [2225 avoided]
14:1 Original Writes vs. Consolidated Writes

Version History:

0.9 - Initial Release
0.91 - removed need for reading of temp table before writing to it (thanks to MattR). Note that if you've been using 0.9, you must re-create the my_threadviews table as it's structure has changed.
0.92 - added reporting of the ratio of Original Writes vs. Consolidated Writes. Use this to help in tweaking the frequency of updates. If the ratio is low, (e.g. 2:1, 5:1, etc) it probably means updates are occuring too often. (The ratio will also be low if you have many separate threads that are viewed a small number of times.)
1.00 - No code changes. Changed version to 1.00 since it's been stable for the past 2 months.

Show Your Support

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

Comments
  #82  
Old 05-06-2003, 05:01 PM
Jujubee Jujubee is offline
 
Join Date: Nov 2001
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 06:35 AM scotty said this in Post #80
hm - I installed the hack and everything worked fine...

...except the "mark read" feature of thread, that the icon of the thread is changed.

anyone else reporting this problem?
This hack doesn't touch icons or dates so I don't know where those changes are coming from.

BTW, I've been letting this run for 24 hours between updates:

Quote:
3884 Total Views (original number of write queries)
212 Threads (new number of write queries)

95% of Writes Avoided [3672 avoided]
18:1 Original Writes vs. Consolidated Writes
Reply With Quote
  #83  
Old 05-06-2003, 07:51 PM
scotty's Avatar
scotty scotty is offline
 
Join Date: Oct 2001
Location: Mannheim, Germany
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 08:01 PM Jujubee said this in Post #81
[B]This hack doesn't touch icons or dates so I don't know where those changes are coming from.
I can't explain it too - I've looked over the code and the changed code doesn't touch the cookie settings... strange
Reply With Quote
  #84  
Old 05-15-2003, 07:05 PM
Kaelon's Avatar
Kaelon Kaelon is offline
 
Join Date: Jan 2002
Posts: 405
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just wanted to report that since installing this hack, my load has rarely risen over 1, and I have over 3,000,000 views a month.

Great work, Jujubee!

Kaelon
Reply With Quote
  #85  
Old 05-15-2003, 08:05 PM
Odysseus's Avatar
Odysseus Odysseus is offline
 
Join Date: Oct 2002
Location: Regensburg, Germany
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Jepp, this works just great for me, too.

This stupid threadview-update caused countless "deadlocks" on my machine which resulted in serverloads of 20.0 or even bigger throughout the day ... after installing this hack, the load has never reached a value above 2.50 again.

Great! Thanks! :banana:
Reply With Quote
  #86  
Old 06-14-2003, 07:05 AM
Sabrina Sabrina is offline
 
Join Date: Aug 2002
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nm figured it out
Reply With Quote
  #87  
Old 08-17-2003, 08:02 AM
Cal Poly Forum Cal Poly Forum is offline
 
Join Date: Jul 2003
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

BUmp.

So would this work on 2.3.2 without any problem??
Reply With Quote
  #88  
Old 08-18-2003, 04:08 AM
Cal Poly Forum Cal Poly Forum is offline
 
Join Date: Jul 2003
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump.
Reply With Quote
  #89  
Old 08-18-2003, 09:06 PM
julius julius is offline
 
Join Date: Nov 2001
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I installed on 2.3.2 without any problem.

It adds a query: before installing this hack I had 21 queries on showtread, now I have 22 queries.
Reply With Quote
  #90  
Old 09-25-2003, 08:28 AM
Q8vbhacks Q8vbhacks is offline
 
Join Date: Mar 2002
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

users online 300-400 server load over 7
there is setting

if ($loadavg[0]<5 && mt_rand(1,600)=='44'){

NIX Load Limit 0 <--- i don't want to be server busy to our users

877 Total Views (original number of write queries)
540 Threads (new number of write queries)

38% of Writes Avoided [337 avoided]
2:1 Original Writes vs. Consolidated Writes
Reply With Quote
  #91  
Old 10-14-2003, 12:20 PM
AKosygin's Avatar
AKosygin AKosygin is offline
 
Join Date: Oct 2003
Location: Los Angeles County
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First, I would like to thank you a billion, this has saved us and we see MASSIVE performance gains. We dropped 20 points on the NIX load and no more lagging. We also tested this to work with vBulletin v2.3.2 and 2.2.x. We get 300 to 400 visitors and it was lagging until the database server was overloaded, now we are zooming by most of the time.

Quote:
Originally Posted by v0id
I get safe mode errors when I set *NIX Load Limit to anything but 0. Damn.
We had similar problems, it means that the load average command belongs to root. With PHP's safe mode on, a file belonging to you can not access a file belonging to anyone else including files belonging to root. You will have to ask your server admin to turn of PHP's safe mode.

If you can not turn off safe mode, another solution is to have it read how many processes your SQL login is processing. We had to hack this hack to check that. Actually, we really hacked this hack with a bunch of functions. Maybe I will post the giant hack of this hack later when I have time to refine it a bit.
Reply With Quote
Reply

Thread Tools

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 02:55 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.06855 seconds
  • Memory Usage 2,302KB
  • Queries Executed 25 (?)
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
  • (5)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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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