Chris Snoek
Chris Snoek@chris_snoek · SpotShare

Create a social activity feed for logged in users

Created on
Discussion
@chris_snoek How are you planning on architecting this? I recently built one for Meeve, I can provide you with some ideas if you dont already have any! Btw, read the Justin Bieber problem ;)
Upvote (1)Share
@ishaanbahal Hi @ishaanbahal thanks for your message! Im having some problems indeed, got the activities as separate entries in my database now, and after a few attempts to grouping them together, I decided to just show the entries as the platform is not very popular yet. Im curious how you got your activity feed up and running!
@chris_snoek Okay, so for me, its mostly events and some small activities, but I kept two things, activities are unique objects within the system, so they make sense in a database. I also indexed all those in ElasticSearch (this part isn't required since you can always query the database), and I query only once when the user come to the app, with a previous feed ID. When the query completes, the data is compared from the data of the previous feed, if same, same ID is returned as before, if different, then I store the object IDs in a list inside redis. So they are sorted and I cant fetch them paginated, without querying the db server. In my case, most event objects are also cached, so DB calls get automatically reduced and clients keep a simple feedID that they send with the first time they are calling the server to get a new feed ID. Hope this makes sense! Also, I give 3 day expiry per feedId, so after three days, a new feed ID is always generated.
@chris_snoek Or simply put, create a Feed ID per user and change the feed ID only when their feed changes. Store this feedId mapped list of objects in cache or memory somewhere, so even if it is lost, you can always rebuild it and it helps in faster pagination.
@chris_snoek Also, as a simple thing, if you're on apps (iOS and Android), you can cache the response of the past feed, open the app to it, and once you get new data for the feed, if any, then simple reload the view controller. That way users get a more instagram-ish feel and things seems pseudo-fast. 😉
@ishaanbahal Thanks Ishaan for your in-depth explanation. I use a similar approach, and is for web only. The only thing I haven't figured out yet is how to logically group same kind of activity, or multiple actions from the same users. For example 'John liked 3 photos of Jane.'
Upvote (1)Share