I'm developing a system that has to return the most trending 'articles' in real time based on the no. of hits that article has.
My first thought was storing for each article the no. of hits vs. time. Then I would normalize this function, and calculate its first derivative which will return the growth rate. Then with the second derivative I'd be able to know how much it's growing and if it reaches a certain threshold -> tag it as trending.
The problem is: I can do that "offline" for example at the end of the day, but I don't know how to do it continously...
I know that there exist such things as Storm but I'm looking for something as specific as this (a written algorithm in pseudocode or an article approaching this problem and not the generic one).