What Is Rebalancing in Kafka? (Basic)

What Is Rebalancing in Kafka? (Basic)

A beginner-friendly guide to the moment a consumer group reshuffles its partitions: why it happens, what goes on behind the scenes, why it can hurt, and the simple habits that keep it calm.

Imagine a school where a pile of exam papers is divided into bundles and each bundle is given to one teacher. The plan works nicely until something changes. A new teacher arrives and wants a share. A teacher falls ill and leaves. Suddenly the old plan no longer fits, and the head teacher must call everyone together, collect the bundles, and hand them out again. For a few minutes, marking slows down while the reshuffle happens. In Apache Kafka, this reshuffle is called a rebalance. It is a normal and necessary part of life for every consumer group, but if you do not understand it, it can cause slowdowns, repeated work, and confusing behaviour. This guide explains rebalancing from the ground up, in simple words.

1The Background You Need

Rebalancing only makes sense once three ideas are clear: partitions, consumers, and groups.

Topics and partitions

Apache Kafka stores streams of events, such as orders, payments, clicks, or sensor readings. Events are grouped into named categories called topics. To make a topic big and fast, Kafka splits it into smaller logs called partitions. Each partition is an ordered, append-only list of events, and every event in it has a position number called an offset.

Consumers and consumer groups

Applications that read events are called consumers. Consumers that share the same group name form a consumer group. Kafka divides the partitions of the topic among the members of the group, so that each partition is read by exactly one member at a time. This is how a group shares the reading work and keeps events in order.

The assignment is not permanent

Which member reads which partition is called the assignment. It is a plan, and like any plan it must be updated when the situation changes. Members come and go, topics grow, and the plan must always cover every partition with exactly one owner. The act of updating the plan is the rebalance.

Simple Analogy

Think of a taxi company that assigns city zones to drivers. Each zone has exactly one driver at a time. When a driver goes home sick or a new driver joins, the dispatcher redraws the list of who covers which zone. The redrawing is the rebalance.

i
Helpful Note

Rebalancing belongs to consumer groups. Producers do not rebalance, because they are free to write to any partition. Only readers that must avoid stepping on each other need a plan.

2What Is a Rebalance?

A rebalance is the process by which a consumer group redistributes topic partitions among its current members.

The simple definition

Whenever the set of members or the set of partitions changes, Kafka pauses the normal flow, gathers the group, and agrees on a new assignment. Once everyone knows their new partitions, reading continues, and each member picks up from the last saved bookmark of the partitions it now owns.

Why Kafka needs rebalancing

Reason 1

Fairness

Work should be shared fairly. A newcomer should get a share, and no member should be overloaded while another sits idle.

Reason 2

Coverage

Every partition must always have an owner. If a member disappears, its partitions must not be left unread.

Reason 3

Order safety

Only one member may read a partition at a time. A clear plan prevents two members from handling the same partition together.

Reason 4

Automatic healing

No human has to reassign work after a crash. The group repairs itself, which makes Kafka applications easy to scale and easy to run.

flowchart LR
  subgraph Before["Before"]
    A1["Consumer A: P0, P1, P2"]
    B1["Consumer B: P3, P4, P5"]
  end
  subgraph After["After Consumer C joins"]
    A2["Consumer A: P0, P1"]
    B2["Consumer B: P3, P4"]
    C2["Consumer C: P2, P5"]
  end
  Before --> After
        
FIG 1 — A new member joins and partitions are shared out again
Simple Analogy

Six tables in a restaurant are served by two waiters, three tables each. When a third waiter starts, the manager gives each waiter two tables. Every table still has exactly one waiter, and the workload is fair again.

3What Triggers a Rebalance

Rebalances do not happen at random. A small list of events starts every one of them.

A new consumer joins the group

You start another copy of your application, perhaps to handle a busy period. The group must share its partitions with the newcomer.

A consumer leaves the group

An application shuts down normally or is redeployed. Its partitions must go to the remaining members.

A consumer crashes or becomes unreachable

