incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From He Shiming <heshim...@gmail.com>
Subject Re: Optimal counter implementation?
Date Wed, 11 May 2011 14:42:43 GMT
On Tue, May 10, 2011 at 10:00 PM, Olafur Arason <olafura@olafura.com> wrote:
> If you know erlang I would advise you to extend _stats, it would
> give you the best performance.
> http://wiki.apache.org/couchdb/Runtime_Statistics
>
> There is also some work in doing visualization to it:
> https://github.com/mcaprari/couchdb-stats
>
> If you want to go the javascript route I would advice you to use update
> as a incremental counter, you would supply the _id and it would increment
> the page count. You can do more fancy stuff if you want.
>
> Your would have a separate document for the counters, possible with a
> _id scheme like this:
> current_id+_stats"
> So the stat document for 879759be9418a39aab624e9619092c80 would
> be 879759be9418a39aab624e9619092c80_stats.
>
> Then you would use views to collect the data with the key as the id
> of the original document.
>
> If you use a single count document it can balloon very fast also slow
> down everything because on update it has to send a new document,
> and the couchdb database file would grow really fast and you would
> have to compact very often.
>
> Regards,
> Olafur Arason
>
> On Tue, May 10, 2011 at 09:05, He Shiming <heshiming@gmail.com> wrote:
>> Hi,
>>
>> I'm working on this project, that needs to count page views. I came up
>> with two possible solutions:
>>
>> 1. For each page to be counted, use a single count document, and an
>> update handler to count on each page view
>> 2. Create a new document on each page view, this way I get to record a
>> history of views, which I prefer
>>
>> I was wondering if the second method will consume too much space and
>> CPU on a heavy traffic website. If I need the log of page views, it
>> looks like this is the only way. But is it the correct and optimal way
>> of doing counters?
>>
>> Or should I pick an alternative database for counters?
>>
>> --
>> Best regards,
>> He Shiming
>>
>

Thank you both for the information. The CouchDB stats module appeared
to be too reliant on CouchDB internals. So it looks like I'll be using
another db for counters.

-- 
Best regards,
He Shiming

Mime
View raw message