17

I am going through the documentation looking at multiple places, it is adding up confusion..

About the property min.insync.replicas

When a producer sets acks to "all" (or "-1"), this configuration specifies the minimum number of replicas that must acknowledge a write for the write to be considered successful. If this minimum cannot be met, then the producer will raise an exception (either NotEnoughReplicas or NotEnoughReplicasAfterAppend). When used together, min.insync.replicas and acks allow you to enforce greater durability guarantees. A typical scenario would be to create a topic with a replication factor of 3, set min.insync.replicas to 2, and produce with acks of "all". This will ensure that the producer raises an exception if a majority of replicas do not receive a write.

The questions I had,

  1. Is this property had the meaning only if it is used with "acks" as part of "Sending the record" ( Producer) OR does it have any influence as part of the Consumer flow as well ?
  2. What if acks=all and min.insync.replicas = 1(default value :1 ) --> Is it same as acks = 1 ? ( considering replication-factor 3 ?

Update #1 I come across this phrase

"When a producer specifies ack (-1 / all config) it will still wait for acks from all in sync replicas at that moment (independent of the setting for min in-sync replicas). So if you publish when 4 replicas are in sync then you will not get an ack unless all 4 replicas commit the message (even if min in-sync replicas is configured as 2)."

how this phrase is relevant as of today ?Is this property "min in-sync replicas" still independent ?

1 Answer 1

44

There are two settings here that affect the producer:

  • acks - this is a producer-level setting
  • min.insync.replicas - this is a topic-level setting

The acks property determines how you want to handle writing to kafka:

acks=0 - I don't care about receiving acknowledgment of receipt acks=0 illustration

acks=1 - Send an acknowledgment when the leader partition has received the batch in memory acks=1 illustration

all/-1 - Wait for all replicas to receive the batch before sending an acknowledgment acks=all illustration

Keep in mind, the receipt in the partition is in memory, Kafka by default doesn't wait for fsync to disk, so acks=1 is not a durable write!

min.insync.replicas is used when there is a problem in the topic, maybe one of the partitions is not in-sync, or offline. When this is the case the cluster will send an ack when min.insync.replicas is satisfied. So 3 replicas, with min.insync.replicas=2 will still be able to write: enter image description here

The acks property has no affect on the consumers, just that the data won't be written until acks and min.insync.replicas is satisfied.

What if acks=all and min.insync.replicas = 1(default value :1 ) --> Is it same as acks = 1 ? ( considering replication-factor 3 ?

Only if there is a problem with the topic. If you have 3 replicas and min.insync.replicas=1 and two of the partitions are down this is the same as acks=1. If the topic is healthy, the producer will wait for all replicas before sending the ack.

11
  • Does this mean - "If the topic is healthy, the producer will wait for all replicas before sending the ack" - independent of the setting "min.insync.replicas"? Basically, i wanted to understand does "min.insync.replicas" have any impact on "Acks" setting ?
    – Nag
    Commented Jun 11, 2020 at 17:50
  • It only has an impact if in sync replicas < total number of replicas for the topic. Commented Jun 11, 2020 at 18:24
  • 6
    So , in summary - acks = all will send the acknowledgement if at least ""min.insync.replicas" responded back with the response. To quantify "atleast", it depends on the topic health. If all replicas(brokers) are functioning properly, ack will only be sent if all replicas are responds back with a response. IF not , atleast "min.insync.replicas" should respond back .
    – Nag
    Commented Jun 12, 2020 at 3:07
  • 1
    yep, looks like you got it Commented Jun 12, 2020 at 14:10
  • 1
    @viji Consumers will still be able to consume messages, the topic will not be unavailable, but producers will not be able to produce until min.isr in satisfied Commented Jul 1, 2021 at 15:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.