The program dies, its machine fails, or the network breaks. Kafka notices that its signals have stopped and removes it from the group.

A consumer is too slow

A member takes too long between requests for new events and is judged stuck, even if the program is still running.

The subscription changes

The group starts reading an extra topic, or a topic that matches a name pattern appears.

The number of partitions changes

Someone adds partitions to a topic. The new partitions need owners, so the plan must be redrawn.

TriggerPlanned or UnplannedTypical Cause
Member joinsUsually plannedScaling up or deploying a new version
Member leaves cleanlyPlannedScaling down or a normal shutdown
Member crashesUnplannedProgram fault, machine failure, network outage
Member too slowUnplannedLong processing between requests
Subscription changesPlannedNew feature reads a new topic
Partitions addedPlannedCapacity growth of a topic
!
Common Mistake

Treating every rebalance as a sign that something is broken. Some rebalances are healthy and expected. The problem is frequent, unplanned rebalances that keep repeating.

4Who Notices? Heartbeats and the Coordinator

To start a rebalance, someone must first notice that the group has changed.

The group coordinator

For every consumer group, one Kafka server, called a broker, acts as the group coordinator. It keeps the list of active members, receives their regular signals, and decides when a rebalance must begin. The coordinator is like the manager of a team who keeps the attendance list.

Heartbeats

Each consumer sends a small signal, called a heartbeat, to the coordinator every few seconds. A heartbeat simply says “I am alive.” If the coordinator does not hear from a member for longer than the session timeout, it declares that member dead, removes it from the group, and starts a rebalance.

The processing time limit

Heartbeats alone are not enough, because a consumer could be alive yet stuck, for example waiting on a slow database. Kafka therefore also limits how long a consumer may go without asking for new events. If this limit is exceeded, the member is treated as failed and the group rebalances, even if heartbeats are still arriving.

Setting 1

Heartbeat interval

How often a member says “I am alive”. Shorter intervals detect trouble sooner.

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 events before being judged stuck.

Simple Analogy

A night watchman must press a button every ten minutes to prove he is awake. That is the heartbeat. He must also finish his patrol within an hour. If he presses the button but never completes the round, the company still knows something is wrong. Kafka uses both checks together.

i
Helpful Note

The heartbeat is usually sent by a separate background activity inside the consumer, so it keeps flowing even while the main code is busy processing events. The processing time limit is what catches the stuck main code.

5The Steps of a Rebalance

Let us follow a rebalance from the first signal to the moment reading resumes.

1

The coordinator notices a change

A new member asks to join, a member asks to leave, or heartbeats stop arriving. The coordinator decides that the group needs a new plan.

2

Members are told to rejoin

The coordinator tells every member, in reply to their next heartbeat, that a rebalance is under way and that they must rejoin the group.

3

Members stop and commit

Each member finishes what it is doing, saves its bookmark for the partitions it owns, and releases them, so nobody works on a partition that is about to change hands.

4

The join phase

All members send a join request. The coordinator waits until everyone has reported or the waiting time is over, then picks one member as the group leader.

5

The leader makes the plan

The group leader, which is just one of the consumers, receives the list of members and topics and calculates a new assignment using the chosen strategy.

6

The sync phase

The leader sends the plan to the coordinator, and the coordinator gives each member its own portion.

7

Reading resumes

Every member loads the last committed bookmarks for its new partitions and starts fetching events again.

sequenceDiagram
  participant M1 as Member 1 - Group Leader
  participant M2 as Member 2
  participant GC as Group Coordinator
  GC-->>M1: A rebalance is starting, please rejoin
  GC-->>M2: A rebalance is starting, please rejoin
  M1->>GC: Join group
  M2->>GC: Join group
  GC-->>M1: You are the leader, here are the members
  GC-->>M2: Joined, waiting for your assignment
  M1->>GC: Sync with the new plan
  M2->>GC: Sync and wait for plan
  GC-->>M1: Your partitions
  GC-->>M2: Your partitions
        
