coulix
coulix

Reputation: 3368

Redis PUBLISH and order of messages

If two separate clients do a PUBLISH on the same channel, can I assume that the order in which the subscribers will be informed will be respected ?

Since redis is singlethreaded it should but I want to make sure it does not process both PUBLISH in parallel.

Upvotes: 3

Views: 2189

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230541

Yes, PUBLISH is a synchronous command. It does not return until it pushes the message to all subscribers. And different PUBLISH commands are naturally serialized in Redis request queue.

Time complexity: O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).

Upvotes: 4

Related Questions