What Are Consumer Groups in Kafka?
A beginner-friendly guide to the teams of readers that share the work of a topic, remember their own place, and keep going when members join, leave, or crash.
Imagine a large pile of exam papers that must be marked by tomorrow morning. One teacher alone would take days. So the school forms a team of teachers and divides the pile into bundles, giving each bundle to exactly one teacher. If a new teacher joins, the bundles are shared out again. If a teacher falls ill, the school hands that teacher’s bundle to someone else, who reads the notes and carries on. Meanwhile, a completely different team from another department may want its own copy of the same papers to check something else, and their work never disturbs the first team. In Apache Kafka, that team of teachers is called a consumer group. This guide explains how it works, why it exists, and how to use it well.
1The Reading Problem
Storing events is only half of the story. Somebody has to read them, and reading at scale is harder than it sounds.
A quick refresher
Apache Kafka stores streams of events, such as orders, payments, clicks, or sensor readings. Events are grouped into named categories called topics, and every topic is split into slices called partitions. Each partition is an ordered, append-only log, and every event in it has a position number called an offset. The applications that read these events are called consumers.
What goes wrong with one reader
Imagine a topic receiving fifty thousand events every second. A single consumer program might be able to process only ten thousand per second. The gap grows every moment, and the consumer falls further and further behind. You could start a second copy of the program, but then a new question appears: how do the two copies avoid reading and processing the same event twice, and what happens when one of them crashes?
Without some organising idea, the two consumers would either both read everything, wasting effort and causing duplicate work, or fight over which events belong to whom. Kafka solves this with a simple and elegant concept: the consumer group.
Picture a restaurant kitchen where several cooks work together. Without any plan, two cooks may prepare the same dish while another order is forgotten. With a plan, such as “cook one handles starters, cook two handles mains, cook three handles desserts”, the kitchen runs smoothly. A consumer group is that plan for reading events.
Consumer groups are one of the two or three ideas that make Kafka special. Once you understand them, many other Kafka behaviours suddenly make sense.
2What Is a Consumer Group?
A consumer group is a set of consumers that cooperate to read a topic, sharing its partitions so that each partition is read by only one member at a time.
The simple definition
Every consumer chooses a name for its group, called the group identifier. All consumers that use the same group identifier belong to the same group. Kafka treats the group as one logical reader. Inside the group, the partitions of the subscribed topics are divided among the members. Each partition goes to exactly one member, and one member may hold several partitions.
The three big promises
Work is shared
Partitions are divided among the members, so the reading work is split and the group can keep up with heavy traffic.
No overlap inside a group
A partition is read by only one member at a time, so the group does not process the same event twice under normal conditions, and order inside each partition is kept.
Recovery is automatic
If a member disappears, its partitions are handed to the others, and reading continues from the last saved position.
Think of a group of postmen sharing one town. Each street is served by exactly one postman, so no letter is delivered twice. If a postman is sick, his streets are shared among the others. The group name is the name of the post office branch.
flowchart LR
T["Topic: orders - 4 partitions"] --> P0["Partition 0"]
T --> P1["Partition 1"]
T --> P2["Partition 2"]
T --> P3["Partition 3"]
P0 --> A["Consumer A"]
P1 --> A
P2 --> B["Consumer B"]
P3 --> B
subgraph G["Consumer Group: email-service"]
A
B
end
3Many Groups, One Topic
The second superpower of consumer groups is that different groups do not disturb one another.
Every group gets the full stream
Inside one group, the partitions are divided. Between different groups, nothing is divided. Each group receives every event of the topic and keeps its own bookmark. The email service, the analytics team, and the fraud checker can each have their own group reading the same topic, and each sees every order. A slow group never slows the others, because their bookmarks are independent.
Two behaviours in one design
This design gives Kafka the strengths of two older messaging styles. Within a group, the members compete for partitions, which behaves like a work queue where each job goes to one worker. Across groups, every group gets a copy, which behaves like a broadcast where every subscriber hears the news. Kafka offers both with one mechanism.
| Question | Inside One Group | Across Different Groups |
|---|---|---|
| Who gets each event? | Only one member, the owner of that partition | Every group gets it |
| Behaviour | Like a work queue | Like a broadcast |
| Bookmarks | Shared by the group, kept per partition | Separate for every group |
| Effect of a slow reader | The group falls behind on its partitions | Other groups are not affected |
flowchart LR
T["Topic: orders"] --> G1["Group: email-service"]
T --> G2["Group: analytics"]
T --> G3["Group: fraud-check"]
G1 --> R1["Sends receipts"]
G2 --> R2["Builds dashboards"]
G3 --> R3["Flags suspicious orders"]
A news channel broadcasts one bulletin. Every household watches the full bulletin on its own television. Inside one household, however, family members may divide the chores that follow the news. The households are the groups, and the family members are the consumers inside each group.
4How Partitions Are Shared Out
The number of partitions and the number of consumers together decide who does what.
The sharing rule
Because a partition can be read by only one member of a group at a time, the number of partitions sets the ceiling on how many members can be busy. If a topic has six partitions, at most six members of one group can be reading. A seventh member would have nothing to do and would simply wait as a standby.
| Situation | Partitions | Members | What Happens |
|---|---|---|---|
| Fewer members than partitions | 6 | 3 | Each member reads two partitions |
| Equal numbers | 6 | 6 | Each member reads one partition |
| More members than partitions | 6 | 8 | Six members work; two are idle standbys |
| Only one member | 6 | 1 | One member reads all six partitions |
Why only one reader per partition?
Kafka keeps the events of a partition in strict order. If two members read the same partition at once, they would process events in overlapping and unpredictable ways, and the order would be lost. Giving each partition a single reader keeps order safe and makes each member’s work simple to reason about.
Imagine a single book being read aloud. If two people read different pages at the same time, the story becomes confusing. One reader per book keeps the story in order. If you have six books and eight readers, two readers must wait for a book to become free.
Starting more consumers than there are partitions and expecting more speed. The extra members stay idle. If you need more parallel reading, the topic needs more partitions.
5Offsets: The Group’s Shared Bookmark
A group must remember how far it has read, or every restart would begin from scratch.
What is a committed offset?
Each event in a partition has an offset, a number that shows its position. As a group reads, it periodically saves the offset it has reached, called committing an offset. The saved number means “everything before this position has been handled, and the next event to read is this one.” The bookmark is saved per group, per partition.
Where the bookmarks live
Kafka stores these bookmarks in itself, in a special internal topic dedicated to offsets. Because that topic is replicated like any other, the bookmarks survive broker failures. When a consumer starts, it asks Kafka for the last committed offset of its partitions and continues from there. If no bookmark exists yet, a setting decides whether the group starts from the earliest available event or only from new events that arrive from now on.
Reading a long novel, you put a bookmark where you stopped. If you share the novel with a friend, you both use a notebook that records the page reached. The notebook is kept in a safe cupboard, so even if you lose your place in your head, you can find it again.
Two positions to keep apart
The current reading position
This is where the consumer is right now in memory, the next event it will ask for. It moves forward with every batch fetched.
The committed position
This is the bookmark saved in Kafka. If the consumer crashes, a new owner resumes from here, so events between the committed position and the crash may be read again.
flowchart LR
E0["Offset 0-99 - handled and committed"] --> E1["Offset 100-119 - read, not yet committed"]
E1 --> E2["Offset 120 and beyond - not yet read"]
Because events stay in Kafka for the retention period, a group can also move its bookmark backwards to reprocess old events, which is very useful after fixing a bug.
6The Group Coordinator: The Team Manager
Somebody must keep track of who is in the group and who owns what. In Kafka, one broker plays that role for each group.
What the coordinator does
For every consumer group, one broker acts as the group coordinator. It keeps the list of active members, receives their regular signals, notices when someone stops responding, starts a reshuffle when the membership changes, and stores the group’s committed offsets. Different groups may have different coordinators, which spreads the management work across the cluster.
Joining a group step by step
Find the coordinator
The new consumer asks any broker which broker is the coordinator for its group identifier.
Ask to join
The consumer tells the coordinator which topics it wants to read and asks to become a member.
Receive an assignment
The group agrees on who reads which partitions. The new consumer receives its share.
Load the bookmarks
The consumer asks for the last committed offsets of its partitions so it knows where to continue.
Start reading and signalling
It begins fetching events and sends regular heartbeats to prove it is alive.
sequenceDiagram
participant C as New Consumer
participant B as Any Broker
participant GC as Group Coordinator
C->>B: Who is the coordinator for my group?
B-->>C: Broker 2
C->>GC: Join group and subscribe to topics
GC-->>C: Partition assignment
C->>GC: Fetch committed offsets
GC-->>C: Last saved positions
C->>GC: Heartbeats while reading
A team manager keeps the attendance list, hands out tasks, notes down who has finished what, and notices when someone has not shown up. The coordinator is that manager, and it sits inside one of the brokers.
7Heartbeats and Staying Alive
How does the group know a member is still healthy? Through small regular signals and one important time limit.
Heartbeats
Each consumer sends a small heartbeat to the coordinator every few seconds. It is like a wave that says “I am still here”. If the coordinator hears nothing for longer than the session timeout, it decides the member is gone, removes it from the group, and starts a reshuffle of partitions.
The processing time limit
Heartbeats alone are not enough. A consumer could be alive yet stuck, for example waiting forever on a slow database. To catch this, Kafka also sets a limit on how long a consumer may go without asking for more events. If a consumer takes too long to process a batch and misses this limit, it is treated as failed and removed from the group, even if its heartbeats are still arriving.
Heartbeat interval
How often a member says “I am alive”. Short intervals detect problems sooner but create more small requests.
Session timeout
How long the coordinator waits without a heartbeat before declaring the member dead.
Maximum processing gap
How long a member may take between requests for new events before it is considered stuck.
Batch size per request
How many events a member receives at once. Smaller batches finish faster and stay within the time limit.
A night watchman must press a button every ten minutes to prove he is awake. That is the heartbeat. He must also complete his patrol round within an hour. If he presses the button but never finishes the round, the company still knows something is wrong. Both checks together give a reliable picture.
Doing slow work, such as long database calls, on a huge batch of events. The consumer overruns the processing limit, gets removed, triggers a reshuffle, and the same events are read again by someone else, making the slowdown even worse.
8Rebalancing: When the Team Changes
Teams change all the time. A rebalance is how a group redistributes its partitions when that happens.
What triggers a rebalance
A member joins
A new consumer starts, perhaps because you scaled the application up during busy hours. The partitions must be shared with the newcomer.
A member leaves or crashes
An application is stopped, redeployed, or fails. Its partitions must be given to the survivors.
A member is judged too slow
Missing heartbeats or the processing time limit causes the coordinator to remove a member.
The subscription changes
The group starts reading additional topics, or the number of partitions of a topic grows.
The steps of a rebalance
The coordinator notices the change
It sees a join request, a leave request, or missing heartbeats.
Members give up or pause partitions
Depending on the strategy, some or all members stop reading and commit their progress.
A new assignment is decided
The group agrees which member owns which partitions, using an assignment strategy.
Reading resumes from the bookmarks
Each member continues from the committed offsets of its new partitions.
flowchart TD
A["Group has 3 members and 6 partitions"] --> B["Member 3 crashes"]
B --> C["Coordinator misses heartbeats and declares it dead"]
C --> D["Rebalance starts"]
D --> E["Partitions of Member 3 are given to Members 1 and 2"]
E --> F["Members continue from last committed offsets"]
When a bus driver falls ill, the depot manager reassigns that route to other drivers and updates the timetable. Passengers may wait a little longer during the change, but the routes keep running.
9Eager and Gentle Rebalancing
Not all rebalances are equally disruptive. The way partitions are moved makes a big difference.
The classic stop-the-world style
In the older style, called eager rebalancing, every member gives up all its partitions at the start of the rebalance, and then everything is assigned afresh. During this short period, the whole group stops reading. In a large group, or when rebalances happen often, these pauses add up and lag grows.
The gentle, incremental style
Cooperative rebalancing is smarter. Members keep the partitions that do not need to move and continue reading them. Only the partitions that must change owners are paused and handed over. Most of the group keeps working through the change. Newer versions of Kafka also offer an improved group protocol that moves much of the coordination work to the broker side, making rebalances lighter still, especially in very large groups.
| Aspect | Eager Rebalance | Cooperative Rebalance |
|---|---|---|
| What members do | All give up every partition | Only moving partitions are given up |
| Reading during the change | Stops for the whole group | Continues for unaffected partitions |
| Effect on lag | Noticeable pause | Much smaller pause |
| Best for | Simple, small groups | Large or frequently changing groups |
Assignment strategies
Range
Gives each member neighbouring partitions of every topic. Simple, but can create uneven loads when there are many topics.
Round robin
Deals partitions to members one by one like cards, giving a very even spread.
Sticky
Keeps the spread even but tries to leave existing assignments unchanged, so fewer partitions move.
Cooperative sticky
Combines stickiness with incremental hand-over, so most members keep reading during a change.
Fewer moves matter because a consumer often keeps helpful state in memory, such as caches and running totals for the partitions it owns. Every time a partition moves, that state must be rebuilt.
10Static Membership: Avoiding Needless Reshuffles
Many rebalances are caused by ordinary things like restarts during deployments. Kafka has a feature to make them calmer.
The problem with quick restarts
Normally, when a consumer restarts, Kafka sees the old member leave and a new member join. That triggers two reshuffles for a change that lasts only seconds. In a large group deployed one member at a time, this can cause a long chain of pointless reshuffles.
Giving members a stable name
With static membership, each consumer is given a fixed name of its own. If it disappears and returns within the session timeout with the same name, Kafka recognises it as the same member and returns its previous partitions without any reshuffle. The other members are not disturbed at all. If it fails to return in time, the normal rebalance begins.
If a waiter steps out for a five-minute break, the manager does not redraw the whole floor plan. The tables stay reserved for that waiter for a short time. Only if the waiter fails to return does the manager reassign the tables.
Giving two running consumers the same static name. Kafka allows only one active member per name, so the second one is rejected or forces the first out. Every instance must have its own unique name.
11Committing Offsets and Delivery Guarantees
When the group saves its bookmark decides what happens after a crash.
Three possible behaviours
At most once
Save the bookmark first, then process. A crash in between skips events. No duplicates, but possible loss.
At least once
Process first, then save the bookmark. A crash in between makes the events be read again. No loss, but possible duplicates.
Exactly once
Processing and bookmark saving succeed together or not at all, using transactions or repeat-safe design.
Automatic and manual commits
By default, many consumers save their bookmark automatically every few seconds. This is easy, but it can save a position for events that were fetched yet not fully processed, risking loss if the consumer crashes. Careful applications turn this off and commit manually, after the work for a batch is truly finished. This gives at-least-once behaviour, which is the most common and practical choice.
A postman ticks a parcel off his list. If he ticks before delivering and then loses the parcel, it is forgotten. If he delivers first and drops the list before ticking, he may deliver the same parcel again tomorrow. Which mistake is acceptable depends on the parcel.
Where at-least-once fits: notifications
An occasional duplicate receipt email is annoying but harmless, especially if the consumer is designed so that repeating the work has no bad effect.
Where exactly-once fits: balances and totals
Stream processing that reads, calculates, and writes results back to Kafka can use transactions so no event is counted twice, even after a failure.
12Consumer Lag: The Group’s Health Number
If you could watch only one number for a consumer group, this is the one.
What is lag?
Lag is the gap between the newest event in a partition and the group’s committed bookmark for that partition. It tells you how many events are waiting to be processed. A small, steady lag is normal, because events arrive continuously. A lag that keeps growing means the group cannot keep up.
Reading the signal
| Pattern of Lag | Likely Meaning | Possible Response |
|---|---|---|
| Small and steady | The group keeps pace with the traffic | Nothing to do |
| Short spikes that recover | Temporary bursts of traffic | Usually fine; watch for patterns |
| Steadily growing | Consumers are too slow for the incoming load | Speed up processing or add members, up to the partition count |
| Growing on one partition only | A hot key or one stuck member | Investigate keys, the member owning it, or a poisonous event |
| Sudden jump after deployment | Frequent rebalances or crashes | Check logs and the rebalance rate |
Lag is the height of the pile of unmarked exam papers on the teachers’ table. A small pile that stays about the same height is healthy. A pile that grows every hour tells you that the teachers cannot keep up, and you must hire more teachers or make marking faster.
Lag can also be measured in time: how old is the oldest unprocessed event? For some businesses, “five minutes behind” is more meaningful than “two million events behind”.
13Scaling a Consumer Group
When lag grows, there is a sensible order in which to respond.
Find the real bottleneck
Check whether time is being lost in processing, such as slow database calls, or in the reading itself. Adding members will not help if every member waits on the same slow service.
Make each member faster
Group database writes into batches, cache repeated lookups, and remove unnecessary waiting.
Add members up to the partition count
Start more copies of the consumer application. The group rebalances and shares the partitions among them.
Add partitions if you have hit the ceiling
If every partition already has its own member, raise the partition count in a planned way, remembering the effect on keys and ordering.
Check for hot partitions
If one partition carries most of the traffic because of a dominant key, more members cannot help, and the key design must be reviewed.
flowchart TD
L["Lag is growing"] --> Q1{"Is processing itself slow?"}
Q1 -->|"Yes"| F1["Speed up processing"]
Q1 -->|"No"| Q2{"Members fewer than partitions?"}
Q2 -->|"Yes"| F2["Add more members"]
Q2 -->|"No"| Q3{"One partition much busier?"}
Q3 -->|"Yes"| F3["Review keys and hot partitions"]
Q3 -->|"No"| F4["Plan more partitions"]
Automatically scaling consumers on demand without limits. Each scale change triggers a rebalance, and scaling beyond the partition count wastes resources. Keep automatic scaling within sensible bounds.
14Handling Bad Events: Poison Messages
Sometimes one event is so strange that a consumer cannot process it, and the whole partition gets stuck behind it.
The problem
Consumers read a partition in order. If one event is malformed, or triggers a bug, the consumer fails on it. If the consumer simply retries forever without moving its bookmark, the partition is blocked and all events behind it wait. This troublemaker is called a poison message. Meanwhile, lag grows and other events, perfectly healthy, are delayed.
Sensible ways to cope
Limited retries
Retry a few times in case the trouble was temporary, such as a brief database outage, then stop retrying.
Dead letter topic
After the retries fail, copy the bad event, together with information about the error, to a separate topic called a dead letter topic, and move on. People or special tools can inspect and repair these events later.
Retry topics with delay
Send failing events to a retry topic that is read after a delay, so temporary problems can heal without blocking the main stream.
Skip with an alert
For low-value data, log the problem, raise an alert, and skip the event so the stream continues.
On a factory line, one damaged item should not stop the whole belt. A worker moves it to a “problem” bin for later inspection and lets the belt continue. The dead letter topic is that problem bin.
Always record why an event was set aside, including the error and the original position. Without that, the problem bin fills with mysteries nobody can solve.
15Managing Groups: Naming, Resetting, and Security
Groups are long-lived objects in the cluster, and they need a little housekeeping.
Naming groups well
The group identifier decides which consumers share work and which bookmarks are used. Choose clear, meaningful names that reflect the application or team, such as the email service or the fraud checker. Two unrelated applications accidentally sharing a group name would split the events between them, and each would miss half of the data.
Resetting a group’s position
Operators can move a group’s bookmark: back to the earliest event, forward to the newest, to a particular time, or to a specific offset. This is helpful for reprocessing after a bug fix, or for skipping a burst of unwanted events. The group must be stopped while its offsets are changed, otherwise the running members would overwrite the new bookmarks.
Cleaning up
Groups with no active members eventually lose their stored bookmarks after an expiry period, so a group idle for too long may start from scratch when it returns. Old, unused groups should be removed so they do not clutter monitoring and confuse operators.
Security
Kafka can require applications to prove their identity and can check which identities may read a topic and which may use a given group name. A well-run cluster gives each application its own identity, allows it only its own group names and only the topics it needs, and keeps credentials in a proper secrets system.
A library keeps a card for each reading club, noting which page they have reached in the shared book. The librarian can move the club’s bookmark on request, removes cards of clubs that disbanded years ago, and checks membership cards at the door.
16Advantages and Trade-offs of Consumer Groups
Consumer groups are elegant, but they come with rules you must respect.
Advantages
- Reading work is shared, so a topic can be processed at high speed
- Members can be added or removed without stopping the system
- Failures are handled automatically by redistributing partitions
- Order inside each partition is safely preserved
- Different groups read the same data independently
- Bookmarks survive restarts, because they are stored in Kafka
Disadvantages / Trade-offs
- Parallel reading is capped by the partition count
- Rebalances cause pauses and can repeat work
- Applications must handle repeated events safely
- Slow processing can get a member removed unexpectedly
- A single hot partition can hold back the whole group
- Order across partitions is not guaranteed
17Anti-Patterns and Best Practices
Most group problems repeat across companies. Learn them once and avoid them forever.
Problem
Doing slow work for a huge batch of events inside the reading loop without limits.
Why It’s Harmful
The consumer overruns its allowed processing time and is removed from the group, triggering rebalances and repeated work.
Correct Approach
Fetch smaller batches, keep processing fast, and tune the time limit to match realistic work.
Problem
Two different applications using the same group name by accident.
Why It’s Harmful
They split the partitions between them, so each application sees only part of the data without knowing it.
Correct Approach
Give every application its own clearly named group, and share a name only among copies of the same application.
Problem
Committing the bookmark before the work is finished, for example through automatic commits with slow processing.
Why It’s Harmful
A crash can lose events that were marked as handled but never processed.
Correct Approach
Commit manually after the batch is truly done, and design the work to be safe if repeated.
Problem
Retrying a poison message forever without ever moving on.
Why It’s Harmful
One bad event blocks its whole partition, and lag grows without limit.
Correct Approach
Limit the retries, set the event aside in a dead letter topic with the error details, and continue.
Problem
Sharing one consumer object across several threads without care.
Why It’s Harmful
The standard consumer is not built for free use from many threads at once, and misuse causes confusing failures.
Correct Approach
Give each thread its own consumer, or keep the consumer in one thread and pass work to others safely, committing only after the work completes.
Best practices at a glance
Name groups clearly
One group name per application, chosen to be meaningful and unique.
Match members to partitions
Plan the partition count so the group has room to grow.
Design repeat-safe consumers
Make sure seeing an event twice never causes harm.
Commit after processing
Save bookmarks only when the work is really finished.
Use gentle rebalancing
Prefer cooperative strategies and stable member names to reduce pauses.
Watch lag per partition
Alert on lag that keeps growing, and look at each partition, not only the total.
Have a dead letter plan
Decide in advance what happens to events that cannot be processed.
Shut down gracefully
Commit progress and leave the group cleanly so partitions move quickly to others.
18A Real-World Walk-Through
Let us watch consumer groups at work in an online shop during a sale.
The setup
The “orders” topic has twelve partitions. Three groups read it: one for emails, one for fraud checks, and one for analytics.
A quiet morning
The email group runs three members, each owning four partitions. Lag stays near zero.
The sale begins
Traffic jumps tenfold. The email group’s lag starts to climb, because three members cannot send that many emails.
The team scales up
The application is scaled to six members. A cooperative rebalance moves only some partitions, and the group keeps reading while it changes.
A member crashes
One member is killed by its host. The coordinator notices the missing heartbeats and hands its partitions to the others, who continue from the last committed bookmarks. A few emails may be sent twice, but the receipts are designed to be repeat-safe.
A bad event appears
One malformed order blocks a partition. After three retries, the consumer sends it to the dead letter topic with the error details, and the partition flows again.
Meanwhile, the other groups
The fraud and analytics groups read the same events at their own pace. The email trouble never affected them.
19Frequently Asked Questions
It is a set of consumers sharing one group identifier that divide the partitions of a topic among themselves, so each partition is read by only one member at a time, with the group’s progress saved as shared bookmarks.
Yes, and this is a core feature. Each group receives every event and keeps its own bookmarks, so groups never interfere with each other.
As many as you like, but only as many as the number of partitions can be active at once. Extra members wait idle as standbys.
The coordinator notices the missing heartbeats, removes the member, and rebalances. The remaining members take over its partitions and continue from the last committed offsets.
You probably have more members in the group than partitions. Each partition can be read by only one member of a group at a time.
The group resumes from the last committed offset. Events processed after that bookmark but before the crash are read again. Design consumers to be safe against repeats and commit after processing.
A rebalance redistributes partitions after the group changes. In the older eager style, everyone stops while partitions are reassigned. Cooperative strategies, stable member names, and quick processing reduce the pause.
In an internal, replicated Kafka topic used for offsets, so the bookmarks survive restarts and broker failures.
Yes, as long as the events are still within the retention period. Stop the group, move its bookmarks back to an earlier offset or time, and restart it.
Most consumers use one, because groups provide bookmarks and automatic sharing. Special cases exist where an application assigns partitions to itself manually and manages its own position, but this is uncommon and needs careful design.
20Summary and Key Takeaways
We began with a team of teachers marking a pile of exam papers, each bundle given to exactly one teacher, with the bundles reshuffled whenever the team changes. A Kafka consumer group is that team. Consumers that share a group identifier divide the partitions of a topic, so each partition has one reader at a time, order is preserved, and the group can grow or shrink while running. A group coordinator on one of the brokers tracks members through heartbeats, hands out assignments, and stores the group’s bookmarks in a replicated internal topic. Different groups read the same topic independently, giving Kafka both work-queue and broadcast behaviour at once. In return, you must respect a few rules: parallelism is capped by the partition count, rebalances cause pauses, processing must stay within its time limit, consumers must tolerate repeated events, and lag must be watched closely. Master those, and consumer groups will carry your reading workload calmly at any scale.
Key Takeaways
- A group is a team of readers — consumers with the same group identifier share the partitions of a topic, and each partition has only one reader in the group at a time.
- Groups are independent — every group gets the full stream and keeps its own bookmarks, so many teams can read the same topic without disturbing each other.
- Partitions cap parallelism — members beyond the partition count stay idle, so plan the partition count for the scale you expect.
- The coordinator manages the team — it tracks heartbeats, triggers rebalances, and stores committed offsets in a replicated internal topic.
- Rebalances are normal but costly — use cooperative strategies, stable member names, and quick processing to keep pauses short.
- Commit after processing — at-least-once is the practical default, so design consumers to be safe when they see an event twice.
- Watch lag and plan for bad events — alert on lag that keeps growing, look at each partition, and use limited retries with a dead letter topic for poison messages.