How to update video views count effectively?
Tuesday, April 1, 2008 at 8:40PM
Todd Hoff in General Discussion
Hi,

I am building a video-sharing site and I'm looking for an efficient way to update video views count.

The easiest way would be to perform an SQL update to increase the "views" counter every time a video is viewed, but naturally I want to avoid DB write access as much as possible.

I am looking for an efficient temporary storage to which I could connect and say "increment views of video X". Every so often I would save the changes to my main database, and remove the counter from this temporary storage.

I am having a hard time finding such temporary storage, however. My first thought was memcache, but it's not ideal as I wouldn't like to lose the data if memcache goes down. Also, memcache's increment command requires that the key is already present - that means that every time a video is viewed, I would have to check if the key already exists in memcache, before I can actually send the increment command.

What do people use to solve this kind of issues?

Kind regards,
Tomasz
Article originally appeared on (http://highscalability.com/).
See website for complete article licensing information.