FIG 2 — The join and sync phases of a rebalance
Simple Analogy

A class teacher calls a short meeting, makes everyone put down their work, picks one student to draw up a new seating chart, gives the chart to the teacher, and the teacher announces where everyone should sit. Then class resumes.

i
Helpful Note

You do not write any of these steps yourself. The Kafka client library performs them automatically. Understanding them simply helps you explain what you see in logs and dashboards.

6How the New Plan Is Drawn: Assignment Strategies

The group leader needs a rule to decide who gets which partitions. Kafka offers a few common rules.

Strategy 1

Range

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

Strategy 2

Round robin

Deals partitions out one by one like playing cards, giving a very even spread.

Strategy 3

Sticky

Keeps the spread even but tries to leave existing assignments untouched, so fewer partitions change owner.

Strategy 4

Cooperative sticky

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

Why “sticky” matters

Consumers often keep useful things in memory for the partitions they own, such as caches, running totals, or open connections. If a partition moves to another member, that member must rebuild all of it. A sticky strategy reduces these moves, so most members keep their partitions and their memory stays valuable.

Simple Analogy

When a new student joins a class, a good teacher moves as few students as possible to make room, rather than reshuffling the whole classroom. Students who are already comfortable at their desks stay where they are.

StrategyEvennessPartitions That MoveGood For
RangeCan be unevenManySimple, single-topic groups
Round robinVery evenManyEven spread over many topics
StickyEvenFewGroups that keep local state
Cooperative stickyEvenFew, moved gentlyLarge or busy groups that change often

7Eager and Cooperative Rebalancing

Not all rebalances disturb the group equally. The style of the hand-over decides how much reading stops.

Eager rebalancing: stop the world

In the classic style, every member gives up all of its partitions at the start of the rebalance, and then everything is assigned again from scratch. While this happens, the entire group stops reading. Even members whose partitions will not change must pause. In a large group, or when rebalances repeat, these pauses add up and lag grows.

Cooperative rebalancing: only move what must move

The cooperative style is smarter. Members keep the partitions that are staying, and continue reading them without interruption. Only the partitions that need a new owner are released, and then handed over in a second, short round. Most of the group stays productive throughout. Because the change happens in two small steps, the total disruption is much smaller.

flowchart TD
  subgraph Eager["Eager style"]
    E1["All members release all partitions"] --> E2["Group stops reading"]
    E2 --> E3["New plan is drawn"]
    E3 --> E4["All members resume"]
  end
  subgraph Coop["Cooperative style"]
    C1["Plan is drawn; find partitions that must move"] --> C2["Only those partitions are released"]
    C2 --> C3["Released partitions go to new owners"]
    C3 --> C4["Other members never stopped reading"]
  end
        
FIG 3 — Eager and cooperative styles side by side
AspectEagerCooperative
What members give upEverythingOnly partitions that move
Reading during the changeStops for the whole groupContinues for unaffected partitions
Number of roundsOneTwo short rounds
Effect on lagNoticeable pauseSmall pause
Simple Analogy

Imagine rearranging furniture when a new person joins a shared office. The eager way is to carry out every desk into the corridor and put them all back in a new layout. The cooperative way is to move only the one or two desks that must change, while everyone else keeps working.

i
Helpful Note

Newer Kafka versions also offer an improved group protocol in which the brokers take over much of the coordination work. This makes rebalances lighter, especially in very large groups. Whatever the version, the basic idea remains the same.

8Why Rebalances Can Hurt

Rebalancing keeps the group healthy, but it is not free. Here are the costs beginners should know.

Cost 1: Pauses in reading

While partitions are being reassigned, some or all members do not read. Events pile up in Kafka, and consumer lag, the gap between the newest event and the group’s bookmark, grows. Once reading resumes, the group must catch up.

Cost 2: Repeated work

A member may have processed some events but not yet saved its bookmark when the partition is taken away. The new owner starts from the last saved bookmark and reads those events again. This is why consumers must tolerate seeing an event twice.

