integration with "who's online" block

chadd - October 2, 2009 - 13:58
Project:Boost
Version:6.x-1.x-dev
Component:Cookie issues
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

this isn't really a bug or anything, but more of a question on how things work...

correct me if i'm wrong, but from what i understand:
- the who's online block displays the number of anon users by counting the number of uid=0 rows in the sessions table for whatever past time amount you have it set to
- boosted pages don't hit the db, so therefore don't insert/update a row into the sessions table

so when i see "There are currently 3 users and 38 guests online.", those 38 guests just happened to have landed on a page that hasn't been boosted yet? and therefore created a session for that anon user?
and therefore we probably have many more anon users "currently online" than is being reported because the majority of them are landing on pages that have already been boosted so therefore they were never entered into the sessions table?

i'm not advocating that i want to sacrifice the speed of boost for the accuracy of the who's online block, ...no way.
i'm just more curious about how it all integrates and how far off that number actually is.

thanks for the info...

#1

mikeytown2 - October 2, 2009 - 19:06

#586210: Set session cookie would fix this issue.

But to answer your question, yes that means the 38 guests hit a non boosted page and where thus given a session, in the last 15 min most likely.
http://api.drupal.org/api/function/user_block

<?php
case 3:
        if (
user_access('access content')) {
         
// Count users active within the defined period.
         
$interval = time() - variable_get('user_block_seconds_online', 900);

         
// Perform database queries to gather online user lists.  We use s.timestamp
          // rather than u.access because it is much faster.
         
$anonymous_count = sess_count($interval);
         
$authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
         
$authenticated_count = 0;
         
$max_users = variable_get('user_block_max_list_count', 10);
         
$items = array();
          while (
$account = db_fetch_object($authenticated_users)) {
            if (
$max_users > 0) {
             
$items[] = $account;
             
$max_users--;
            }
           
$authenticated_count++;
          }

...
?>

#2

chadd - October 2, 2009 - 19:28

ok, thanks.
that's what i thought.

the session cookie looks interesting, but i don't think we'd implement it if it caused any performance issues, and the only benefit was the 'who's online' block (for our case, at least).

#3

mikeytown2 - October 2, 2009 - 19:47

If the users does a POST they get a cookie as well. So if your site has a lot anonymous action taking place, then that would effect the count.

Depending on your websites usage pattern and expiration times in conjunction with when cron runs, you might be able to decrease cache misses. You would crawl to replace expired content rather then flushing it. Follow these directions if you wish to do this: http://drupal.org/node/587438#comment-2104678

#4

mikeytown2 - October 21, 2009 - 02:04
Version:6.x-1.03» 6.x-1.x-dev
Status:active» postponed

Postponed till this is done: #586210: Set session cookie

 
 

Drupal is a registered trademark of Dries Buytaert.