Architecture : How would you go about building an activity feed like Facebook?

View other answers to this thread

Learn Something New Everyday,
Connect With The Best Developers!

Sign Up Now!

& 500k+ others use Hashnode actively.

Shreyansh Pandey's photo

This is quite an interesting question, really. Let's see how I'd go about it.

Alright, so the problem boils down to this: how to notify a user of any changes live from the people he's following. Okay.

So, let's break this problem down: a user can have a unique ID; and whenever s/he posts something, a small JSON object is pushed to a queue:

{
    "id": <GUID>
    "user_id": <USER_ID>
    "item_id": <ITEM_ID>
}

Here, item_id can be the item (image, post, etc.) itself. Now, whenever a user posts something, this gets queued. And when the queue gets this object, it sends out a push notification/publish-subscribe message to the followers the person has. On receiving the message, the message is displayed in the user's feed.

Now, I would like to say that publishing the item_id would be better, and then later, fetching the entire data would make this system faster.

There are other methods to do this as well. I would love to design one if you want me to! :)

I hope this helps!

Want to read more?

Browse featured discussions

© 2020 · Hashnode