简体   繁体   English

Kafka生产者,消费者,经纪人在同一主机上?

[英]Kafka Producer, Consumer, Broker in same host?

Are there any downsides to running the same producer and consumer code for all nodes in the cluster? 为集群中的所有节点运行相同的生产者和使用者代码是否有任何弊端? If there are 8 nodes in the cluster (8 consumer, 8 kafka broker, and 8 producers), would 8 producers be running at the same time in the cluster then? 如果集群中有8个节点(8个消费者,8个kafka代理和8个生产者),那么集群中是否有8个生产者同时运行? Is there a way to modify cluster so that only one producer runs at a time? 有没有一种方法可以修改群集,以便一次只运行一个生产者?

Kafka cluster is nothing but Kafka brokers running under a distributed consensus. 卡夫卡集群不过是在分布式共识下运行的卡夫卡经纪人。 Kafka cluster is agnostic about number of producers and consumers running around it. Kafka集群不了解围绕它运行的生产者和消费者的数量。 Producers and consumers are clients of the Kafka cluster. 生产者和消费者是Kafka集群的客户。 Producers will stream data to Kafka and consumers consume the data from Kafka. 生产者将向Kafka传输数据,而消费者则从Kafka消费数据。 Within Kafka cluster data will be distributed within topics. 在Kafka集群内,数据将在主题内分布。 Topics are sharded using partitions. 使用分区对主题进行分片。 If multiple consumers belong to the same consumer group consumers can work in a self healing fashion. 如果多个消费者属于同一消费者组,则消费者可以自我修复的方式工作。

Is there a way to modify cluster so that only one producer runs at a time? 有没有一种方法可以修改群集,以便一次只运行一个生产者?

If you intend to run a single producer at certain point of time, you don't need to make any change within cluster. 如果您打算在某个时间点运行单个生产者,则无需在集群中进行任何更改。

Are there any downsides to running the same producer and consumer code for all nodes in the cluster? 为集群中的所有节点运行相同的生产者和使用者代码是否有任何弊端?

The primary downsides here would be scalability and memory usage. 这里的主要缺点是可伸缩性和内存使用率。

Producers and Consumers are not required to run on Brokers. 生产者和消费者不需要在经纪人上运行。 Producers should be deployed where data is being generated (or running as separate hosts, like Kafka Connect workers). 生产者应部署在生成数据的地方(或作为独立的主机运行,例如Kafka Connect工作者)。

Consumers should be scaled out independently based on the throughput and ordering guarantees that you need in your downstream systems. 应根据您在下游系统中需要的吞吐量和订购保证,独立扩展消费者。

There is nothing that says 8 brokers requires 8 producers and 8 consumers; 没有什么可以说8个经纪人需要8个生产者和8个消费者。 partitions are what matters more 分区更重要

  • If you have N partitions in a topic, you can only scale to N active consumers anyway, and infinitely many producers 如果一个主题中有N个分区,则无论如何都只能扩展到N个活动的使用者,并且无限多个生产者
  • 8 brokers can hold lots of partitions for any given topic 8个经纪人可以为任何给定主题保留很多分区

Running a single producer is an implementation of your own code. 运行单个生产者是您自己的代码的实现。 The broker cannot force it. 经纪人不能强迫它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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