在 producer/consumer 个客户端中绕过 Zookeeper?

Bypass Zookeeper in producer/consumer clients?

这是 的后续问题。我将 Zookeeper 视为 Kafka 代理实例的协调器,或 "message bus"。我理解为什么我们可能希望 producer/consumer 客户端通过 Zookeeper 进行交易——因为 Zookeeper 具有内置的容错功能,可以确定与哪个 Kafka 代理进行交易。但是对于新模型——即 0.10.1+——我们是否应该始终在我们的 producer/consumer 客户端中完全绕过 Zookeeper?我们这样做是否会放弃任何优势(例如,更好的容错能力)?还是 Zookeeper 最终还在幕后工作?

Zookeeper 仍在幕后工作,但 0.9+ 客户端不再需要担心它,因为消费者偏移量现在存储在 Kafka 主题中而不是在 zookeeper 中。

补充一下 Hans Jespersen 的回答,最近的 Kafka producer/consumer 客户端(0.9+)不再与 ZooKeeper 交互。

如今,ZooKeeper 仅供 Kafka 代理(即 Kafka 的服务器端)使用。这意味着你可以,例如锁定客户端对所有 ZooKeeper 实例的外部访问以提高安全性。

I understand why we might want producer/consumer clients transacting through Zookeeper -- because Zookeeper has built-in fault-tolerance as to which Kafka broker to transact with.

Producer/consumer 客户端未通过 ZooKeeper "transacting",见上文。

But with the new model -- ie, 0.10.1+ -- should we always bypass Zookeeper altogether in our producer/consumer clients?

如果您提出问题的动机是因为您想实现自己的 Kafka 生产者或消费者客户端,那么答案是:您的自定义客户端不应再使用 ZooKeeper。官方 Kafka producer/consumer 客户端(Java/Scala)或例如Confluent's C/C++, Python, or Go clients for Kafka 演示如何通过利用 Kafka 功能(而不是必须依赖 ZooKeeper 等单独的服务)来实现可伸缩性、容错等。

Are we giving up any advantages (Eg, better fault-tolerance) by doing that? Or is Zookeeper ultimately still at work behind the scenes?

不,我们不会在这里放弃任何优势。否则,Kafka 项目不会更改其 producer/consumer 客户端以停止使用 ZooKeeper 并开始将 Kafka 用于其内部工作。

ZooKeeper 只是还在幕后为 Kafka brokers 工作,见上文。