[Redis] How are MessageBus and Redis working

Hi All,

I kind of started investigating how, Redis is used with Discourse and this lead me to MessageBus gem,

And looking into the gem as well as the code, I can see is used to interface with Redis its self via another Gem called Redis,

Can someone please explain how all this interact, and why there is a need for MessageBus, instead just use Redis ruby Gem ?


MessageBus and Redis serve very different purposes.

Redis is an in-memory database, used to store state on the server that is more or less volatile. Some examples are scheduled jobs, session data, rate limiting data, …

MessageBus is a system that is used to push messages to the client. For example, if you’re on Discourse while someone replies here, you’ll see a blue number appear an your avatar immediately – that piece of information was sent from the server to your browser through MessageBus.


@fefrei Thanks for replying.

And I kind of get the purpose of Redis, but I also know that it has a supports for pub/sub architecture. And I was under the impression that MessageBus, was using Redis gem to publish messages on Redis,

And also following your answer, how does MessageBus keeps track of the state if , in your example the blue bar appearing if someone is replying to my message.


For questions about MessageBus internals, @sam likely is the right person to ask :slight_smile: