The Real Fullstack

The Out-of-Order Delivery

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

Ingeniero8 minSimulador de flujosSimulador de línea de tiempo
kafkajavaspring-kafka

Este reto aún no está traducido al Español. Estás leyendo la versión en inglés.

Misión:Guarantee per-order ordering while keeping enough parallelism to handle 3,000 events per second.Contexto · Objetivos de aprendizaje ▾

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.

Misión: Guarantee per-order ordering while keeping enough parallelism to handle 3,000 events per second.

Objetivos de aprendizaje

  • 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.
SimulaciónSimulado

Ejecuta la simulación para ver la salida.

Ejecutar simulación
kafka.send("order-events", event);   // no key → spread across partitions (sticky/round-robin)// OrderCreated → partition 3, OrderPaid → partition 7, OrderCancelled → partition 1

Simplificación

Violation counts are illustrative. Each partition's consumer handles 600 events/s. Modelo educativo: los números ilustran un comportamiento, no son benchmarks.

Conceptos

Retos relacionados

Referencias