Cost 3: Lost local state

Caches and running totals held in memory for a partition are useless to a new owner. It must rebuild them, which takes time and extra load on databases or on Kafka itself.

Cost 4: The rebalance storm

Sometimes a rebalance causes conditions that trigger another rebalance, and then another. For example, a rebalance makes members slow, which makes one exceed its time limit, which triggers a new rebalance. This chain is called a rebalance storm, and it can keep a group nearly useless for a long time.

flowchart LR
  A["Rebalance starts"] --> B["Members pause and rebuild state"]
  B --> C["Processing becomes slow"]
  C --> D["A member exceeds its time limit"]
  D --> E["Member is removed from the group"]
  E --> A
        
FIG 4 — How a rebalance storm feeds itself
Simple Analogy

Imagine a team meeting called to reorganise the tasks. During the meeting no work is done, some tasks are started twice by mistake, and people forget what they had in their heads. If the meeting overruns and people are late for the next one, another meeting must be called. Soon the whole day is meetings.

!
Common Mistake

Ignoring occasional rebalances until they become a storm. Watch how often rebalances happen. A calm group rebalances only when you change it on purpose.

9Common Causes of Unwanted Rebalances

When rebalances happen too often, the cause is usually one of a few familiar culprits.

Slow processing of a batch

The consumer fetches a large batch and takes too long to process it. It exceeds the allowed gap between requests and is removed.

Slow downstream systems

A database or another service that the consumer calls becomes slow, and every batch takes longer than usual.

Long pauses inside the application

Long garbage collection pauses or overloaded machines can stall a consumer so that even heartbeats are delayed.

Unstable networks

Lost or delayed heartbeats make the coordinator believe a healthy member has died.

Rolling deployments

Restarting members one after another causes a leave and a join for each, leading to a long series of rebalances.

Timeouts set too tight

A very short session timeout treats brief hiccups as failures. A very long one delays the detection of real failures.

Automatic scaling that flaps

An auto-scaler that adds and removes consumers every few minutes forces a rebalance each time.

SymptomLikely CauseFirst Thing to Check
Rebalances every few minutes, members “kicked out”Processing exceeds the time limitBatch size and time spent per batch
Rebalance during every deploymentMembers restarting without stable identityStatic membership and graceful shutdown
Random rebalances with healthy programsNetwork or machine stallsHeartbeat timeouts and machine health
Group never settlesRebalance stormTime limits, downstream latency, and scaling rules

10Calming Rebalances: Simple Habits

You cannot remove rebalancing, but a few simple habits make it gentle and rare.

1

Keep batches small and processing quick

Fetch fewer events per request if each takes a while to process. The consumer then returns for more well within the time limit.

2

Set sensible timeouts

Choose a session timeout long enough to forgive brief hiccups but short enough to detect real failures in reasonable time, and a processing limit that matches real work.

3

Use a cooperative assignment strategy

It lets most members keep reading during a change and moves as few partitions as possible.

4

Give members stable names

Static membership lets a restarting member return quickly and reclaim its partitions without a reshuffle.

5

Shut down gracefully

Let a departing member commit its progress and leave the group cleanly, so its partitions move promptly.

6

Deploy gently

Roll out changes one member at a time with pauses between, and avoid restarting everything at once.

7

Scale with restraint

Give auto-scalers a cool-down period, so they do not add and remove members every few minutes.

Simple Analogy

A well-run office avoids constant reorganisation. It gives each person a permanent desk, lets people take short breaks without losing their desks, asks departing colleagues to hand over their work properly, and adds new staff one at a time.

11Static Membership

A special feature exists to spare groups from the most avoidable rebalances: those caused by quick restarts.

The problem it solves

Normally, when a consumer restarts, Kafka sees the old member leave and a new member join. That means two rebalances for a change that lasts only a few seconds. In a large group updated one member at a time, this triggers a long chain of reshuffles.

How it works

