Skip to content

BuildBreak lab 3 of 15

Consumer group assignment

Scale a group from one to three consumers on six partitions, overshoot to eight, then find out what happens when two services share one group.id.

Foundation20 min

Read first: Consumer groups and partition assignment · Partition sizing and consumer parallelism

Simulation.This lab is a deterministic simulation. No Kafka broker is running; logs and metrics are simulated.

Brokers
3 (KRaft)
Topics
orders: 6 partitions, RF 3
Producers
order-service
Consumer groups
billing (1), order-email (0)
Guided run
7 stages: build → break → observe → fix → retest

1

Business scenario

The orders topic has six partitions and receives twelve orders a second. The billing service consumes it to raise invoices; one instance handles about five orders a second, so a single instance falls behind. The team wants to scale it out, and somebody suggests eight instances "to be safe". The same week a new email service goes live to send order confirmations. Its author copied billing's configuration, group.id included, and now some customers get no confirmation and some orders are never invoiced.

2

Starting architecture

Drawing diagram…

The order service producer writes to the orders topic, which has six partitions. The billing consumer group has three members; each member is assigned two partitions by the group coordinator, and every partition has exactly one owner.

flowchart LR
  OS["Order service producer"] --> T
  subgraph T["Topic orders with 6 partitions"]
    P0["P0"]
    P1["P1"]
    P2["P2"]
    P3["P3"]
    P4["P4"]
    P5["P5"]
  end
  subgraph G["Consumer group billing"]
    B1["billing-1"]
    B2["billing-2"]
    B3["billing-3"]
  end
  P0 --> B1
  P1 --> B1
  P2 --> B2
  P3 --> B2
  P4 --> B3
  P5 --> B3
  GC["Group coordinator"] -.->|"assigns partitions"| G
Six partitions shared by a group of three: each partition belongs to exactly one member of the group at a time.

3

Expected behaviour

  • Within one group, every partition is read by exactly one member, so every order is processed once by billing.
  • Adding members up to the partition count adds throughput. Members beyond the partition count get nothing to do.
  • Each service that needs every order has its own group and its own committed offsets, so billing and email both see the whole stream.

4 · Build → break → observe → fix → retest

Guided run

buildStage 1 of 7

One consumer is not enough

Do this

  1. Turn on Order service publishing (12 orders per second) and press play.
  2. Watch the billing group panel: one member owns all six partitions.

Look for

  • "Billing throughput" settles near 5 records per second while 12 arrive, so "Billing lag" climbs steadily.
  • Lag is per partition: every one of the six is falling behind.

Not done yet. The simulator checks this for you:lag("billing") >= 30

Simulator

Simulation · not a real cluster
simulated time 0.0s
Speed

Controls for this stage

12 orders per second across six partitions.

Consumer group billing

stablegeneration 1lag 0

RangeAssignor (eager)commit after batchmax.poll.records 20

  • billing-1runningprocessed 0
    orders-0orders-1orders-2orders-3orders-4orders-5
Partitions of group billing: owner, committed offset and lag
PartitionOwnerCommittedLag
orders-0 billing-1none0
orders-1 billing-1none0
orders-2 billing-1none0
orders-3 billing-1none0
orders-4 billing-1none0
orders-5 billing-1none0

Consumer group order-email

stablegeneration 1lag 0

RangeAssignor (eager)commit after batchmax.poll.records 20

No members.

Partitions of group order-email: owner, committed offset and lag
PartitionOwnerCommittedLag
orders-0 unownednone0
orders-1 unownednone0
orders-2 unownednone0
orders-3 unownednone0
orders-4 unownednone0
orders-5 unownednone0

Simulated metrics

computed by the simulation
Orders acknowledged
0
Billing throughput
0records/s
Billing lag
0records
Idle billing consumers
0
Orders processed by billing
0
Orders processed by email
0
Orders billing never saw
0
Orders email never saw
0

Partition logs

simulated records
  • orders-0leader b1ISR 1,2,3HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

  • orders-1leader b2ISR 2,3,1HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

  • orders-2leader b3ISR 3,1,2HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

  • orders-3leader b1ISR 1,2,3HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

  • orders-4leader b2ISR 2,3,1HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

  • orders-5leader b3ISR 3,1,2HW 0end 0

    empty

    billing: committed none, lag 0 · order-email: committed none, lag 0

dashed = above the high watermark (not replicated, not readable)dim = committed by every groupviolet = same event written twice

Simulated log

newest first · not real broker output
  1. 0.0sINFO [simulation] Simulated cluster ready: 3 brokers, orders (6 partitions, RF 3). KRaft mode, no ZooKeeper

The root cause, the solution with its code, and what the simulation leaves out appear when you finish the last stage.