views:

1305

answers:

4

I have a Rails application where users can set up their domains and publish content onto them. I need to collect public traffic statistics such as pageview count etc. One good example of this feature is flickr usage statistics i can see as a customer.

The question is what is the best way to collect usage information. Should it be done by parsing log files or should it be collected and stored in database at runtime? Is there any tool or Rails plugin that already provides this?

This solution should scale well, even with thousands of domains and millions of pageviews in month.

+3  A: 

Google Analytics is probably your best bet...

Matt Darby
A: 

The easiest solution is probably just to buy Mint or use Google Analytics.

Steve Losh
+1  A: 

Check with your host. A few of them provide Urchin stats by default.

Other than that most people use Google Analytics. If you need extremely fine grained information you can try some post processing on your production.log with tools like this one. If you do your post-processing on a scheduler ( like cron ) then you should not need to worry about performance or scaling too much.

Bill
+1  A: 

It depends on exactly what you're trying to log.

I've started to use http://github.com/smtlaissezfaire/enhanced_query_analyzer/tree/master in a beta-production system to log queries. You could certainly do something similar to log page views with a before filter in application.rb

If you need or want to use a database, don't want to share your information with google, and are using mysql, I'd suggest looking into the archive storage engine

Thanks, i ended up with solution like this query analyzer one. I wrote a plugin that makes delayed insert with all the neccessary information after each request.
Priit