With static membership, each consumer is given a fixed, unique name. If it disappears and returns with the same name within the session timeout, Kafka recognises it as the same member. It simply gets its previous partitions back, and the rest of the group is not disturbed. Only if the member fails to return in time does the normal rebalance begin.

Advantages

  • Quick restarts cause no rebalance at all
  • Rolling deployments become smooth
  • Local state and caches stay with the same member
  • Brief crashes are forgiven without disturbing the group

Disadvantages / Trade-offs

  • A member that truly died keeps its partitions until the session timeout ends, so those partitions are unread meanwhile
  • Each instance needs its own unique, stable name
  • Two instances with the same name will clash
Simple Analogy

A waiter steps out for a five-minute break. The manager does not redraw the floor plan. The waiter’s tables stay reserved for a short time. If the waiter does not come back, the manager reassigns the tables.

!
Common Mistake

Combining static membership with a very long session timeout without thinking. If a member really dies, its partitions sit unread for the whole timeout. Balance the two settings carefully.

12Bookmarks and Rebalancing: Committing Progress

The safety of a rebalance depends on how well members save their progress.

What is committed and what is not

As a member reads, it periodically saves its bookmark, called the committed offset, in Kafka. The bookmark says how far the group has finished. The member’s current reading position may be ahead of that saved bookmark. When a partition moves during a rebalance, the new owner starts from the committed bookmark, not from the old owner’s current position.

Two outcomes

Progress saved before the hand-over

The old owner commits just before releasing the partition. The new owner continues exactly where the old one stopped, with little or no repeated work.

Progress not saved

The old owner is removed abruptly, or fails to commit in time. The new owner restarts from an older bookmark and repeats some events.

flowchart LR
  A["Old owner reads offsets 100 to 149"] --> B["Committed bookmark: offset 130"]
  B --> C["Rebalance moves the partition"]
  C --> D["New owner starts at offset 130"]
  D --> E["Offsets 130 to 149 are read again"]
        
FIG 5 — Events after the last commit are read again by the new owner
Simple Analogy

A shift worker leaves a note in a shared logbook saying where the work stopped. If the worker forgot to update the note during the last hour, the next worker starts from the older note and repeats the last hour’s tasks.

Reacting to the hand-over

Kafka lets a consumer be told just before it loses partitions and just after it receives new ones. Well-built applications use these moments. When partitions are about to be taken away, they finish their current work and commit the bookmark. When new partitions arrive, they prepare, for example by loading the state they need. This turns a rebalance from a messy interruption into an orderly hand-over.

i
Helpful Note

Because of possible repeats, always design your processing so that seeing the same event twice does no harm. This one habit makes every rebalance safe.

13Monitoring Rebalances

You cannot fix what you cannot see. A few signals reveal the health of a group.

Rate
How often the group rebalances per hour
Duration
How long each rebalance takes
Lag
How far the group falls behind during and after

What to watch

Watch the number of rebalances over time. A calm group shows rebalances only when you deploy or scale. Watch how long each takes, because long rebalances mean long pauses. Watch consumer lag per partition, since lag that jumps and then recovers is a typical fingerprint of a rebalance. Watch the size of the group and the state of each member, such as whether the group is stable, preparing to rebalance, or waiting for members. In application logs, look for messages saying that a member was removed for exceeding its time limit, since these point straight at the cause.

What You SeeWhat It Usually Means
A rebalance at every deploymentNormal, but can be softened with gentle rolling and stable member names
Rebalances at regular intervalsProcessing time limit exceeded on a schedule, or auto-scaling flapping
Lag spikes that recoverPauses during rebalances followed by catching up
Group state stuck in preparing or waitingA member is slow to rejoin, or too many members are changing at once
Same events processed twiceBookmarks not saved before partitions moved
i
Helpful Note

Set an alert on the rebalance rate, not just on lag. A rising rebalance rate warns you of trouble minutes or hours before customers see delays.

14Advantages and Trade-offs of Rebalancing

Rebalancing is a bargain: automatic healing in exchange for occasional disruption.

