I’m designing a website that has to track all the visits to a determinated resource. The problem is that the site was thought to manage large amount of traffic, so, track every visit is not reliable.
I was researching a bit about it and here recommends to register data only for the minimun unit of time needed (in this case, visitors/day). It’s a good idea, but if the site are going to have a lot of traffic, may be that in midnight two visitors could try to visit the same resource and the two rails processes will try to create two different documents for the visitors of the same day.
So anybody has an idea about how to deal with this problem? The idea of track only visitors/day is fine, but i’m not sure of how to manage possible duplications of days in the stats of a resource. (May be with a unique index of both resource and day, but in this case the second concurrent visitor will get an error…)
EDIT: I’m using rails 3.2.2, Mongoid 2.5.0 and MongoDB 2.0.0 (with TTL index support)
I’ve been using Trackoid for my tracking needs. I’m using it with resque and doing all tracking in a background job on a separate server. You could of course also trigger the tracking with javascript which I guess would be prefered.