liveBook · Manning

Ordering guarantee

As explained in Apache Kafka in Action

An ordering guarantee is a promise that records are observed in a specified sequence, such as their order within a partition.

An ordering guarantee preserves records in arrival order within a partition. It does not establish one sequence across partitions, so parallelism can change what a consumer observes globally. section 6.1.1

Use these conditions when record order matters:

  • Send related records from the same producer to the same partition; records from different producers or partitions have no guaranteed relative order. section 6.1.1
  • Enable idempotence so retries and failures do not disrupt ordering through duplicate or confused producer sequences. section 6.1.1
  • Assign each partition to only one instance within a consumer group when scaling a service while retaining its order guarantees. section 4.2.2
  • Do not equate partition order with ascending timestamps: CreateTime, LogAppendTime, event time, and stream time answer different questions. section 12.5.1

Scaling product-price processing

A product-price topic can distribute partitions across instances in one consumer group. Each instance processes its assigned partition in order, while separate groups independently read the same data. A second producer or a different partition does not preserve a shared sequence. section 4.2.2

Table 12.3 Streaming times

Time

Responsibility

Meaning

Event time

Our code

The time at which an event occurred

Create time

Producer

The time at which the message was created by the producer

Log append time

Broker

The time at which the message was written to the log by the broker

Stream time

Stream processor

The time at which a message is processed

Compare event, producer-creation, broker-append, and stream-processing times before designing time-window operations around ordering. section 12.5.1

How Apache Kafka in Action covers it

How deep it goes
Explains partition scope, producer affinity, idempotence, consumer ownership, and timestamp limits, but not a cross-partition ordering mechanism.
Examples
Demonstrates product-price records distributed among consumer instances and contrasts partition order with CreateTime, LogAppendTime, event time, and stream time.
What it assumes
Assumes familiarity with Kafka topics and partitions while introducing consumer groups, offsets, idempotence, and Kafka timestamp types.
What you can do after
Operate Kafka consumers and producers with partition affinity, idempotence, and consumer-group assignments suited to ordered processing.
How it connects
Connects partitions, producers, idempotence, retries, consumer groups, timestamps, and stream processing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.