How to implement a Digg-like algorithm?

Posted by Niklas on Stack Overflow See other posts from Stack Overflow or by Niklas
Published on 2008-09-16T12:59:00Z Indexed on 2010/04/11 15:03 UTC
Read the original article Hit count: 497

Filed under:
|
|
|

Hi,

How to implement a website with a recommendation system similar to stackoverflow/digg/reddit? I.e., users submit content and the website needs to calculate some sort of "hotness" according to how popular the item is. The flow is as follows:

  • Users submit content
  • Other users view and vote on the content (assume 90% of the users only views content and 10% actively votes up or down on content)
  • New content is continuously submitted

How do I implement an algorithm that calculates the "hotness" of a submitted item, preferably in real-time? Are there any best-practices or design patterns?

I would assume that the algorithm takes the following into consideration:

  • When an item was submitted
  • When each vote was cast
  • When the item was viewed

E.g. an item that gets a constant trickle of votes would stay somewhat "hot" constantly while an item that receives a burst of votes when it is first submitted will jump to the top of the "hotness"-list but then fall down as the votes stop coming in.

(I am using a MySQL+PHP but I am interested in general design patterns).

© Stack Overflow or respective owner

Related posts about sql

Related posts about algorithm