Skip to content

Instantly share code, notes, and snippets.

@markpapadakis
Last active February 18, 2019 20:42
Show Gist options
  • Save markpapadakis/5c0e0ee74fe5fcc4d06fd87563c29236 to your computer and use it in GitHub Desktop.
Save markpapadakis/5c0e0ee74fe5fcc4d06fd87563c29236 to your computer and use it in GitHub Desktop.

Suppose topic with a partition P0.

  1. Producer PR1 publishes a message to P0 with required acks = 2 (two peers from the replicas set, aside from leader, needs to ack. it before the update is considered committed). Producer PR1 is waiting for ack from the leader. That message’s LSN is going to be 100.
  2. Producer PR2 publishes a message to P0 with required acks = 1(one peer from the replicas set, aside from the leader, needs to ack. it before the update is considered committed). Producer PR2 is waiting for ack from the leader. That message’s LSN is going to be 101
  3. One Peer asks to consume from x(< 100) and then immediately asks to consume from 102. Other peers in the replicas set are busy and haven’t gotten to consume any updates yet(but not too busy as to be expelled from the ISR).

What happens now? Is PR2 getting acknowledged (because one peer consumed > 101 and acks == 1 and PR's message LSN = 101) ? Or, will Kafka wait for all messages before it to be aknowledgd (e.g the message from PR1 with LSN 100) before acknowledging the message from PR2 with LSN 101?` That is to say, will it respond to PR2 with an acknowledgement before PR1 is provided an acknowledgement, considering that PR1's message LSN < PR2's message LSN?

@gwenshap
Copy link

Ah, yeah. It is one of the things that make sense when you get used to it, but very confusing at first. We get LOTS of support calls with "my producer got an ack, why didn't the consumer see the message immediately?".

This is why it is so important to measure "produce to consume" latency as well as "producer to broker" latency.

@gwenshap
Copy link

... and I just realized that min.isr is set at topic level, not producer level... so the scenario is quite imaginary... but it was interesting to think through anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment