Hey
I was just on Facebook website and for some reason i got interested in their "news feed" feature.
It got me thinking on how on earth do they do that. I know that they have HUGE hardware behind it
and use caching, but still.
Come to think about it now, you have other website that offer the same thing..
Let's say that they save actions into one table..
Came up with two options:
Option 1:
- Get a list of my friends
- Get a list of recent activities from actions table, activity matches my friend list
Option 2:
- Each time an action is made, make INSERT for each friend i have
Now, i would say that the second option would be faster, but still.. Imagine having 500
friends. That means 500 INSERTs.
Isn't there any better way of doing this?
'news feed' like db structure
Moderator: General Moderators
Re: 'news feed' like db structure
Actually, I think the first approach is the better one. Since it is more normalized, caching is easier since the same event isn't spread to 500 hundred different users (in the database). Facebook probably caches parts of the feed separately for specific time spans, invalidate a chunk at a time to allow a new chunk to enter from above and so forth.
Their feed system by the way is quite broken. I can't recall how many times I've seen past events resurface as if they happened just now, over and over. But it's a social network so no one cares
Their feed system by the way is quite broken. I can't recall how many times I've seen past events resurface as if they happened just now, over and over. But it's a social network so no one cares