Advantages

  • Work is shared fairly without manual effort
  • Failed members are replaced automatically
  • Applications scale up and down while running
  • Every partition always has exactly one reader in the group
  • Order inside each partition is preserved

Disadvantages / Trade-offs

  • Reading pauses while ownership changes
  • Events after the last commit may be processed again
  • In-memory state must be rebuilt after a partition moves
  • Frequent rebalances can snowball into a storm
  • Behaviour depends on client version and settings

15Anti-Patterns and Best Practices

Most rebalance problems come from the same handful of mistakes.

ANTI-PATTERN-01 Avoid
Problem

Processing a large batch of events with slow calls, such as long database writes, between requests for new events.

Why It’s Harmful

The consumer exceeds its allowed processing gap, is removed, and triggers a rebalance. The same events are read again, and the cycle repeats.

Correct Approach

Fetch smaller batches, speed up processing, and tune the time limit to match realistic work.

ANTI-PATTERN-02 Avoid
Problem

Killing consumer applications abruptly instead of shutting them down cleanly.

Why It’s Harmful

The member never commits its progress or leaves the group. The coordinator must wait for the session timeout, so partitions sit unread and more events are repeated.

Correct Approach

Handle shutdown signals, commit progress, and close the consumer so it leaves the group at once.

ANTI-PATTERN-03 Avoid
Problem

Restarting all members of a group at the same moment during a deployment.

Why It’s Harmful

The group loses all its members at once, everything stops, and a full rebalance happens when they return.

Correct Approach

Roll changes one member at a time, waiting until each has rejoined and become stable before starting the next.

ANTI-PATTERN-04 Avoid
Problem

Keeping important state only in a consumer’s memory, with no way to rebuild it.

Why It’s Harmful

Every rebalance that moves a partition destroys the state for that partition, causing wrong results.

Correct Approach

Store state in a durable place, or rebuild it from Kafka when partitions are assigned, and design consumers to tolerate moves.

ANTI-PATTERN-05 Avoid
Problem

Scaling consumers up and down every few minutes based on tiny changes in load.

Why It’s Harmful

Every change forces a rebalance, so the group spends much of its time reshuffling instead of reading.

Correct Approach

Use cool-down periods, scale in larger steps, and never scale beyond the number of partitions.

Best practices at a glance

Habit 1

Small, fast batches

Keep processing well within the allowed gap between requests.

Habit 2

Cooperative strategy

Let members keep reading while only the necessary partitions move.

Habit 3

Stable member names

Use static membership for quick, calm restarts.

Habit 4

Graceful shutdown

Commit progress and leave the group cleanly.

Habit 5

Repeat-safe processing

Make sure seeing an event twice never causes harm.

Habit 6

Gentle deployments

Roll changes one member at a time.

Habit 7

Watch the rebalance rate

Alert when rebalances become frequent, long, or repetitive.

Habit 8

Plan partitions ahead

Choose a partition count with room to grow so that adding partitions is rare.

“A healthy consumer group rebalances when you change it, not when you are asleep.”

16A Real-World Walk-Through

Let us watch rebalancing during a busy day at an online shop.

1

A calm start

The email service group has three members reading a topic with six partitions, two partitions each. Lag is near zero.

2

A sale begins

Traffic rises sharply, and the team starts two more members. The coordinator sees two join requests and begins a rebalance.

3

A gentle hand-over

Using a cooperative strategy, only a few partitions move to the newcomers. The original members keep reading the rest, so lag barely moves.

4

A member is overloaded

One member’s downstream database slows down, and its batch takes longer than the allowed gap. The coordinator removes it and starts another rebalance.

5

Recovery and repeats

The remaining members take over its partitions from the last committed bookmark. A few emails are sent twice, but receipts are designed to be repeat-safe, so no harm is done.

6

The team investigates

Dashboards show a rise in the rebalance rate and long processing times. The team reduces the batch size, fixes the slow query, and the rebalances stop.

7

Evening deployment

The next release is rolled out one member at a time with stable names. Each quick restart returns the same partitions without a reshuffle.

