[Zope3-Users] Ahh, counters... Best practice?

Dennis Noordsij dennis.noordsij at movial.fi
Wed Aug 15 04:53:06 EDT 2007


On Wednesday 15 August 2007 00:07, Jeff Shell wrote:
> We're working on something where we need to allow site visitors to
> rate items. It's the basic star-rating thing. We want to keep a count
> of the number of votes along with the current value.

Hi Jeff,

Another possibility is of course to do external logging, i.e. to an SQL 
database. I use this for certain objects where I need to log every hit, 
Postgres easily does 100s per second, the zodb would not like it nearly as 
much.

Was surprisingly easy to implement too (compliments to Zope!). You could use 
the object's intid as the key in the sql database for example, or a name, or 
whatever you like.

I then have a view which aggregates hits per hour, and a query on top which 
applies an exponential backoff multiplier - i.e. recent hits are weighted 
more than older hits. The results of this query are cached for a few minutes 
using lovely.memcached (great product!), so the impact is very very low.

Just another suggestion, goodluck

Cheers
Dennis




More information about the Zope3-users mailing list