简体   繁体   中英

kafka replication factor less then broker count

I have a Kafka topic created with replication factor=2, partition count = 1 and brokers count = 3.

Will messages be correctly read if all 3 brokers are specified as bootstrap servers in consumer?

Can it be, that messages are not consumed, when consumer gets to a node, that doesn't have a replica? Or it doesn't work that way?

Kafka brokers are communicating internally which each other.

That means, if your consumer only knows about one of the brokers it will communicate with all brokers in the cluster to figure out on which broker the partition leader is located. Then your consumer will consume from that broker.

However, it is usually best to not only provide one of the broker addresses but rather more than one or even all addresses as a comma separated list in your consumer configuration bootstrap.servers . That way, even if one of the brokers goes down, your consumer will still be able to fetch the data.

Will messages be correctly read if all 3 brokers are specified as bootstrap servers in consumer?

Yes. However, each partition as a partition leader that sits on one of the brokers, so your consumer will only consume data from that one broker.

Can it be, that messages are not consumed, when consumer gets to a node, that doesn't have a replica?

No. As explained above, the brokers are communicating with each other to figure out on which broker the partition leader is located.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM