当我按键对数据进行分区,然后在 Kafka 的主题中添加一个新分区时会发生什么? [英] What happens when I partition data by key and then later on add a new partition to the topic in Kafka?

查看:23
本文介绍了当我按键对数据进行分区,然后在 Kafka 的主题中添加一个新分区时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按键对数据进行分区,然后在 Kafka 的主题中添加一个新分区时会发生什么?

What happens when I partition data by key and then later on add a new partition to the topic in Kafka?

现有记录会有任何变化吗?未来的数据将如何分区?

Will there be any change to the existing record? And how will the future data be partitioned?

推荐答案

将新分区添加到特定主题时,现有数据的分区不会改变.Kafka 不会尝试重新分发现有记录,并且这种修改只会对新记录产生影响.请注意,默认情况下,Kafka 使用 hash(key) % noOfPartitions 对数据进行分区,以确保将具有相同键的记录添加到同一分区.具有不同键的数据将以循环方式添加到分区中.

Partitioning of existing data doesn't change when new partitions are added to a particular topic. Kafka will not attempt to re-distribute existing records and this modification will only have effect on new records. Note that by default, Kafka partitions data using hash(key) % noOfPartitions in order to ensure that records with the same key are added to the same partition. Data with different key will be added to partitions in a round-robin fashion.

这篇关于当我按键对数据进行分区,然后在 Kafka 的主题中添加一个新分区时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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