Kafka中多个partition怎么保证跨区消费是有序的

@Author  : Spinach | GHB
@Link    : http://blog.youkuaiyun.com/bocai8058

官方说明

这个问题严格来说是肯定有的,kafka只能保证分区内的有序性。

下面是kafka作者Jay Kreps的blog中介绍kafka设计思想的一段话:

Each partition is a totally ordered log, but there is no global ordering between partitions (other than perhaps some wall-clock time you might include in your messages). The assignment of the messages to a particular partition is controllable by the writer, with most users choosing to partition by some kind of key (e.g. user id). Partitioning allows log appends to occur without co-ordination between shards and allows the throughput of the system to scale linearly with the Kafka cluster size.

(每个分区都是一个完全有序的日志,但是分区之间没有全局排序(除了你的消息中可能包含的一些挂钟时间)。将消息分配给特定分区是可由编写者控制的,大多数用户选择通过某种密钥(例如用户id)进行分区。分区允许在没有分片之间协调的情况下发生日志追加,并允许系统的吞吐量与Kafka群集大小线性地扩展。)

解决方法

严格说,kafka是无法保证全局消息有序的,没有这个机制,只能局部有序。

但是如果只有一个分片和一个消息的生产者,那么就相当于消息全局有序了。如果有多个消息生产者,就算只有一个分片,如果这些生产者的消息都发给这个分片,那kafka中的消息连局部有序都没有办法了。


评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小学僧来啦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值