简体   繁体   English

Kafka 主题的理想分区数

[英]Ideal number of partitions for Kafka topic

I am currently working on a setup which has 6 kafka-brokers , Data is being pushed into my topic from two producers at a rate of about 4000 messages per second, I have 5 Consumers for this topic working as a group.我目前正在研究一个有 6 个kafka-brokers的设置,数据正以每秒大约 4000 条消息的速度从两个producers推送到我的topic中,我有 5 个Consumers作为一个小组工作。 What should be the ideal number of partitions of my kafka topic ?我的kafka topic的理想分区数应该是多少?

Please feel free to tell me if any change is required in brokers/consumers/producers as well.如果brokers/consumers/producers也需要任何更改,请随时告诉我。

In general more the partitions - more the throughput.一般来说,更多的分区 - 更多的吞吐量。 However there are other considerations too like the limits of hardware you are running on, whether you are using compression etc. There is a good enough information from Confluent here which provides you insight into rough calculation you can use to arrive at number of partitions.但是,还有其他考虑因素,例如您运行的硬件的限制,您是否使用压缩等。Confluent提供了足够好的信息,可以让您深入了解粗略的计算,您可以使用它来得出分区数量。

A rough formula for picking the number of partitions is based on throughput.选择分区数量的粗略公式基于吞吐量。 You measure the throughout that you can achieve on a single partition for production (call it p) and consumption (call it c).您可以测量在单个分区上可以实现的生产(称为 p)和消费(称为 c)的吞吐量。 Let's say your target throughput is t.假设您的目标吞吐量是 t。 Then you need to have at least max(t/p, t/c) partitions.然后你需要至少有 max(t/p, t/c) 个分区。 The per-partition throughput that one can achieve on the producer depends on configurations such as the batching size, compression codec, type of acknowledgement, replication factor, etc.在生产者上可以实现的每个分区的吞吐量取决于诸如批处理大小、压缩编解码器、确认类型、复制因子等配置。

Moreover for consumer此外对于消费者

The consumer throughput is often application dependent since it corresponds to how fast the consumer logic can process each message消费者吞吐量通常取决于应用程序,因为它对应于消费者逻辑处理每条消息的速度

So the best way is to measure and benchmark for your own use case因此,最好的方法是针对您自己的用例进行衡量和基准测试

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

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