How does the Timeline Twitter algorithm work?

Iโ€™m trying to create a system similar to the Twitter timeline, but I canโ€™t plunge into the head of how to get updates from so many followers, while remaining effective. Let's say I follow 1000 people on Twitter. When I go to my channel, how does he know what tweets show me? This is what I think of, but it seems extremely inefficient and unlikely:

You have 10,000 friends. In a for loop, loop through each friend, getting their latest status updates since their last update. 

But it just seems ridiculous to go through 10,000 friends. I canโ€™t imagine how else they would do it. Or it will be something like:

 Someone I am following posted a tweet. That tweet is inserted in an array containing the tweets of all people I am following. 

But then it would seem strange if I followed someone new who had 20,000 tweets, then 20,000 tweets would be included in my array, and if this person has millions of followers, then there is a million X 20,000 copies of the same set of tweets. So this also seems unlikely.

Anyone have any ideas how they can do this?

+6
source share
2 answers

I advise you to check out the twissandra project, they have implemented all the basic twitter functions using cassandra , the nosql database. Twitter is said to no longer use it for tweets .

In the old implementation can be found here

+3
source

This video here explains the full twitter design https://www.youtube.com/watch?v=KmAyPUv9gOY

0
source

Source: https://habr.com/ru/post/925715/


All Articles