What Are Consumer Groups in Kafka?

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.

Simple Analogy

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.

i
Helpful Note

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

Promise 1

Work is shared

Partitions are divided among the members, so the reading work is split and the group can keep up with heavy traffic.

Promise 2

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.

Promise 3

Recovery is automatic

If a member disappears, its partitions are handed to the others, and reading continues from the last saved position.

Simple Analogy

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
        
FIG 1 — Two consumers in one group sharing four partitions

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.

QuestionInside One GroupAcross Different Groups
Who gets each event?Only one member, the owner of that partitionEvery group gets it
BehaviourLike a work queueLike a broadcast
BookmarksShared by the group, kept per partitionSeparate for every group
Effect of a slow readerThe group falls behind on its partitionsOther 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"]
        
FIG 2 — Three independent groups reading the same topic
Simple Analogy

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.

SituationPartitionsMembersWhat Happens
Fewer members than partitions63Each member reads two partitions
Equal numbers66Each member reads one partition
More members than partitions68Six members work; two are idle standbys
Only one member61One 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.

Simple Analogy

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.

!
Common Mistake

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.

Simple Analogy

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"]
        
FIG 3 — Committed, read but uncommitted, and unread events in a partition
i
Helpful Note

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

1

Find the coordinator

The new consumer asks any broker which broker is the coordinator for its group identifier.

2

Ask to join

The consumer tells the coordinator which topics it wants to read and asks to become a member.

3

Receive an assignment

The group agrees on who reads which partitions. The new consumer receives its share.

4

Load the bookmarks

The consumer asks for the last committed offsets of its partitions so it knows where to continue.

5

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
        
FIG 4 — A consumer joining a group
Simple Analogy

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.

Setting 1

Heartbeat interval

How often a member says “I am alive”. Short intervals detect problems sooner but create more small requests.

Setting 2

Session timeout

How long the coordinator waits without a heartbeat before declaring the member dead.

Setting 3

Maximum processing gap

How long a member may take between requests for new events before it is considered stuck.

Setting 4

Batch size per request

How many events a member receives at once. Smaller batches finish faster and stay within the time limit.

Simple Analogy

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.

!
Common Mistake

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

1

The coordinator notices the change

It sees a join request, a leave request, or missing heartbeats.

2

Members give up or pause partitions

Depending on the strategy, some or all members stop reading and commit their progress.

3

A new assignment is decided

The group agrees which member owns which partitions, using an assignment strategy.

4

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"]
        
FIG 5 — A rebalance after a member crashes
Simple Analogy

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.

AspectEager RebalanceCooperative Rebalance
What members doAll give up every partitionOnly moving partitions are given up
Reading during the changeStops for the whole groupContinues for unaffected partitions
Effect on lagNoticeable pauseMuch smaller pause
Best forSimple, small groupsLarge or frequently changing groups

Assignment strategies

Strategy 1

Range

Gives each member neighbouring partitions of every topic. Simple, but can create uneven loads when there are many topics.

Strategy 2

Round robin

Deals partitions to members one by one like cards, giving a very even spread.

Strategy 3

Sticky

Keeps the spread even but tries to leave existing assignments unchanged, so fewer partitions move.

Strategy 4

Cooperative sticky

Combines stickiness with incremental hand-over, so most members keep reading during a change.

i
Helpful Note

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.

Simple Analogy

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.

!
Common Mistake

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

Guarantee 1

At most once

Save the bookmark first, then process. A crash in between skips events. No duplicates, but possible loss.

Guarantee 2

At least once

Process first, then save the bookmark. A crash in between makes the events be read again. No loss, but possible duplicates.

Guarantee 3

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.

Simple Analogy

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.

“Kafka can promise a lot, but your consumer must be built to survive seeing the same event twice.”

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 LagLikely MeaningPossible Response
Small and steadyThe group keeps pace with the trafficNothing to do
Short spikes that recoverTemporary bursts of trafficUsually fine; watch for patterns
Steadily growingConsumers are too slow for the incoming loadSpeed up processing or add members, up to the partition count
Growing on one partition onlyA hot key or one stuck memberInvestigate keys, the member owning it, or a poisonous event
Sudden jump after deploymentFrequent rebalances or crashesCheck logs and the rebalance rate
Lag
Events waiting to be processed per partition
Rate
Events processed per second by the group
Members
Active consumers currently in the group
Simple Analogy

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.

i
Helpful Note

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.

1

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.

2

Make each member faster

Group database writes into batches, cache repeated lookups, and remove unnecessary waiting.

3

Add members up to the partition count

Start more copies of the consumer application. The group rebalances and shares the partitions among them.

4

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.

5

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"]
        
FIG 6 — A simple path for tackling growing lag
!
Common Mistake

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.

Simple Analogy

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.

i
Helpful Note

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.

Simple Analogy

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.

ANTI-PATTERN-01 Avoid
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.

ANTI-PATTERN-02 Avoid
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.

ANTI-PATTERN-03 Avoid
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.

ANTI-PATTERN-04 Avoid
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.

ANTI-PATTERN-05 Avoid
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

Habit 1

Name groups clearly

One group name per application, chosen to be meaningful and unique.

Habit 2

Match members to partitions

Plan the partition count so the group has room to grow.

Habit 3

Design repeat-safe consumers

Make sure seeing an event twice never causes harm.

Habit 4

Commit after processing

Save bookmarks only when the work is really finished.

Habit 5

Use gentle rebalancing

Prefer cooperative strategies and stable member names to reduce pauses.

Habit 6

Watch lag per partition

Alert on lag that keeps growing, and look at each partition, not only the total.

Habit 7

Have a dead letter plan

Decide in advance what happens to events that cannot be processed.

Habit 8

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.

1

The setup

The “orders” topic has twelve partitions. Three groups read it: one for emails, one for fraud checks, and one for analytics.

2

A quiet morning

The email group runs three members, each owning four partitions. Lag stays near zero.

3

The sale begins

Traffic jumps tenfold. The email group’s lag starts to climb, because three members cannot send that many emails.

4

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.

5

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.

6

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.

7

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

Q1What is a consumer group in one sentence?

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.

Q2Can two different groups read the same topic?

Yes, and this is a core feature. Each group receives every event and keeps its own bookmarks, so groups never interfere with each other.

Q3How many consumers can be in a group?

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.

Q4What happens when a consumer crashes?

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.

Q5Why are some of my consumers idle?

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.

Q6Why do I see repeated events after a restart?

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.

Q7What is a rebalance and why is it slow sometimes?

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.

Q8Where does Kafka store the group’s bookmarks?

In an internal, replicated Kafka topic used for offsets, so the bookmarks survive restarts and broker failures.

Q9Can I make a group reread old events?

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.

Q10Do I always need a group?

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.