The Real Fullstack

The Out-of-Order Delivery

The customer cancelled after paying. Why did the warehouse process the payment last — and ship?

工程师8 分钟流程模拟器时间线模拟器
kafkajavaspring-kafka

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务:Guarantee per-order ordering while keeping enough parallelism to handle 3,000 events per second.背景 · 学习目标 ▾

Brightcart publishes OrderCreated, OrderPaid and OrderCancelled events to a 12-partition Kafka topic. The warehouse consumer occasionally applies them in the wrong order: a cancel is overwritten by a later-processed “paid”, and the order ships.

任务: Guarantee per-order ordering while keeping enough parallelism to handle 3,000 events per second.

学习目标

  • Know that Kafka orders messages only within a partition.
  • Choose a partition key that matches your ordering requirement.
  • Avoid breaking ordering with parallel processing inside a partition.
模拟模拟数据

运行模拟以查看输出。

运行模拟
kafka.send("order-events", event);   // no key → spread across partitions (sticky/round-robin)// OrderCreated → partition 3, OrderPaid → partition 7, OrderCancelled → partition 1

简化说明

Violation counts are illustrative. Each partition's consumer handles 600 events/s. 教学模型——数字用于说明行为,并非基准测试。

概念

相关挑战

参考资料