admin管理员组文章数量:1302379
If I set acks=0 in Kafka, my producer will write messages one after another without waiting for any acknowledgment from the leader broker or the replicas/followers. However, my question is whether a consumer can start reading these messages before the leader synchronizes with the followers.
Specifically, if the producer sends messages continuously, can the consumer read them immediately, or does the leader need to synchronize with the followers first before the consumer can access the messages?
Could you please point me to the relevant Kafka documentation that addresses this?
If I set acks=0 in Kafka, my producer will write messages one after another without waiting for any acknowledgment from the leader broker or the replicas/followers. However, my question is whether a consumer can start reading these messages before the leader synchronizes with the followers.
Specifically, if the producer sends messages continuously, can the consumer read them immediately, or does the leader need to synchronize with the followers first before the consumer can access the messages?
Could you please point me to the relevant Kafka documentation that addresses this?
Share Improve this question asked Feb 10 at 19:55 Ciprian Ciprian 731 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 0As you said, if ack set to 0, producer will not wait for a response from the broker and that message will be immediately available for consumers to read. In short ack value means "how many brokers should the producer wait to receive a response?". Those brokers are "in sync"
brokers for that topic.
Then what is in-sync brokers? In-sync brokers keep data synchronously, unlike replication brokers. A replicated data may be written to other brokers a few minutes, or hours later but that is not the case for in-sync brokers. It is defined by min.insync.replicas
parameter. By default it's 1, meaning only 1 broker has the synced message.
It matters for ack's too, since ack value can not be higher than in.sync.replicas
. If your ack
is 2 and in.sync.replicas
3, producer is going to wait for the broker it directly connected and 1 other sync broker to complete the producing process.
In short;
- When
ack
is 0, the message will be immediately available to consume, regardless of the number ofin.sync.replicas
orreplication.factor
. - When
ack
is 1 (by default), producer is going to wait for the acknowledgement from the broker it is connected. - When
ack
is more than 1 (let's say 3),in.sync.replicas
must be equal or greater than ack value. The producer is going to wait for the acknowledgement from the brokers with a total number given in ack parameter. These brokers are called "in sync" brokers. - ack ≤ in.sync.replicas ≤ replication.factor
For documentation:
https://docs.confluent.io/kafka/design/replication.html#in-sync-replicas-and-producer-acks https://docs.confluent.io/platform/current/installation/configuration/topic-configs.html#min-insync-replicas
本文标签:
版权声明:本文标题:Can a Kafka consumer read messages immediately when acks=0, before the leader syncs with followers? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741693671a2392879.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论