从副本消费 [英] Consuming from a replica

查看:18
本文介绍了从副本消费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kafka 将主题的每个分区复制到指定的复制因子.

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?

Kafka 中的复制是否仅用于故障转移?

Is the replication in Kafka only for fail-over?

推荐答案

在 Kafka 2.3 及更早版本中,您只能从领导者那里消费——这是设计使然.复制仅用于容错.

In Kafka 2.3 and older, you can only consume from the leader -- this is by design. Replication is for fault-tolerance only.

如果leader失败,其中一个follower会被选为新leader.

If the leader fails, one of the follower will be elected as a new leader.

查看这篇博文了解更多详情:http://www.confluent.io/blog/hands-free-kafka-replication-a-lesson-in-operational-simplicity/

Have a look at this blog post for more details: http://www.confluent.io/blog/hands-free-kafka-replication-a-lesson-in-operational-simplicity/

更新:

从 Kafka 2.4 开始,可以从跟随者副本中获取.详情请查看 KIP-392:https://cwiki.apache.org/confluence/display/KAFKA/KIP-392%3A+Allow+consumers+to+fetch+from+closest+replica

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

这篇关于从副本消费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