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. 教育用モデルです。数値は挙動を示すためのもので、ベンチマークではありません。

コンセプト

関連する課題

参考資料