问题
Kafka replicates each partition of a topic up-to specified replication factor.
As far as I know, all write and read requests are routed to the leader of the partition. Is there any way to consume from the followers not from the leader?
Is the replication in Kafka only for fail-over?
回答1:
In Kafka 2.3 and older, you can only consume from the leader -- this is by design. Replication is for fault-tolerance only.
If leader fails, the followers will elect a new leader.
Have a look at this blog post for more details: http://www.confluent.io/blog/hands-free-kafka-replication-a-lesson-in-operational-simplicity/
Update:
As of Kafka 2.4, fetching from follower replicas is possible. For details, check out KIP-392: https://cwiki.apache.org/confluence/display/KAFKA/KIP-392%3A+Allow+consumers+to+fetch+from+closest+replica
来源:https://stackoverflow.com/questions/37803376/consuming-from-a-replica