Skip to content

PATTERN Cited by 1 source

Stream-connection-as-ordering-unit

Definition

Stream-connection-as-ordering-unit is the pattern of binding message ordering guarantees to the logical identity of a producer's network connection (stream) rather than to a fixed partition assignment. In this model, a producer opening a connection to the service gets a "your stream is ordered" contract — regardless of which backend pod processes the messages — instead of the traditional "your partition is ordered" contract of Kafka-style message buses.

Why it exists

In traditional message-bus architectures (Kafka, Pulsar, Kinesis), partitions are the unit of both parallelism AND ordering. This coupling creates three structural problems:

  1. Adding/removing partitions breaks ordering. The routing function that maps producers to partitions changes; consumers must reconcile.
  2. Partition topology is treated as immutable. Teams provision for peak load and carry that infrastructure forever. You can add partitions but typically cannot safely decrease them.
  3. Scale-down is architecturally blocked. Removing partitions invalidates ordering assumptions downstream.

By moving the ordering guarantee from the partition to the stream connection, the system decouples parallelism from ordering, enabling true elastic autoscaling.

Mechanism

  1. Producer opens a gRPC stream (connection) to the service — this registers a logical identity.
  2. For the lifetime of that connection, data arrives in order regardless of which pod processes it.
  3. Backend pods are a pool; routing is heuristic-based (see patterns/hot-routing-autoscale).
  4. Pods can be added (demand spike) or removed (demand drop) without affecting ordering guarantees for existing streams.

Trade-offs

Advantage Cost
True elastic autoscaling (up and down) Ordering scope limited to single connection lifetime
No partition topology planning Consumer-side global ordering requires external coordination
No "provision for peak" waste Connection failures reset ordering context
Simpler producer API System must manage connection routing centrally

Seen in

Last updated · 542 distilled / 1,571 read