Hi,
The problem:
For every post, I want to show the exact number it has been viewed by everybody, anonymous or not.
This does not only include showing in every post page, but also in views with results of various posts.
Not being a problem:
I don't have problem if the numbers are refreshed every now and then, for example every 30 minutes.
However, statistic numbers must be accurate.
As it is now (Everything throught drupal)
This is a problem as for high volume traffic sites, we have serious performance issues for many reasons.
This idea is already implemented and that's why we want to change it.
Pros: Full drupal system
Cons: If we put Varnish - or anything equivelant that in any way does not bootstrap drupal, anonymous hits are not shown.
I believe, the best way is to use Varnish, or anything equivelant but also save somehow all hit counts.
But how?
In order to use Varnish but not lose hits is:
A) Varnish has to log everything (can it do so?)
B) Somebody else has to save hit counts,
..and then once in a while, submit this information in drupal.
..or take this information from a different source, throught javascript and show it to the user, without the need for drupal for doing anything at all (everything will be static for drupal)
So.
Idea A. A user hits a page. Takes the response, even from Varnish. Asynchronously, (javascript) sends a request(R1) for every statistic, gets a number, shows it to a spesific div.
R1 could be:
R1-1. Google Analytics, and through javascript Google Analytics API we request the view statistics for a spesific page.
Pros: Google
Pros: Our site is fully cachable, no hit is lost
Cons: Google may complain for high traffic requests (501/503 errors), there are specific limits for the API.
Cons: We have to give an API key inside javascript
R2-2. Something else in our server, with custom PHP and MySQL queries that log everything? Could this be a good way to avoid Drupal bootstraping and everything else? Apparently, with this way we will have to implement an asynchronous call as google analytics javascript for every page, to our own logging system
Idea B. A user hits a page. Takes the response, even from Varnish. Drupal once in a while (cron job) is refreshed by new view counts. This value could be a cck field, to avoid another JOIN. But how is this cck field is refreshed?
1. Cron job, checks Apache/Varnish logs and refreshes cck value (hardcoded [sql quieries] or drupal way [load nid->save])
2. Cron job, through Google Analytics API, that requests statistics for many pages (simultaneously) and refreshes cck values the same way as B.1
Has somebody thought of all these? Has he or she found the best solution?