flowchart TD
  S["Sale starts and traffic grows"] --> J["Two members join"]
  J --> R1["Cooperative rebalance moves a few partitions"]
  R1 --> O["One member becomes too slow"]
  O --> R2["Member removed and second rebalance"]
  R2 --> D["Survivors continue from committed bookmarks"]
  D --> F["Team fixes slow query and reduces batch size"]
  F --> C["Group is calm again"]
        
FIG 6 — A day in the life of a consumer group

17Frequently Asked Questions

Q1What is a rebalance in one sentence?

It is the process by which a consumer group redistributes the partitions of its topics among its current members after the group or the topic changes.

Q2Is a rebalance a bug or a failure?

No. It is a normal, designed behaviour. It only becomes a problem when it happens too often, takes too long, or causes repeated work.

Q3Do producers rebalance?

No. Producers may write to any partition. Only consumers in a group must coordinate to avoid reading the same partition at once.

Q4Who decides the new assignment?

One consumer in the group is chosen as the group leader and draws up the plan using the configured strategy, then sends it to the coordinator, which gives each member its share. In newer protocols, the broker performs much of this work.

Q5Do I lose events during a rebalance?

No, events stay safely in Kafka. But events processed after the last committed bookmark may be read again, so consumers must tolerate repeats.

Q6Why does my group rebalance every few minutes?

Common reasons are processing that exceeds the allowed gap between requests, members with unstable networks or machines, auto-scaling that changes the group size, or timeouts set too tight.

Q7What is the difference between eager and cooperative rebalancing?

Eager makes every member give up all partitions and stops the whole group while a new plan is drawn. Cooperative moves only the partitions that must change owners, so the rest of the group keeps reading.

Q8What is static membership for?

It gives each consumer a fixed name so that a quick restart is recognised as the same member returning. The member regains its partitions without any rebalance.

Q9Does adding more consumers than partitions help?

No. Only as many members as there are partitions can be active. The extra members sit idle, and each extra member still causes a rebalance when it joins.

Q10How can I tell that a rebalance is happening?

Look at the group state reported by Kafka tools, at consumer log messages about revoked and assigned partitions, at a rise in consumer lag, and at the rebalance rate metrics of your monitoring system.

18Summary and Key Takeaways

We began with a school where exam-paper bundles must be handed out again whenever a teacher joins or leaves. A Kafka rebalance is that reshuffle. Whenever a consumer joins, leaves, crashes, is judged too slow, or when the subscription or partitions change, the group coordinator starts a rebalance. Members stop, save their bookmarks, rejoin, let a group leader draw a new plan, receive their partitions, and resume from the last committed offsets. Rebalancing gives automatic fairness and healing, at the price of pauses, repeated work, and lost in-memory state. Cooperative strategies, static membership, small quick batches, graceful shutdowns, gentle deployments, and repeat-safe processing keep it calm. Watch the rebalance rate as carefully as you watch lag, and your groups will heal themselves without becoming a source of surprises.

Key Takeaways

  • A rebalance redistributes partitions — it happens inside a consumer group whenever members or partitions change, so every partition always has exactly one owner.
  • Triggers are few and known — a member joining, leaving, crashing, running too slowly, a subscription change, or added partitions.
  • The coordinator runs the show — heartbeats and a processing time limit tell it who is alive, and a group leader draws the new plan through join and sync phases.
  • Eager stops everyone, cooperative moves little — prefer cooperative and sticky strategies so most members keep reading during a change.
  • Rebalances have costs — reading pauses, events after the last commit are repeated, and in-memory state is lost, so design consumers to be repeat-safe and rebuildable.
  • Most trouble is self-inflicted — slow batches, abrupt shutdowns, simultaneous restarts, tight timeouts, and flapping auto-scalers are the usual causes of rebalance storms.
  • Calm habits work — small fast batches, sensible timeouts, static membership, graceful shutdown, gentle deployments, and alerts on the rebalance rate.