Cloud Parts

Event-driven order processing

Checkout publishes one event to Kafka; payments, inventory and email each consume it at their own pace.

Fits: Several teams owning separate services around shared business events3 technologies
Live model
What you’re watchingCheckout appends order events to one Kafka topic. Three consumers read it independently: watch the email sender fall behind and catch up in bursts while payments keeps pace.

Click any box to open its page. Open it in the playground to rewire it, change the traffic or take parts down.

Instead of the checkout service calling payments, inventory and email one after another, and failing if any of them is slow, it records a single fact (“order placed”) in a Kafka topic and returns. Each downstream service reads the topic with its own offset. A slow email sender falls behind without holding anyone else up, and a new service can be added later and replay the history from the start.

How it flows

  1. 1

    Checkout records one event

    When an order is placed, checkout appends an OrderPlaced event, keyed by order id, to the orders topic and responds to the customer. It doesn’t know or care who reads it.

    Checkout APIApache Kafka
  2. 2

    Each consumer keeps its own place

    Payments, inventory and email are separate consumer groups. Kafka tracks an offset for each, so they read the same events independently and at different speeds.

    Payments serviceInventory serviceAWS Lambda
  3. 3

    Slow consumers catch up later

    The email sender polls every couple of seconds and takes several events at once. It’s often behind, which is fine: the events wait in the topic, and nothing upstream slows down.

  4. 4

    Results go to each service’s own store

    Payments writes charges to its own PostgreSQL database. Services never share a database; if one needs another’s data, it reads the events or publishes its own.

    Payments servicePostgreSQL

Why this shape works

  • Services are decoupled in time: one being slow or down doesn’t break checkout
  • Adding a consumer (fraud checks, analytics) needs no change to checkout
  • The topic is a replayable history, useful for rebuilding a service’s state or backfilling a new one
  • Keying by order id keeps each order’s events in order within a partition

Where it strains

  • Consumers must be idempotent: after a crash, Kafka redelivers events since the last committed offset
  • Eventual consistency: right after checkout, inventory may not have reserved stock yet
  • Tracing one order across services needs correlation ids and good observability
  • Event schemas become a contract between teams; change them carefully, with a schema registry and Avro or Protobuf

Common swaps

Built from

Architectures with parts in common

Improve this page on GitHub