0

I can not say enough of performance gain that my site gained through migrating to Pressflow + Varnish. However I have a rather annoying problem with Pressflow. After migrating to Pressflow 6, the statistics of online users does not show correctly. For example the forum shows 70 online users while there are actually over 1000 users online.

I am wondering whether it can be fixed or it is just a "collateral damage" that one should afflict to gain the performance. If it can be fixed, appreciate your hints to do so, and if not, how else can I show the correct stats.

Thanks

2

I believe this is because of how Pressflow handles anonymous sessions. It implements what are called "lazy sessions", which only creates sessions when actually needed.

This behavior can be changed by putting a drupal_start_session() in a custom hook_init. If you do this, though, you will likely take a performance hit.

I have had to do this with a few projects to fix session problems when moving from Drupal 6 to Pressflow 6.

EDIT TO ADDRESS COMMENT:

You can simply put the hook in a custom module, such as

function mymodule_init ()
{
  drupal_start_session();
}

Note that you should really profile before and after to see what the performance impact is.

| improve this answer | |
  • Where should I put the hook_init snippet? Thanks – alfish Jan 22 '12 at 17:10
  • if the performance hit is substantial and you only need it to show the total number of online users you could just "estimate" it by extrapolating from the numbers that are reported. For example multiple 70 times 15 to get to the a more realistic number ;-) – uwe Jan 22 '12 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.