Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka - min.insync.replicas interpretation

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 ?

like image 720
Nag Avatar asked Jun 11 '20 14:06

Nag


1 Answers

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.

like image 53
Chris Matta Avatar answered Nov 08 '22 12:11

Chris Matta