Try
↑ ↓ move↵ openesc close

Interview prep / Partitioned logs

Junior · Partitioned logs · System design interview question

Billing and analytics both need every event from the orders topic. How do you set up the consumers?

Sketch your own answer first, then compare it with the one below.

A strong answer

Give each service its own consumer group. A group gets a full copy of the stream, and the members inside it split the partitions. So the billing group and the analytics group each see every event, and each keeps its own committed offsets.

Putting both services in one group would be a mistake: the group would split the messages, so billing would see some orders and analytics the rest.

Because the groups are independent, they can run at different speeds. Analytics may batch and fall minutes behind while billing stays current. The one coupling is retention: if analytics falls further behind than the log keeps data, it loses events, so alarm on its lag.

Each group should be sized to the partition count. If the topic has 12 partitions, 12 is the useful maximum per group.

Sources

Learn it by running it

The partitioned logs lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms