Dionysian
Dionysian

Reputation: 1235

Redis pubsub and twitter like newsfeed?

I checked out Redis pub/sub functionality and at first glance it looks perfect for something like forming a twitter feed. However I tried to google for Redis pub/sub and newsfeed and I can barely find any example or use case about this. If Redis is actually not good for this, what are the disadvantages?

Upvotes: 1

Views: 1421

Answers (1)

kris.jeong
kris.jeong

Reputation: 99

First of all, Redis pub/sub is not a data storage, but just a data flow channel.

For example(Chronologically sequenced)

  1. You create a channel named news:feed
  2. User A joins news:feed
  3. User B publishes to news:feed

This scenario works fine. But the following doesn't:

  1. You create a channel named news:feed
  2. User B publishes to news:feed
  3. User A joins news:feed

In this case, user A will never receive the message published by User B, before he (A) joined.

If you want to implement newsfeed using pub/sub, you have to create several channels (at least as many as users). Here is an implementation of a simple Twitter clone: http://redis.io/topics/twitter-clone

Upvotes: 2

Related Questions