educative.io

How to enforce strict order in pub-sub?

It seems like it’s easy to maintain the strict order in each partition. But how does consumer consume the msg in strict order given multiple partition?


Course: Grokking Modern System Design Interview for Engineers & Managers - Learn Interactively
Lesson: https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/design-of-a-pub-sub-system

Hi Ronaldo

Ordering events or requests in some specific order (say the chronological order) needs more machinery such as Paxos (see our content on consensus in Advanced System Design course https://www.educative.io/courses/grokking-the-principles-and-practices-of-advanced-system-design/int…).

Ordering in a queue or pub-sub means that if only one thread is extracting the data out, the order of data coming out is the same as going in. And that will be true for each partition individually. For any ordering across partitions, application will need to do more work.

In summary, ordering is usually not well-defined for use-cases utilizing a pub-sub. More work is needed for strict ordering globally.

Thank you

1 Like