Kafka: Consumer Groups in Depth
Tested 2026-11-30 on Ubuntu 22.04.4 LTS host (Linux 6.8), 4-core Arm Neoverse-N1 (aarch64), 23 GB RAM; Docker Engine 29.1.3 · with Apache Kafka 4.4.0 (apache/kafka:4.4.0, 3 KRaft nodes), kafka-clients 4.4.0, Eclipse Temurin JDK 25.0.5 (eclipse-temurin:25.0.5.1_2-jdk), Docker Engine 29.1.3 · by Vivek Sahu (@viv1) · CC BY 4.0
Your shop sends 200 orders a second to Kafka, and your billing service takes 10 ms to charge each one.
One copy can’t keep up: it was 9,313 orders behind after 80 seconds, and falling further.
Three copies in one consumer group share the work: under 900 behind at each of four checks.
Until a member joins, leaves or restarts. Then the group rebalances, and by default every member stops, all waiting for one busy member: up to one of its batches, 5 s here (in 26 runs, from almost nothing to 4.4 s without an order read).
There are ways to move only what must move, and the bookmark each group keeps has rules of its own: when it is written decides whether a crash bills a customer twice or not at all.
This course is for someone who has produced and consumed messages (the console tools, a simple client) but never looked inside a consumer group. Lesson 1 recaps only what groups rest on: partitions, offsets and the poll loop. Every number here comes from runs on a real three-broker cluster; in the practicals you run the same mechanisms on your own.
By the end you’ll be able to:
- explain, from runs you watched, how a group shares out partitions: the coordinator, the assignors, static membership;
- say what committing an offset guarantees, and where duplicates and lost messages come from, auto-commit included;
- explain why a rebalance pauses consumers, and how eager, cooperative and the new protocol (KIP-848) differ;
- read a group’s lag and tune it in production:
max.poll.interval.ms, session timeouts, and what lag does and doesn’t tell you.
How it works
Each lesson starts with the problem, then an animated picture you step through (press Play, or use the
arrow keys), then the mechanism with real output, and Go deeper sections for the details. Each practical has
you write the Java yourself, as single-file programs run with java File.java: requirements, a hint, a hidden
solution, “predict first” questions, and a part where you break it. One script, ./lab, does the rest:
./lab setup p0starts three Kafka 4.4.0 brokers in Docker containers, on a network of their own, and downloads the Kafka client jars from Maven Central, checking each one’s SHA-256../lab check pNtells you whether your work is right. It only reads your files (and runs your program in a group of its own: once for p0, killed and restarted for p1)../lab reset pNremoves this course’s containers and volumes (only those) and starts them again; your files stay.
All you need is Docker. Java runs in a container too (Eclipse Temurin JDK 25), and nothing is published on a port of your computer. The two images are a 400 MB download, once, and take about 1.4 GB of disk.
Path
| Lesson | Practical | You’ll be able to |
|---|---|---|
| 1 · One topic, many readers | say what a group shares out, what it doesn’t, and what its bookmarks are | |
| 2 · Who gets which partition | 0 · Your cluster and a group you can watch | find a group’s coordinator, and watch eager, cooperative, new-protocol and static rebalances |
| 3 · What a commit really guarantees | say what a crash repeats or skips for each way of committing, and where a group with no bookmark starts | |
| 4 · Consumer groups in production | 1 · Capstone: a consumer you can trust | tell a dead member from a stuck one, read lag, and pick the setting to change; then count what each way of committing repeats and loses when you kill your own consumer |
What your folder will look like
~/kafka-groups/
├── lab the lab script: ./lab setup|check|reset pN (Practical 0)
├── lab.log every command ./lab ran, with its output
├── run ./run File.java: your Java programs, in a JDK container on the course network
├── kafka ./kafka <tool>: Kafka's command-line tools, inside broker kcg-1
├── lib/ kafka-clients 4.4.0 and its logger (./lab setup p0)
├── Watcher.java a member that prints what it owns and reads (Practical 0)
└── sink/ the capstone (Practical 1): empty at first
├── OrderSink.java processes each order into a file, committing as you tell it
└── auto-1.txt ... one file per run: <order number> <partition> <offset> a line