vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Deferred Threadviews v1.00 (to reduce server load) (https://vborg.vbsupport.ru/showthread.php?t=40137)

Tim Wheatley 08-31-2002 02:01 AM

Code:

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

Darth Cow 09-03-2002 03:41 AM

Quote:

Originally posted by Raz
Jujubee, a great hack! Devs, should really consider making something similar as part of VB3.
I believe they already have :). I read somewhere on the alpha forums that thread views are now only updated every hour :cool:.

Ritsui 09-03-2002 11:53 PM

How about scaling dynamically with load? Something like:
PHP Code:

$loadMult = (($loadavg[0] * 100) +5);    //change these values to tweak frequency of writes
if ( mt_rand(1,$loadMult)=='1' ) {
...
snip... 

This would seem to work better at least with smaller forums that have occasional very heavy peaks where you still want views to be updated frequently, but less based proportionally on load.

Jujubee 09-06-2002 01:09 AM

Quote:

Originally posted by Tim Wheatley
Code:

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

Tim, have you been getting any emails with the above settings? PHP will produce a random number between 1 and 5. This won't ever equal 44. :)

If you want more frequent updates, change the 44 to 1, then change the 5 to something higher. A limit of 5 would mean the views would be update once every 5 pageviews -- not much of a savings IMHO. :)

Jujubee 09-06-2002 01:13 AM

Quote:

Originally posted by Ritsui
How about scaling dynamically with load? Something like:
PHP Code:

$loadMult = (($loadavg[0] * 100) +5);    //change these values to tweak frequency of writes
if ( mt_rand(1,$loadMult)=='1' ) {
...
snip... 

This would seem to work better at least with smaller forums that have occasional very heavy peaks where you still want views to be updated frequently, but less based proportionally on load.

Sure, this would work. But personally, I don't want it doing any updates when the load is high. I don't mind losing views if the server crashes.

With your code, for example, the load could be 50 and it would still update (if the correct random number was produced). Hundreds of consecutive db writes when the load is at 50+ won't be a pretty sight. :)

Mijae 12-04-2002 10:14 PM

Quote:

Originally posted by FFMania
Have some problem......when I find this code....

PHP Code:

    if ($noshutdownfunc) {
      
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
    } else {
      
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'";
    } 

I can't fiind it since I have lesane Store hack installed..so the code becomes...

PHP Code:

if ($noshutdownfunc) {
  
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
  
  
// Store hack by Lesane

  
$storeview=$DB_site->query_first("select views, postuserid from thread WHERE threadid='$threadid'");
  
$views=$storeview[views];
  
$postuserid=$storeview[postuserid];

  
$storeadmin $DB_site->query_first("SELECT * FROM storeadmin");
  
$view1=$storeadmin[view1];
  
$view2=$storeadmin[view2];
  
$view3=$storeadmin[view3];
  
$view4=$storeadmin[view4];
  
$view5=$storeadmin[view5];
  
$viewpoint1=$storeadmin[vpoint1];
  
$viewpoint2=$storeadmin[vpoint2];
  
$viewpoint3=$storeadmin[vpoint3];
  
$viewpoint4=$storeadmin[vpoint4];
  
$viewpoint5=$storeadmin[vpoint5];

  if (
$views == $view1
  {
    
$DB_site->query("UPDATE user SET storep=storep+$viewpoint1 where userid='$postuserid'");
  }
  elseif (
$views == $view2
  {
    
$DB_site->query("UPDATE user SET storep=storep+$viewpoint2 where userid='$postuserid'");
  }
  elseif (
$views == $view3
  {
    
$DB_site->query("UPDATE user SET storep=storep+$viewpoint3 where userid='$postuserid'");
  }
  elseif (
$views == $view4
  {
    
$DB_site->query("UPDATE user SET storep=storep+$viewpoint4 where userid='$postuserid'");
  }
  elseif (
$views == $view5
  {
    
$DB_site->query("UPDATE user SET storep=storep+$viewpoint5 where userid='$postuserid'");
  }
  
} else {
  
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'"

Any idea what I should do?

I have the same problem, I tried adding your hack anyways deleting some lines from Store Hack but I started getting php errors, so I have no idea what to do.

Erwin 12-05-2002 01:18 AM

The good news is that vB3 will have this built-in. :)

eoc_Jason 12-31-2002 06:52 AM

I like this hack but it has one quirk... late at night when not many people are on it doesn't update that often and people are asking why...

Would it be possible to code in a timer so that it would write every 5min or so? But also have the random number generation so that it will write properly during normal usage?

ladyfyre 01-04-2003 05:20 PM

How can i set this so that it updates every 500 threadviews, without any conditionals? The server load on the mysql server is not a factor...it is the php server load that is an issue and something in apc is not playing nicely with this hack. I would like to keep it, but would prefer being able to set a fixed # at which it will dump.

I have been trying to use this:

PHP Code:

if (mt_rand(1,500)=='44'){//change these values to tweak frequency of writes 

But it is not updating at 500 views.

Scott MacVicar 01-05-2003 06:20 PM

Here is a file to let you use a cron job to do it instead of in showthread, its more efficent in my opinion.

Open up the file and change the path to your config.php, upload now to your server, and then create a cron job.

Cpanel users can do this in the Advanced section

just type

php /home/path/to/deffered_views.php

and set it to run every 30mins


All times are GMT. The time now is 08:02 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.01397 seconds
  • Memory Usage 1,770KB
  • 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
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete