

Ask HN: How often does HN recalculate rankings? - xwowsersx

The HN ranking algorithm is well-known (see: http:&#x2F;&#x2F;amix.dk&#x2F;blog&#x2F;post&#x2F;19574). My question is: is the rank of every single post updated at some interval? It would seem that, in some way, this has to happen, otherwise items that are growing obsolete (on account of the gravity of time) would not move down as they should. However, it also seems impractical and prohibitively costly to constantly re-rank every single item. Is the idea that time has such a gravitational effect that HN only needs to fetch all posts where the timestamp is &lt;  2 weeks ago (or whatever) and re-rank only THOSE items since the ranking of a post submitted 2 weeks ago and one submitted 2 months ago will both be approaching zero (thereby limiting reranking to only a small subset of all posts)?
======
wfjackson
[http://www.righto.com/2013/11/how-hacker-news-ranking-
really...](http://www.righto.com/2013/11/how-hacker-news-ranking-really-
works.html)

You might expect that every time you visit Hacker News, the stories are scored
by the above formula and sorted to determine their rankings. But for
efficiency, stories are individually reranked only occasionally. When a story
is upvoted, it is reranked and moved up or down the list to its appropriate
spot, leaving the other stories unchanged. Thus, the amount of reranking is
significantly reduced. There is, however, the possibility that a story stops
getting votes and ends up stuck in a high position. To avoid this, every 30
seconds one of the top 50 stories is randomly selected and reranked. The
consequence is that a story may be "wrongly" ranked for many minutes if it
isn't getting votes. In addition, pages can be cached for 90 seconds.

------
woven
I'm not sure how HN does it specifically. In a version of our app, we had
scoring which was initially modeled after Reddit's algorithm
([http://amix.dk/blog/post/19588](http://amix.dk/blog/post/19588)). A server
task updated the scores for every item every hour. We could have limited how
far back we went, but had no need in our case given that the amount we indexed
was within reason. We'd add or subtract from the score based on a set of rules
that considered a number of factors including posted date, number of votes and
number of comments. We had an admin tool for assigning more or less weight to
the various factors.

------
dang
The server does it in a background thread every few seconds. It limits this to
the stories that are in memory, but it also (on startup) makes sure that all
recent stories are in memory.

------
bthornbury
There's probably some type of lower bound on the overall score that they use
rather than just time. This would be one limit, also updates could be
prioritized based on time. So newer posts (or more highly scored ones) would
be scheduled to be updated more often.

------
bhartzer
Is it safe to assume that the 'timestamp' is when that item was first
submitted to HN, and not when the content was originally posted?

~~~
minimaxir
Correct, as that's how the official APIs report it.

