yun_man_ger
yun_man_ger

Reputation: 343

DB solution for user activity feed

I am wokring on a project where user activity feed generation is needed. If user A follows user B and user B does some activity user A see it on his homepage.

Now I am looking for a DB solution for persisting user feed. Once user B commits some action all users who follow user B will receive a record. I think saving a mongodb document for a user with a list of object references will be better than saving a document for each feed record.

On the other hand, there will be many writes and even more reads and mongodb has a lock on a collection. Maybe this might be a problem. Or maybe Redis could be used for this. And redis having something with concurrency. I am not much experienced in both.

The summary question is what would be better to use for this task: Mongo, Redis or something else?

Thank you!

Upvotes: 7

Views: 7572

Answers (3)

Dwight Gunning
Dwight Gunning

Reputation: 2525

Cassandra is a proven choice for self-hosting activity feeds although it is typically considered complex to run and operate.

Nowadays there are 3rd party / hosted options such as GetStream.io and DynamoDB.

Upvotes: 2

Geert-Jan
Geert-Jan

Reputation: 18905

see the blogpost: http://www.waistcode.net/blog/mongodb-newsfeed-schema-design-for-entexis which exactly describes what you're looking for. IMHO: it's really elegant.

I was pointed to that blogpost through a related question ( MongoDB database schema design ) a couple of days ago.

hth.

Upvotes: 8

brycemcd
brycemcd

Reputation: 4513

Be sure to evaluate neo4j. It was created for many of the same use cases you're describing.

Upvotes: 2

Related Questions