Connector Rebalancing in Kafka Connect: The Incremental Cooperative Protocol

Connector Rebalancing in Kafka Connect: The Incremental Cooperative Protocol

A complete, plain-English guide to how a Kafka Connect cluster shares connectors and tasks among its workers, why the old stop-the-world approach hurt, and how incremental cooperative rebalancing moves only what must move — with timeouts, upgrade paths, monitoring, and troubleshooting.

Imagine a restaurant kitchen with five cooks and a long list of dishes being prepared at once. A new cook arrives for the evening shift. In one kind of kitchen, the head chef blows a whistle, every cook puts down every pan, the whole list of dishes is thrown into a pile, and the chef hands out the work again from scratch. Every plate stops cooking for a few minutes, even though only one person joined. In a better kitchen, the head chef quietly asks two busy cooks to hand over one dish each to the newcomer, while everyone else keeps stirring. Kafka Connect used to work like the first kitchen. Since version 2.3 it can work like the second. That second way is called incremental cooperative rebalancing, and it is the subject of this tutorial.

Kafka Connect is the part of Apache Kafka that moves data between Kafka and other systems, such as databases, search engines, and cloud storage, without you writing custom programs. It runs as a group of servers that share the work. Whenever that group changes, the work has to be divided again. This tutorial explains, from the ground up, how that dividing works, what changed with the incremental cooperative protocol, and how to run it safely in production. You do not need prior knowledge. Every new term is explained the first time it appears.

1What Is Rebalancing and Why Should You Care?

Rebalancing is how a group of workers redistributes shared work whenever the group or the work changes.

The Simple Definition

A rebalance is the process by which a group of cooperating servers agrees on who is responsible for which piece of work. It happens every time a server joins, a server leaves, or the list of work changes. In Kafka Connect, the pieces of work are called connectors and tasks, and the servers are called workers. During a rebalance, the group figures out a new fair split and everyone moves to it.

Rebalances are normal and healthy. They are the reason a Connect cluster can survive the loss of a server, grow when you add servers, and pick up newly created connectors automatically. The problem is not that rebalances exist, but how disruptive they are. A poorly behaved rebalance can pause every data pipeline in the cluster, cause duplicate records, delay reports, and trigger alarms across the company.

Simple Analogy

Think of a group of movers carrying boxes into a new house. When another mover shows up, the fair thing is to hand him a few boxes from the busiest movers. The unfair, wasteful thing is to make everyone put down every box, stand in a circle, and start dividing all the boxes again.

Why This Matters in Real Life

Connect clusters often run business-critical pipelines: moving orders into a warehouse, syncing customer changes into search, or archiving events to cheap storage. Teams also deploy new versions, scale up for busy seasons, and lose servers to hardware failures. Each of those events causes rebalancing. If each rebalance stops all pipelines for even a minute, a rolling deployment of ten servers can add up to ten minutes of stalled data. The protocol used for rebalancing decides whether that happens.

2
generations of protocol: eager and cooperative
All
work stops in the old way on every change
Only some
work moves in the new way
i
Good to Know

This tutorial is about the rebalancing of connectors and tasks among Connect workers. It is related to, but different from, the rebalancing of topic partitions among consumers. Chapter 14 explains how the two relate and why people often confuse them.

2Kafka Connect Vocabulary You Need First

A friendly tour of the words used in every later chapter.

Term 1

Worker

A running Connect server process. It hosts connectors and tasks. Several workers with the same group name form one Connect cluster.

Term 2

Connector

A configured job, such as “copy this database table into Kafka.” The connector itself is lightweight; its main job is to decide how the work is split into tasks.

Term 3

Task

The unit that actually moves data. A connector may create many tasks so that copying happens in parallel.

Term 4

Source Connector

Brings data from an outside system into Kafka topics.

Term 5

Sink Connector

Sends data from Kafka topics out to an outside system.

Term 6

Group Coordinator

A broker that keeps track of which members belong to a group and announces membership changes.

Term 7

Leader Worker

The one worker chosen in each rebalance to calculate who does what. The others follow its plan.

Term 8

Assignment

The list of connectors and tasks a particular worker is responsible for at a given moment.

Term 9

Generation

A number that increases with every completed rebalance. It lets everyone tell which plan is the current one.

Term 10

Internal Topics

Special Kafka topics where the Connect cluster stores its configurations, its progress markers, and its status reports.

A Picture of the Hierarchy

A Connect cluster contains workers. Workers host connectors. Each connector creates tasks. Tasks are the hardest workers, doing the actual reading and writing. When we say “the cluster is rebalancing,” we mean “the cluster is reshuffling connectors and tasks among workers.”

flowchart TD
  CL["Connect cluster"] --> W1["Worker A"]
  CL --> W2["Worker B"]
  CL --> W3["Worker C"]
  W1 --> C1["Connector orders"]
  C1 --> T1["Task 0"]
  C1 --> T2["Task 1"]
  W2 --> C2["Connector customers"]
  C2 --> T3["Task 0"]
  W3 --> T4["Task 2 of orders"]
        
FIG 1 — Workers host connectors and tasks; a connector’s tasks may live on different workers
Simple Analogy

A construction company (the cluster) employs crews (workers). Each building project (connector) is broken into jobs like plumbing and wiring (tasks). The foreman decides which crew takes which job, and can reassign them when a crew is added or lost.

!
Common Misconception

A connector is not where data moves. Beginners often think restarting a connector restarts the copying. Actually the connector only plans the work; tasks do the copying. A connector can be healthy while all of its tasks are failed or unassigned.

3How a Connect Cluster Holds Itself Together

There is no separate manager. The workers organize themselves using Kafka itself.

Group Membership Through Kafka

In distributed mode, every worker is configured with the same group name. Each worker contacts a Kafka broker acting as the group coordinator and announces itself as a member. The coordinator keeps a list of members and expects each one to send small “I’m alive” messages called heartbeats. When the list of members changes, the coordinator tells everyone that a rebalance is needed, and the members start the joining process again.

Electing a Leader

During each rebalance, the coordinator picks one member as the leader. This is not a permanent title; a different worker may be leader next time. The leader receives the list of all members and information about what each one currently holds, and it calculates the new assignment for everybody. The other workers wait for their part of the plan. The plan is delivered through the coordinator, and each worker starts or stops its pieces accordingly.

Where the Truth Is Stored

The leader needs to know which connectors exist and how many tasks each has. That knowledge lives in the internal topics. A configuration topic stores every connector’s settings and every task’s settings. An offsets topic stores how far source connectors have progressed. A status topic stores whether each connector and task is running, paused, or failed. Because these are ordinary Kafka topics, they are durable and replicated, and any worker can read them to catch up.

sequenceDiagram
  participant W as Worker
  participant GC as Group Coordinator
  participant L as Leader Worker
  participant CT as Config Topic
  W->>GC: Join group
  GC-->>L: You are leader, here are all members
  L->>CT: Read current connectors and tasks
  L->>L: Calculate assignment
  L->>GC: Send assignment plan
  GC-->>W: Your assignment
  W->>W: Start or stop connectors and tasks
        
FIG 2 — The basic flow of one rebalance in a Connect cluster
Simple Analogy

A group of volunteers meets at a community hall. They sign an attendance sheet (the coordinator). One volunteer, chosen for the day, reads the shared job board (the config topic) and hands out tasks. The board stays on the wall, so a late arrival can read it too.

i
Design Tip

Give each separate Connect cluster its own group name and its own set of internal topics. Two clusters sharing a group name will mistake each other for members and fight over the same connectors, which is a confusing and expensive mistake.

4What Triggers a Rebalance?

Every rebalance has a cause. Learning the common causes is the first step to calming a noisy cluster.

1

A Worker Joins

A new server starts, either to add capacity or to replace one that was removed. The group must give it a share of the work.

2

A Worker Leaves Politely

A server shuts down normally and tells the coordinator it is leaving. The group must redistribute what it was holding.

3

A Worker Disappears

A server crashes, freezes, or loses its network. After heartbeats stop for long enough, the coordinator declares it gone and starts a rebalance.

4

A Connector Is Created, Changed, or Deleted

Someone adds a new connector or edits an existing one. The list of work has changed, so the group must adjust.

5

A Connector Changes Its Task Count

A running connector notices that the outside world changed, such as new tables appearing in a database, and asks for a different number of tasks. The list of tasks changes, so a rebalance follows.

6

A Worker Falls Out of Sync

A worker misses updates to the shared configuration and must catch up, which can force a fresh round of joining.

!
Common Misconception

A task crashing does not trigger a rebalance. When a task fails, it simply shows a failed status and stays there until someone restarts it. Rebalancing is about who owns work, not about whether the work is healthy.

TriggerUsually Caused ByHow Often
Worker joinsDeployments, scaling, restartsPlanned and occasional
Worker leaves or vanishesDeployments, crashes, network troublePlanned or unplanned
Connector added or removedTeams managing pipelinesDepends on the organization
Task count changesConnectors reacting to outside changesCan be frequent for dynamic sources
Falling out of syncSlow workers, long pausesRare but disruptive
i
Design Tip

When a cluster rebalances more often than you expect, list which of these six causes fired. Most noisy clusters have just one dominant cause, such as a connector that keeps changing its task count or a worker that keeps timing out.

5The Old Way: Eager Rebalancing

The original protocol, which stops everything on every change.

How Eager Rebalancing Works

The word eager describes a protocol that acts immediately and completely. When any rebalance begins, every worker stops every connector and every task it owns. Only when all workers have released everything do they rejoin the group. The leader then computes a completely fresh assignment as if nothing had existed before, and workers start whatever they are given. From the first stop to the last start, no data moves anywhere in the cluster.

1

A Change Is Detected

The coordinator announces that the group must rebalance.

2

Everyone Stops Everything

Every worker stops all its connectors and tasks before rejoining. Data flow across the whole cluster halts.

3

Everyone Rejoins

Each worker reports that it holds nothing and waits for the group to be complete.

4

The Leader Assigns From Scratch

The leader divides all connectors and tasks across all workers as if starting over.

5

Everyone Starts Again

Workers start their new assignments. Tasks reopen connections, reload state, and resume from their saved positions.

sequenceDiagram
  participant A as Worker A
  participant B as Worker B
  participant N as New Worker
  Note over A,B: Both running tasks normally
  N->>A: New worker joins, rebalance begins
  A->>A: Stop ALL tasks
  B->>B: Stop ALL tasks
  Note over A,N: No data moves anywhere
  A->>B: Everyone rejoins, leader assigns from scratch
  A->>A: Start new assignment
  B->>B: Start new assignment
  N->>N: Start new assignment
        
FIG 3 — Eager rebalancing: a single new worker halts every task in the cluster
Simple Analogy

A teacher gets one new student, so she asks every student to close every book, put away all supplies, and line up. Then she reassigns every desk in the classroom. One new arrival costs the whole class a lost lesson.

Why It Was Designed This Way

The eager protocol is simple and safe. Because everyone releases everything before anyone starts anything, there is never a moment when two workers both think they own the same task. Simplicity was a reasonable choice when Connect clusters were small and rebalances were rare. As clusters grew and pipelines became business-critical, the cost of that simplicity became too high.

Advantages

  • Very simple to understand and reason about
  • No moment of shared ownership of a task
  • The leader plans on a clean slate every time
  • Behavior is predictable and easy to test

Disadvantages / Trade-offs

  • All data flow halts on every rebalance
  • Tasks that did not need to move are still restarted
  • Rolling restarts cause a chain of full stops
  • Duplicates and delays grow with cluster size
  • A flapping worker can cause repeated cluster-wide pauses

6The Pain of Eager Rebalancing in Real Life

Four everyday situations where stop-the-world rebalancing hurt real teams.

The Rolling Deployment

A team upgrades a ten-worker cluster one worker at a time. Each restart makes one worker leave and rejoin, and each departure and arrival triggers an eager rebalance. That is about twenty full stops of the entire cluster during one deployment, even though only one worker changes at any moment. Pipelines that were supposed to be untouched spend a large part of the deployment doing nothing.

The Flapping Worker

One worker suffers long garbage collection pauses and keeps missing its heartbeats. It is repeatedly declared dead and then rejoins. Each cycle triggers a complete stop of every task across the cluster. The sick worker punishes the healthy ones again and again.

The Busy Connector Team

A platform serves fifty teams, each creating and editing connectors throughout the day. Every creation or edit triggers a rebalance. In the eager world, the cluster is halted dozens of times a day, and every pipeline feels each halt.

The Autoscaling Cluster

A container platform adds workers when load rises and removes them when it falls. Scaling events are frequent, and every event stops all work in the cluster, at the very moment when load was rising and the cluster needed to be at its best.

The Hidden Costs Beyond the Pause

Cost 1

Restart Overhead

Every restarted task must reconnect to its outside system, reload its settings, and sometimes rebuild in-memory state. For heavy connectors this takes far longer than the rebalance itself.

Cost 2

Duplicate Records

Progress is saved periodically, not on every record. A task stopped abruptly may re-send a few records after restart, causing duplicates downstream.

Cost 3

Latency Spikes

Downstream users see gaps in the data. Dashboards go quiet and alerts fire because data is late.

Cost 4

Load on the Outside System

When everything reconnects at once, databases and services receive a burst of new connections and queries, sometimes stressing the very systems the connectors depend on.

“In the old protocol, the cost of a rebalance was proportional to the size of the cluster, not to the size of the change.”

7The Big Idea: Incremental Cooperative Rebalancing

Two words, two ideas: move only what changes, and let workers hand work over politely.

Idea One: Incremental

Incremental means “in small steps.” Instead of throwing everything away and starting over, the cluster keeps its current assignment and adjusts it. If a new worker joins, only a few pieces of work move to it. Everything else stays exactly where it is, running without interruption. The size of the disruption now matches the size of the change.

Idea Two: Cooperative

Cooperative means “workers work together.” Instead of every worker dropping everything, workers keep running during the rebalance and give up ownership of specific pieces only when the leader asks them to. A piece of work that must move is first released by its old owner, and only in a following round is it granted to its new owner. Because the release comes first, no piece of work is ever owned by two workers at the same time.

Simple Analogy

Passing a baton in a relay race. The current runner does not drop the baton on the track for the next runner to find. She holds it until the next runner is in place, hands it over cleanly, and only then stops. The rest of the team keeps running the whole time.

The Key Trick: Two Rounds for Anything That Moves

1

First Round: Announce and Revoke

The leader compares the current assignment with the ideal one. Anything already in the right place is left alone. For anything that should move, the leader tells its current owner to stop it. Nothing new is assigned yet for those pieces.

2

Owners Release Their Work

The owners stop only the revoked pieces, still running everything else, and rejoin the group reporting what they now hold.

3

Second Round: Assign

Now that the pieces are unowned, the leader grants them to their new owners, who start them.

sequenceDiagram
  participant A as Worker A
  participant B as Worker B
  participant N as New Worker
  participant L as Leader
  Note over A,B: Both running tasks normally
  N->>L: New worker joins
  L->>A: Round one: revoke Task 3 only
  L->>B: Round one: keep everything
  A->>A: Stop Task 3, keep others running
  B->>B: Keep running everything
  A->>L: Rejoin holding remaining tasks
  L->>N: Round two: assign Task 3
  N->>N: Start Task 3
        
FIG 4 — Cooperative rebalancing: only the moving task stops, and it stops before it is reassigned

Advantages

  • Untouched tasks keep running through the rebalance
  • Disruption is proportional to the size of the change
  • Rolling restarts become far gentler
  • A task never has two owners at once
  • Fewer reconnection bursts against outside systems

Disadvantages / Trade-offs

  • More rounds of communication for pieces that move
  • More complex logic and more settings to understand
  • Moved tasks wait for the old owner to release them
  • Requires all workers to support the newer protocol
i
Design Tip

The protocol gives its biggest benefit when most rebalances involve small changes, such as one worker joining or one connector being edited. If your cluster changes wildly all the time, fix the cause of the churn first; a gentler protocol only softens the damage.

8Step by Step: A New Worker Joins

Following one common event through the cooperative protocol, moment by moment.

Suppose a cluster has two workers. Worker A holds connector Orders and two of its tasks. Worker B holds connector Customers and two of its tasks. Each worker is running smoothly. Now a third worker, called C, starts up.

1

C Announces Itself

C contacts the group coordinator and asks to join. The coordinator tells A and B that the group has changed and that they should rejoin.

2

A and B Rejoin While Still Running

Unlike the eager protocol, A and B do not stop anything. They rejoin and report exactly what they currently hold. C reports that it holds nothing.

3

The Leader Compares Reality With the Ideal

The elected leader sees that A and B each hold four pieces and C holds none. An ideal split among three workers would be closer to three pieces each. It decides that one piece should move from A and one from B.

4

Round One: Revocations Only

The plan tells A to give up one task and B to give up one task. It assigns nothing new to C yet, because those tasks are still owned.

5

A and B Stop Only the Revoked Tasks

Each stops just one task cleanly, while the rest of its work continues without pause.

6

Round Two: Assignment

A and B rejoin, now holding three pieces each. The two released tasks are unowned, so the leader assigns them to C, which starts them.

7

The Cluster Is Balanced

Every worker now holds about the same amount. Of the eight pieces of work, six never stopped at all.

StageWorker AWorker BWorker C
Before4 pieces running4 pieces runningNothing
After round one3 running, 1 stopped3 running, 1 stoppedNothing yet
After round two3 running3 running2 started
Interrupted pieces11Not applicable
Simple Analogy

A new cashier opens a lane at a busy grocery store. The manager does not close every lane and re-sort every shopper. She asks the two longest queues to send one customer each to the new lane, and the rest keep shopping as before.

i
Design Tip

When a new worker joins a large cluster, expect a modest number of tasks to move. If you see the new worker starting many more tasks than the arithmetic suggests, check whether the cluster is using the cooperative protocol at all, or whether it has quietly fallen back to the eager one.

9Step by Step: A Worker Leaves, Politely or Suddenly

A departure can be clean or chaotic. The protocol treats the two cases differently.

Case One: A Graceful Departure

When a worker is shut down normally, it stops its own connectors and tasks first and tells the group it is leaving. Because the work has been released deliberately, the cluster knows exactly what became unowned and can reassign it. The leader spreads the released pieces among the remaining workers in a single assignment round. This is the tidy path.

Case Two: A Sudden Disappearance

When a worker crashes or loses its network, it cannot announce anything. The cluster only finds out when heartbeats stop and the coordinator’s patience runs out. After that, the group rebalances. The pieces of work held by the missing worker are now called lost assignments: nobody stopped them politely, but they are clearly no longer running. Since the worker might still be alive but merely unreachable, the leader has to be careful about how quickly it hands those pieces to others.

flowchart TD
  D["A worker stops responding"] --> H{"Did it announce leaving?"}
  H -->|"Yes"| G["Graceful: work released, reassigned at once"]
  H -->|"No"| T["Heartbeats stop, timeout expires"]
  T --> LR["Group rebalances, work marked as lost"]
  LR --> W["Leader waits for the scheduled delay"]
  W --> R{"Did the worker return in time?"}
  R -->|"Yes"| B["Worker gets its old work back"]
  R -->|"No"| X["Work is reassigned to remaining workers"]
        
FIG 5 — How the leader treats a worker that leaves politely versus one that vanishes
Simple Analogy

A cook who says “I’m going on break” leaves clean instructions, and someone covers the dishes immediately. A cook who vanishes mid-service leaves half-finished pots. The kitchen manager waits a few minutes in case the cook was just in the storeroom, and reassigns the pots only if the cook does not reappear.

Why the Difference Matters

Point 1

Graceful Leaves Are Fast

Because the work is stopped cleanly and announced, the cluster can reassign it right away and lose no time waiting.

Point 2

Sudden Leaves Are Uncertain

The cluster cannot know whether the worker is dead or only briefly unreachable, so it hesitates before reassigning.

Point 3

Deployments Look Like Both

A polite shutdown followed by a quick restart looks, to the cluster, like a leave and a join in rapid succession. The next chapter explains how the protocol avoids overreacting.

Point 4

Shutdown Should Be Clean

Stopping workers with a proper termination signal lets them release their work politely. Killing them abruptly forces the slower, uncertain path.

!
Common Mistake

Container platforms that force-kill workers after a very short grace period turn every polite shutdown into a sudden disappearance. Give workers enough time to stop their tasks and leave the group properly.

10The Scheduled Rebalance Delay: Waiting Before Panicking

A built-in grace period that prevents needless shuffling when a worker returns quickly.

The Problem It Solves

Think about a routine restart. A worker leaves, and thirty seconds later a fresh copy of it starts again. If the leader instantly reassigned the departed worker’s tasks to the others, the cluster would move tasks away, and then, when the worker came back, move tasks back again. That is two rounds of unnecessary movement for something that was over in half a minute.

The Solution: A Grace Period

The protocol includes a configurable waiting time, the scheduled rebalance delay. When a worker disappears and its work becomes lost, the leader does not reassign that work immediately. It schedules another rebalance for later, after the delay, and lets the remaining workers keep running what they already have. If the missing worker comes back before the delay ends, it simply receives its previous work again, and nothing else in the cluster has moved. If the delay ends and the worker has not returned, the leader assigns the lost work to the remaining workers.

1

The Worker Vanishes

Its tasks stop. The leader notes them as lost, not as ready to reassign.

2

The Clock Starts

The leader sets a timer equal to the scheduled delay. Other workers keep running their own work as usual.

3a

Path A: The Worker Returns in Time

It rejoins and is handed back the exact work it had. No other task moves. The disruption is limited to those few tasks and to the downtime of the restart.

3b

Path B: The Timer Expires

The leader calls a rebalance and spreads the lost tasks among the surviving workers.

Simple Analogy

When a waiter steps out for a moment, the restaurant does not immediately give away all his tables. The manager waits a few minutes. If the waiter returns, he resumes his tables; if not, the tables are shared among the others.

Choosing the Delay

The delay is a trade-off between two costs. A long delay is gentle on rolling restarts, because workers can leave and come back without disturbing the cluster. But if a worker is truly dead, its tasks sit idle for the whole delay before anyone takes over, which means data pipelines stay stopped for that long. A short delay recovers quickly from real failures but causes more unnecessary movement during routine restarts. Setting the delay to zero disables the grace period entirely and reassigns lost work immediately.

Longer Delay

  • Rolling restarts cause very little task movement
  • Brief network glitches are forgiven
  • Fewer reconnection bursts against outside systems

Shorter Delay

  • Real failures are recovered from faster
  • Idle tasks wait less for a takeover
  • More task movement during routine restarts
i
Design Tip

Set the delay a little longer than the time a normal restart of one worker takes in your environment, including its startup. If your restarts take one minute, a delay of a few minutes is generous. Then a healthy deployment moves almost nothing, and a real crash is still recovered from within an acceptable time.

11How the Leader Computes the Plan

The leader’s assignment logic follows a few simple, sensible rules.

What the Leader Knows

At the start of each rebalance, every worker tells the leader three things: which workers exist, what each currently holds, and how up to date its view of the shared configuration is. The leader also reads the configuration topic to learn the full list of connectors and tasks that should exist. From this it can compare “what should exist” with “what is running where.”

The Rules It Follows

1

Keep What Is Already Placed

Work that is already running somewhere stays there unless moving it is needed for balance. This stickiness is what makes the protocol incremental.

2

Place New Work on the Emptiest Workers

Newly created connectors and tasks are given to the workers currently holding the fewest pieces.

3

Balance by Count

The leader aims for each worker to hold roughly the same number of connectors and the same number of tasks. It looks at how many pieces there are, not at how heavy they are.

4

Revoke Before Reassigning

If a piece must move from one worker to another, it is first revoked from the old owner, and only in a later round given to the new owner.

5

Wait Before Reassigning Lost Work

Work belonging to a vanished worker is held back for the scheduled delay before it is given to others.

Category 1

Continuing Assignments

Pieces that are running and staying put. These are never touched.

Category 2

Revoked Assignments

Pieces the leader asks a worker to release because they should live elsewhere.

Category 3

Lost Assignments

Pieces whose owner vanished without releasing them. They wait out the delay before being reassigned.

Category 4

New Assignments

Pieces newly created or newly available, ready to be given to a worker.

Simple Analogy

A school principal balancing classes counts students, not talent. Each class gets roughly the same number of pupils. This is fair by headcount but not by effort: a class of sleepy students and a class of rowdy ones both count the same.

!
Common Misconception

The leader does not measure CPU, memory, or throughput when it balances. A cluster can be perfectly balanced by count while one worker carries all the heavy tasks. Chapter 19 shows how to deal with this.

12Protocol Versions: Eager, Compatible, and Sessioned

One setting decides which rebalancing language the workers speak, and how they upgrade together.

Three Choices

Each worker is configured with a protocol setting that names the rebalancing behavior it is willing to use. Because a cluster must agree on one behavior, the group picks the best option that every member supports. This makes safe upgrades possible: workers can be taught the new language before anyone is forced to use it.

Option 1

Eager

The original stop-everything behavior. Every worker understands it, which makes it the universal fallback. If even one worker is set to eager, the whole group uses eager rebalancing.

Option 2

Compatible

Speaks both languages. If every worker in the group supports cooperative rebalancing, the group uses it; if any worker is eager only, the group falls back to eager. Designed as the bridge during upgrades.

Option 3

Sessioned

Cooperative rebalancing plus an added security feature: internal requests between workers are protected by short-lived keys that the leader distributes. In recent versions this is the default choice.

flowchart TD
  S["Each worker declares its protocol"] --> Q{"Does every worker support cooperative?"}
  Q -->|"No, at least one is eager only"| E["Group uses eager"]
  Q -->|"Yes"| C["Group uses cooperative"]
  C --> K{"Does every worker support sessioned?"}
  K -->|"Yes"| SS["Cooperative plus signed internal requests"]
  K -->|"No"| CC["Cooperative without signed requests"]
        
FIG 6 — The group always uses the newest protocol that every member can speak

What “Sessioned” Adds

In distributed mode, a worker that receives a request to change a connector may need to forward it to the worker that owns the connector, which uses the cluster’s internal web interface. Without protection, an outsider who could reach that interface might impersonate a worker. The sessioned protocol has the leader create a shared secret key that is rotated periodically and distributed to members through the rebalance itself. Internal requests carry a signature made with that key, so workers can verify that a request truly came from a fellow member.

Simple Analogy

A group of workers each carry a badge stamped with this week’s secret symbol. The foreman changes the symbol regularly and tells only the group. Anyone who shows up without the current symbol is politely turned away at the door.

SettingRebalancing StyleInternal Request ProtectionBest For
EagerStop everythingNone addedLegacy compatibility only
CompatibleCooperative when everyone allows, else eagerNone addedMid-upgrade transition
SessionedCooperativeSigned with rotating keysModern default for new and upgraded clusters
i
Design Tip

Do not assume your cluster is using cooperative rebalancing just because your version supports it. Confirm which protocol the group actually agreed on by checking the worker rebalance metrics, since one stale worker with an old setting can quietly hold everyone back to eager behavior.

13Upgrading Safely From Eager to Cooperative

A rolling upgrade recipe that never mixes languages in a dangerous way.

Suppose you run an older cluster using eager rebalancing and you want to move to cooperative rebalancing without downtime. The key fact is that the group always falls back to the least capable member. That means you cannot simply switch workers one by one to a cooperative-only setting; a half-upgraded group would contain members that cannot understand one another. The safe path uses the compatible setting as a bridge.

1

Upgrade the Software Everywhere

Make sure every worker runs a version that understands cooperative rebalancing. Do this first, with the protocol setting unchanged, so the group keeps using eager behavior during the rollout.

2

Switch Workers to Compatible, One at a Time

Restart each worker with the compatible setting. Because at least one worker still says eager, the group remains eager during this phase. That is expected and safe.

3

The Group Flips When the Last Worker Switches

When the final worker rejoins with the compatible setting, every member now supports cooperative rebalancing, and the group starts using it automatically at the next rebalance.

4

Optionally Move to Sessioned

Once the group is stable on cooperative behavior, roll workers to the sessioned setting to gain the internal request protection, again one at a time, using the same care.

5

Verify With Metrics

Confirm that the reported protocol and the rebalance times match your expectations, and that rolling restarts now move only a few tasks.

Simple Analogy

A country switching from driving on one side of the road to the other cannot let half the drivers change lanes first. It prepares everyone, then flips at a single moment. The compatible setting is the preparation phase in which all drivers learn the new rule before it takes effect.

ANTI-PATTERN-01 Avoid
Problem

Operators try to force one worker at a time straight to a cooperative-only setting while others are still eager, or they roll back a single worker to eager after the group has moved on.

Why It’s Harmful

A member that speaks a different language from the rest of the group can cause the group to fall back to eager unexpectedly, or can cause confusion during assignment, leading to repeated rebalances and paused pipelines.

Correct Approach

Upgrade the software first, use the compatible setting as the bridge, move everyone together through it, and only then adopt the newer setting. If you must roll back, roll back the whole group in order, not a single worker.

i
Design Tip

Do the upgrade during a calm period and keep an eye on the rebalance metrics throughout. The first few restarts behave like the old world; the improvement appears after the last worker switches. Do not judge the result until the whole group has crossed over.

14Two Different Rebalances: Workers and Sink Consumers

A source of endless confusion: Connect contains two separate rebalancing layers that can interact.

Layer One: Workers Sharing Connectors and Tasks

This is the layer this tutorial has described so far. The Connect workers form a group, and the unit being divided is the connector or task. The protocol we studied, eager or cooperative, applies to this layer.

Layer Two: Sink Tasks Sharing Topic Partitions

A sink connector reads from Kafka topics. Each of its tasks contains a regular Kafka consumer, and all the tasks of one sink connector belong to a single consumer group. That consumer group divides the topic partitions among the tasks, using the ordinary consumer rebalancing you may already know. This is a completely separate group with a separate coordinator conversation and a separate assignment strategy.

flowchart TD
  subgraph L1["Layer one: Connect worker group"]
    W1["Worker A"]
    W2["Worker B"]
  end
  subgraph L2["Layer two: sink connector consumer group"]
    T1["Sink task 0"]
    T2["Sink task 1"]
  end
  W1 --> T1
  W2 --> T2
  T1 --> P["Topic partitions"]
  T2 --> P
        
FIG 7 — Workers share tasks in one group, while sink tasks share partitions in another
QuestionLayer One: Worker GroupLayer Two: Sink Consumer Group
Who are the members?Connect workersTasks of one sink connector
What is divided?Connectors and tasksTopic partitions
What triggers it?Workers or configurations changeTasks start or stop, partitions are added, topics matched by a pattern appear
Which protocol setting controls it?The worker’s protocol settingThe consumer’s own assignment strategy setting
What does it affect?Which worker runs which taskWhich task reads which partition
Simple Analogy

A delivery company first assigns drivers to trucks (layer one), and then each truck’s crew divides the neighborhoods on the route among themselves (layer two). Changing which driver drives which truck does not itself change the neighborhoods, but it can force the crew to reorganize.

How the Layers Interact

When the worker-level rebalance stops and starts a sink task, that task leaves or joins its consumer group, which triggers a consumer group rebalance for that connector. With cooperative worker rebalancing, fewer sink tasks stop, so fewer consumer group rebalances occur. But the consumer layer has its own strategy setting. If sink tasks use an eager consumer assignment strategy, then each time one task joins or leaves, all tasks of that connector pause reading briefly, even when the worker layer was gentle. Modern consumers also offer a cooperative assignment strategy, which softens this layer in the same spirit.

!
Common Misconception

“We enabled cooperative rebalancing, so sink connectors never pause.” Only the worker layer became cooperative. The consumer group inside each sink connector follows its own settings. To reduce pauses fully, look at both layers.

i
Design Tip

When diagnosing a sink connector that pauses during a deployment, ask two questions: did the worker group rebalance, and did the connector’s consumer group rebalance? They have different metrics and different fixes, and they often happen one right after the other.

15Source and Sink Connectors Under Rebalance

What happens to the data when a task is stopped and started somewhere else.

Source Tasks: Progress Lives in Kafka

A source task reads from an outside system and writes to Kafka. It periodically reports how far it has read, for example a position in a database change log. Those reports are saved in the offsets topic. When a task is stopped and restarted on another worker, the new copy reads the saved position and resumes from there. Because the saved position is only updated periodically, the new task may re-read a few records that the old one already sent but had not yet recorded. This produces a small number of duplicates, which is part of the standard at-least-once behavior.

Sink Tasks: Progress Lives in the Consumer Group

A sink task reads from Kafka and writes to an outside system. Its progress is stored as a committed position in the connector’s consumer group. When a sink task is stopped, it should first finish writing what it has and commit its position. When another task takes over its partitions, it starts from the committed position. If the outgoing writes were done but the commit did not happen yet, the new task repeats those records. Again, a few duplicates are possible unless the outside system can safely ignore repeats.

Source

Where Progress Is Saved

In the Connect cluster’s offsets topic, updated periodically as records are confirmed.

Source

Effect of a Move

The new owner resumes from the last saved position. Some records from just before the stop may be sent again.

Sink

Where Progress Is Saved

In the consumer group’s committed positions, updated after batches are written to the outside system.

Sink

Effect of a Move

The new owner resumes from the committed position. Records written but not yet committed may be written again.

Simple Analogy

A relay runner hands the baton over at a marked spot. If the handover is smooth, no distance is repeated. If the first runner stopped a few steps past the last marker, the second runner starts at the marker and re-runs those few steps.

Why Cooperative Rebalancing Helps Here Too

Every unnecessary stop is a chance for duplicates and delay. Because the cooperative protocol stops far fewer tasks, it produces far fewer duplicate records and less lag, even though the semantics of each individual move remain the same. The protocol reduces how often moves happen; it does not change what a single move means.

What Improves

  • Far fewer tasks are restarted per event
  • Fewer duplicates overall
  • Shorter gaps in data delivery
  • Less reconnection load on external systems

What Does Not Change

  • A moved task still resumes from saved positions
  • Duplicates are still possible around each move
  • Downstream systems still need to tolerate repeats
  • Long shutdowns of a task still delay its handover
i
Design Tip

Design destination systems to accept the same record twice without harm, for example by using unique keys and overwriting rather than appending. This makes rebalances, restarts, and retries all safe by construction.

16Stopping Tasks: Shutdown Time, Zombies, and Fencing

Cooperative rebalancing depends on tasks stopping cleanly and quickly. Sometimes they do not.

The Stop Request

When the leader revokes a task, the worker asks the task to stop. Well-written tasks notice the request, finish the current small piece of work, close their connections, and report that they have stopped. The worker waits a limited time for this to happen, controlled by a shutdown timeout. If the task does not stop within that time, the worker gives up waiting and continues, and the task may remain half-alive in the background.

What Is a Zombie Task?

A zombie task is one that the cluster believes is stopped but which is actually still running, perhaps stuck in a slow call to an outside system. If the cluster then starts a fresh copy of the same task on another worker, two copies exist at once, and both may read from the same source or write to the same destination. That can create duplicates or, in worse cases, conflicting writes.

sequenceDiagram
  participant L as Leader
  participant A as Worker A
  participant B as Worker B
  L->>A: Revoke Task 5
  A->>A: Ask Task 5 to stop
  Note over A: Task is stuck in a slow external call
  A->>L: Shutdown timeout reached, moving on
  L->>B: Assign Task 5
  B->>B: Start Task 5
  Note over A,B: Two copies may now be running, the old one is a zombie
        
FIG 8 — A task that ignores its stop request can become a zombie beside its replacement
Simple Analogy

A night guard is told his shift is over, but he is still wandering the building because he did not hear the announcement. A new guard arrives and starts the same rounds. Now two guards patrol the same corridors, each unaware of the other.

How to Prevent Zombies

Defense 1

Responsive Stop Logic

Connector authors should make their tasks check for stop requests often and abandon long waits quickly, so stopping is fast.

Defense 2

Reasonable Shutdown Timeout

Allow enough time for a clean stop of your slowest connectors, but not so much that a stuck task holds up a whole rebalance.

Defense 3

Timeouts on External Calls

Every network call to the outside system should have its own timeout, so no task can be stuck forever inside it.

Defense 4

Fencing for Strong Guarantees

Where exactly-once delivery is required, newer Connect features can fence out the old copy of a source task so that it can no longer write, even if it is still alive.

ANTI-PATTERN-02 Avoid
Problem

A connector’s tasks make blocking calls to an outside system with no timeout and ignore stop requests while waiting.

Why It’s Harmful

When a rebalance asks such a task to stop, it cannot comply, so the shutdown timeout expires and the cluster proceeds. The stuck task lingers as a zombie, causing duplicates, resource leaks, and confusing behavior long after the rebalance.

Correct Approach

Insist that every connector uses timeouts for all outside calls and checks for stop requests regularly. Test stopping a task while it is in the middle of a slow call, as part of connector acceptance.

i
Design Tip

Measure how long your slowest connectors take to stop, and choose the shutdown timeout from that measurement. A stop that takes several seconds in testing will take longer under production load.

17The Timeouts That Govern Rebalancing

Seven clocks, each answering a different question about patience.

Most rebalancing trouble in production comes from misunderstood timing settings. Each timeout answers one specific question. Keeping them apart in your mind is the fastest way to reason about strange behavior.

Timing SettingThe Question It AnswersEffect of a Larger ValueEffect of a Smaller Value
Heartbeat intervalHow often does a worker say “I’m alive”?Slower detection of membership changesMore small messages, faster detection
Session timeoutHow long may a worker be silent before it is declared dead?Slower recovery from real crashes, fewer false alarmsFaster recovery, more false alarms from pauses
Rebalance timeoutHow long may members take to rejoin during a rebalance?More patience for slow members, longer stalled rebalancesSlow members get kicked out sooner
Scheduled rebalance delayHow long to wait before reassigning a vanished worker’s tasks?Gentler rolling restarts, longer idle time after a real crashFaster takeover, more needless movement
Task shutdown timeoutHow long to wait for a task to stop cleanly?Cleaner stops, slower handoversFaster handovers, more zombie risk
Worker sync timeoutHow long may a worker take to catch up on shared configuration?More patience for lagging workersLagging workers give up sooner
Worker unsync backoffHow long does a worker that could not catch up stay out of the group?Longer time out of service for that workerQuicker retry, risk of repeated failure

How They Fit Together

1

Heartbeats Must Fit Inside the Session

The heartbeat interval must be comfortably smaller than the session timeout, so a couple of missed heartbeats do not cause a false death declaration.

2

Rebalance Time Must Cover the Slowest Stop

The rebalance timeout should be long enough for a worker to stop its slowest revoked task and rejoin. If it is shorter, healthy workers may be ejected during rebalances.

3

The Scheduled Delay Must Cover a Restart

The delay should exceed a typical worker restart time, otherwise routine deployments will always cause reassignments.

4

Shutdown Time Must Be Below Rebalance Time

The task shutdown timeout should fit comfortably inside the rebalance timeout, so a stuck task does not push the worker past its allowed rebalance window.

Simple Analogy

A restaurant has several patience rules: how often the waiter checks in, how long a silent waiter is assumed missing, how long a table change may take, and how long to wait before giving away a missing waiter’s tables. Each rule is sensible alone, but they must agree with one another or the floor descends into chaos.

!
Common Mistake

Raising the session timeout to hide flapping without fixing the cause. A larger timeout makes false alarms rarer, but it also makes real crashes take longer to detect, so the underlying pauses or network problems still hurt, just later.

18Choosing Settings for Your Environment

There is no universal best value. The right numbers depend on how your workers live and die.

Start By Asking How Workers Restart

Before touching any timeout, describe how workers actually come and go in your environment. How long does a planned restart take from stop to healthy? How often are workers replaced? How quickly do you need a real failure to be repaired? The answers decide almost every setting.

Environment 1

Fixed Virtual Machines

Restarts are rare and deliberate. A moderate scheduled delay is fine, because deployments are planned and real crashes are unusual. Prioritize clean shutdown scripts.

Environment 2

Containers With Rolling Updates

Restarts are frequent and fast. Use a scheduled delay larger than pod restart time, and give containers a shutdown grace period long enough for workers to stop tasks and leave politely.

Environment 3

Autoscaling Fleets

Workers are added and removed by policy. Scale down slowly and one at a time, and avoid rules that add and remove workers within a few minutes of each other.

Environment 4

Spot or Preemptible Machines

Workers may vanish suddenly. Prefer a shorter scheduled delay so lost work is reassigned quickly, and accept more movement as the price of cheap hardware.

A Reasoning Recipe Instead of Magic Numbers

1

Measure Restart Time

Time a worker from the start of shutdown until it has rejoined and is running tasks again.

2

Decide Acceptable Outage After a Crash

Ask the business how long a pipeline may stand still after a real failure. This is the upper limit for the scheduled delay.

3

Choose the Delay Between the Two

Pick a value above the restart time and below the acceptable outage. If no such value exists, either improve restart speed or accept some movement.

4

Measure Slowest Task Stop

Find how long your slowest task takes to stop under load, then set the shutdown timeout a bit above it.

5

Fit the Session and Rebalance Timeouts

Make the rebalance timeout cover the shutdown timeout with room to spare, and make the session timeout tolerate your typical pauses.

6

Test With a Real Rolling Restart

Restart workers one at a time in a test cluster and watch how many tasks move and how long pipelines pause.

i
Design Tip

Write your chosen values and the reasoning behind them in the team’s runbook. A number without its reason gets changed carelessly the next time someone is under pressure.

19Balance by Count Is Not Balance by Load

Why an evenly split cluster can still have one exhausted worker, and what to do about it.

The Limitation

As Chapter 11 explained, the leader counts pieces of work; it does not weigh them. A task that copies a tiny reference table and a task that streams millions of records per second each count as one. If the heavy tasks happen to land on the same worker, that worker runs hot while its neighbors idle, yet the cluster is considered perfectly balanced.

Simple Analogy

A manager gives every mover five boxes. One mover gets five feather pillows and another gets five refrigerators. The counts are equal, but the fairness is not.

What Contributes to Skew

Cause 1

Uneven Task Weights

Some tasks read from busy partitions or large tables; others handle a trickle.

Cause 2

Few, Large Tasks

When a connector has only a couple of tasks, each one carries a big slice and dominates whichever worker holds it.

Cause 3

Stickiness

Because the protocol avoids unnecessary moves, an accidental clustering of heavy tasks can persist for a long time.

Cause 4

Mixed Connector Types

CPU-heavy transformations, network-heavy sinks, and memory-hungry sources all count the same to the leader.

Practical Remedies

Use More, Smaller Tasks

Raising the task limit on a heavy connector, where the connector supports it, splits its load into smaller pieces that spread more evenly and are easier for the leader to balance.

Separate Heavy and Light Clusters

Run demanding pipelines in their own Connect cluster with larger machines, so that their load never competes with light housekeeping connectors.

Give Every Worker Comfortable Headroom

Size machines so that the unluckiest worker can still cope. Balance by count then works well enough in practice, because no worker is ever at its limit.

Watch Per-Worker Resource Use

Track CPU, memory, and network per worker, and investigate when one worker is persistently far above the rest.

!
Common Mistake

Assuming that adding workers will always fix an overloaded one. If the overloaded worker holds a single very heavy task, new workers cannot share that task, because a task is the smallest unit of work. Split the task first.

20Monitoring Rebalances: What to Watch

A healthy cluster rebalances rarely and quickly. Metrics tell you when that stops being true.

Rebalance Metric

Rebalancing Flag

Shows whether a worker is in the middle of a rebalance right now. Long stretches of “yes” mean trouble.

Rebalance Metric

Completed Rebalances Total

A running count of finished rebalances. Its rate of increase tells you how noisy the cluster is.

Rebalance Metric

Average and Maximum Rebalance Time

How long rebalances take. Rising values often point to slow task shutdowns or overloaded workers.

Rebalance Metric

Time Since Last Rebalance

A quick way to see whether a cluster has been calm or restless recently.

Rebalance Metric

Leader Name and Epoch

Shows who is leader and which generation the group is in. A rapidly changing epoch is a warning sign.

Rebalance Metric

Protocol in Use

Reveals whether the group is really running cooperative behavior or has fallen back to eager.

Worker Metric

Connector and Task Counts per Worker

Shows how evenly work is spread and how many pieces each worker holds after a rebalance.

Task Metric

Task Status and Restarts

Failed, paused, or repeatedly restarting tasks that may be causing or suffering from rebalances.

Alerts That Actually Help

1

Alert on Rebalance Rate

Too many rebalances in an hour, beyond what your deployments and changes explain, signals flapping or churn.

2

Alert on Long Rebalances

A rebalance that stays in progress for longer than your rebalance timeout suggests a stuck worker or task.

3

Alert on Unexpected Protocol

If the group protocol drops back to eager, someone has probably restarted a worker with an old setting.

4

Alert on Unassigned or Failed Tasks

Work that is neither running nor failed with a clear reason may be stuck in a lost state waiting out the scheduled delay.

5

Alert on Imbalance

Large gaps between workers in task count or resource use suggest a balancing problem that needs a human.

flowchart LR
  M["Worker rebalance metrics"] --> D["Dashboard"]
  S["Task status metrics"] --> D
  R["Resource use per worker"] --> D
  D --> A1["Rebalance rate alert"]
  D --> A2["Long rebalance alert"]
  D --> A3["Protocol fallback alert"]
  A1 --> O["On-call engineer"]
  A2 --> O
  A3 --> O
        
FIG 9 — Turning rebalance metrics into alerts that reach the right person
i
Design Tip

Annotate your dashboards with deployment and scaling events. When a spike in rebalances lines up with a deployment marker, it is expected. When it does not, you have found a real problem.

21Operating a Cluster: Everyday Checks and Runbooks

Simple habits that keep rebalancing boring, which is exactly what you want.

The Management Interface

Every Connect worker offers a small web interface for managing the cluster. Through it you can list connectors, see the status of each connector and each task including which worker currently hosts it, pause and resume connectors, restart connectors and individual tasks, and change configurations. Because any worker can answer, and requests are forwarded to the right owner when needed, you can talk to whichever worker is convenient. During a rebalance, some requests may briefly be refused or delayed while ownership is uncertain, and your tools should be ready to retry.

1

Before a Planned Change

Record the current number of connectors and tasks per worker, and confirm that all workers show the expected protocol and are healthy.

2

Change One Thing at a Time

Restart or replace a single worker, wait for the rebalance to finish and the cluster to settle, and only then continue.

3

Watch the Metrics

Confirm that the rebalance finished, the counts look right, and no task is left failed or unassigned.

4

Restart Only What Is Broken

If a task is failed, restart that task, not the whole connector or worker. A larger restart causes a larger rebalance.

5

Record What Happened

Note any surprises and update the runbook, so the next person benefits.

Helpful Habits

Habit 1

Graceful Shutdowns Only

Stop workers with a normal termination request and give them time to release their work.

Habit 2

Batch Connector Changes

Apply several configuration edits together when possible, since each edit can cause a rebalance.

Habit 3

Pause Before Big Work

Pause non-critical connectors during heavy maintenance to reduce the number of pieces that must be moved and restarted.

Habit 4

Keep Versions Aligned

Run the same Connect version and protocol setting on every worker, apart from short upgrade windows.

!
Common Mistake

Reacting to a slow cluster by restarting every worker at once. In the eager world that was merely painful; in either world it removes all the members at the same moment and forces everything to be reassigned from nothing.

22An End-to-End Walkthrough: A Rolling Deployment

A six-worker cluster is upgraded one worker at a time, and we watch what the cooperative protocol does.

An analytics company runs a Connect cluster of six workers carrying thirty connectors and about ninety tasks, so each worker holds roughly fifteen tasks. The team has set a scheduled rebalance delay of five minutes, and a restart of one worker takes about ninety seconds. Tonight they deploy a new version.

1

Worker One Is Stopped Gracefully

It stops its fifteen tasks, tells the group it is leaving, and shuts down. The other five workers keep running their seventy-five tasks without pause.

2

The Leader Schedules a Delay

Because the departed worker’s fifteen tasks are now unowned, the leader waits for the five-minute delay instead of reshuffling. Those fifteen tasks are briefly idle, but nothing else is disturbed.

3

Worker One Returns After Ninety Seconds

It rejoins running the new version and is handed back its own fifteen tasks. The other workers did not move a single task.

4

The Cycle Repeats for Workers Two Through Six

Each restart affects only that worker’s own tasks, and each is back in about ninety seconds. Eighty-five percent or more of the cluster’s tasks run without interruption during each step.

5

The Team Checks the Results

Metrics show six short rebalances, no task failures, no growth in duplicate records, and a balanced cluster at the end.

MeasureEager Behavior (Estimated)Cooperative With Delay
Tasks interrupted per worker restartAll ninety, twiceOnly the restarted worker’s fifteen, once
Rebalances during the deploymentAbout twelve, each halting everythingAbout twelve, each touching very little
Task restarts caused by unrelated workersManyNone
Reconnection bursts on outside systemsLarge and repeatedSmall and localized
“The same number of rebalances can be a non-event or an outage. The protocol decides which.”
Simple Analogy

A hotel repaints its rooms one floor at a time while guests on other floors carry on unbothered. In the old way, the hotel would evict every guest each time a single floor was repainted.

23Best Practices and Design Patterns

Habits and reusable shapes that experienced Connect operators rely on.

Proven Practices

Practice 1

Use the Newest Protocol Everywhere

Run every worker on the same modern protocol setting so the group never falls back to eager behavior.

Practice 2

Shut Down Gracefully

Give workers a proper stop signal and enough grace time to release their tasks cleanly.

Practice 3

Size the Scheduled Delay to Your Restarts

Choose a delay a little longer than a normal restart and much shorter than the outage you can tolerate.

Practice 4

Insist on Fast, Clean Task Stops

Require connectors to honor stop requests and to use timeouts on every outside call.

Practice 5

Change One Worker at a Time

Serialize restarts and replacements, waiting for the cluster to settle between each.

Practice 6

Look at Both Rebalancing Layers

Tune worker rebalancing and the sink consumers’ own assignment strategy together.

Practice 7

Make Destinations Repeat-Safe

Design outside systems to tolerate duplicate records without harm.

Practice 8

Monitor and Annotate

Track rebalance rate, duration, and protocol, and mark deployments on dashboards.

Reusable Design Patterns

Rolling Restart With a Grace Window

Restart workers one at a time inside the scheduled delay so that their tasks return to them, and nothing else moves.

Tiered Clusters

Separate critical, heavy, and experimental connectors into different Connect clusters, so a churn-heavy experiment cannot rebalance a critical pipeline.

Change Windows for Connector Edits

Batch configuration edits into planned windows, since each edit can trigger a rebalance.

Idempotent Destinations

Use unique keys and overwrite semantics at the destination so that repeated records after a move do no harm.

Canary Worker for Upgrades

Upgrade one worker first, observe it through a full rebalance, and only then continue with the rest.

i
Design Tip

Aim for boring rebalances. If your team hardly notices when a rebalance happens, you have configured the cluster, the connectors, and the destinations well. Noise is a signal that one of those three needs attention.

24Writing Rebalance-Friendly Connectors

The protocol can only be as gentle as the connectors it moves. Authors hold half of the responsibility.

Why Connector Design Matters

Whenever the cluster moves a task, it asks a piece of someone’s code to stop and asks another copy of that code to start. If the code stops slowly, starts slowly, or leaves messy leftovers, the protocol’s gentleness is wasted. Connector authors, whether they work inside your company or in a community project, influence rebalancing more than most operators realize. If you choose connectors or write your own, these qualities make the difference between a well-behaved neighbor and a troublemaker.

Quality 1

Fast, Responsive Stop

The task notices a stop request within moments, abandons any long wait, closes its resources, and returns. A stop that takes seconds instead of minutes keeps rebalances short.

Quality 2

Quick, Cheap Start

The task begins useful work quickly. Tasks that spend minutes loading large amounts of data before doing anything create long pauses every time they move.

Quality 3

Frequent, Honest Progress Reporting

Source tasks that record their position often, and sink tasks that commit often, limit how much work is repeated after a move.

Quality 4

Stable Task Configuration

The connector produces the same task settings unless the outside world truly changed. Needless changes trigger cluster-wide rebalances.

Quality 5

Clean Resource Release

Connections, files, and threads are closed on stop, so a moved task leaves nothing behind that could clash with its replacement.

Quality 6

Safe Repeats

Where possible, the connector writes records in a way that repeating them is harmless, and documents its delivery guarantees honestly.

The Task Count Trap

Many connectors look at the outside system, for example the tables in a database or the files in a folder, and split the work into tasks accordingly. If the outside system changes often, the connector may decide the task list has changed and ask the cluster to reconfigure. Every such request causes a rebalance for everyone. A well-designed connector applies a sensible minimum time between checks, ignores trivial changes, and groups changes together instead of reacting to each one individually.

Simple Analogy

A team leader who reshuffles everyone’s duties every time a single new email arrives keeps the whole team from getting anything done. A better leader looks at the inbox on a schedule and reorganizes only when the workload has really changed.

What to Test Before You Trust a Connector

1

Stop It While It Is Busy

Revoke a task in the middle of heavy work and measure how long it takes to stop cleanly.

2

Stop It While the Outside System Is Slow

Make the outside system slow or unreachable and confirm that the task still stops within the timeout.

3

Move It and Count Duplicates

Move a task to another worker under load and count how many records are repeated at the destination.

4

Change the Outside World Repeatedly

Add and remove tables or files rapidly and check that the connector does not request a flood of reconfigurations.

5

Restart the Whole Worker

Perform a rolling restart and confirm that the connector’s tasks return quickly and cleanly.

!
Common Mistake

Judging a connector only by its normal-day behavior. Most connectors look fine when nothing moves. Their true quality shows in the few seconds around a stop, a move, and a start, which is exactly when rebalancing happens.

i
Design Tip

Make a short “rebalance readiness” checklist for every connector before it enters production. The five tests above take an afternoon and prevent months of mysterious pauses.

25Capacity and Failure Domains for a Connect Cluster

Sizing the cluster so that losing a worker is an inconvenience, not a crisis.

The Survivors Must Absorb the Work

When a worker is lost for good, its tasks are handed to the remaining workers after the scheduled delay. Those workers must have room to take them. If every worker is already running at ninety percent of its capacity, no worker can absorb its neighbor’s load, and the cluster becomes overloaded exactly when it is under stress. A widely used rule of thumb is to plan for the cluster to survive the loss of one worker, or one whole group of workers, while staying comfortably within its limits. This is often called planning for N plus one.

N + 1
enough workers to survive losing one
Zones
spread workers across independent failure domains
Headroom
room on each worker for the extra load

A Simple Sizing Method

1

Estimate Total Work

Add up the resource needs of all connectors, counting CPU, memory, and network at their busiest times, not their averages.

2

Decide How Many Failures to Survive

Choose whether you must survive one worker, or a whole zone of workers, disappearing at once.

3

Compute Per-Worker Load After Failure

Divide the total work by the number of workers that would remain after the chosen failure, and check that this is comfortably within one worker’s capacity.

4

Add Margin for Imbalance

Because balance is by count and not by load, some workers will carry more than their share. Add a margin so that even the unluckiest worker copes.

5

Re-Check After Growth

Every new connector changes the numbers. Revisit the sizing whenever the workload grows meaningfully.

Failure Domains

A failure domain is a group of machines that can fail together, such as all machines in one rack, one power feed, or one availability zone. If all your workers sit in one domain, a single event takes down the whole cluster and no amount of clever rebalancing can help. Spreading workers across several domains means a single event removes only a fraction of them, and the rest continue running and take over the lost work.

flowchart TD
  subgraph Z1["Zone one"]
    A["Worker 1"]
    B["Worker 2"]
  end
  subgraph Z2["Zone two"]
    C["Worker 3"]
    D["Worker 4"]
  end
  subgraph Z3["Zone three"]
    E["Worker 5"]
    F["Worker 6"]
  end
  Z1 --> K["Kafka cluster and internal topics"]
  Z2 --> K
  Z3 --> K
        
FIG 10 — Workers spread across three zones so that losing one zone leaves two thirds running

The Cluster Beneath the Cluster

A Connect cluster depends on the Kafka brokers it talks to. The group coordinator lives on a broker, and the internal topics live on brokers. If a broker that hosts the coordinator becomes unavailable, the Connect workers see membership trouble even though nothing is wrong with the workers themselves. Likewise, if the internal topics are not replicated properly, a broker failure can make the shared configuration unavailable. Healthy Connect rebalancing needs a healthy Kafka cluster underneath, with internal topics replicated for safety.

Simple Analogy

A delivery fleet can survive losing a truck if the other trucks have spare room. It cannot survive if all trucks are parked in one garage that floods, or if the dispatch office that hands out routes loses power.

Advantages of Generous Sizing

  • A lost worker causes no overload for the survivors
  • Uneven balance by count stays harmless
  • Rolling restarts are safe even at busy times
  • Growth in the workload does not force emergency scaling

Disadvantages / Trade-offs

  • More idle capacity costs more money
  • More workers mean more members in each rebalance
  • Very large clusters take longer to settle after changes
  • Sizing needs regular review as connectors are added
i
Design Tip

If a single Connect cluster grows very large, consider splitting it into several smaller clusters by purpose or team. Smaller groups rebalance faster and a problem in one cannot disturb the others.

26Anti-Patterns and Common Mistakes

Ways rebalancing setups go wrong, and how to avoid each one.

ANTI-PATTERN-03 Avoid
Problem

One or two workers are left on an old protocol setting while the rest are configured for cooperative rebalancing.

Why It’s Harmful

The group always falls back to the least capable member, so the entire cluster silently uses stop-everything rebalancing. Teams believe they upgraded but continue to suffer the old pauses.

Correct Approach

Audit the protocol setting on every worker, alert when the group’s active protocol is not the expected one, and keep configuration in one shared template.

ANTI-PATTERN-04 Avoid
Problem

The scheduled rebalance delay is set to zero, or set shorter than a normal worker restart.

Why It’s Harmful

Every routine restart causes the leader to move the departed worker’s tasks elsewhere and then move tasks back when the worker returns, doubling the disruption for no benefit.

Correct Approach

Measure restart time and set the delay above it, while staying below the outage the business can tolerate after a real crash.

ANTI-PATTERN-05 Avoid
Problem

An extremely long scheduled rebalance delay is chosen “to be safe,” without thinking about real failures.

Why It’s Harmful

When a worker truly dies, its tasks stay idle for the whole delay. Pipelines stop for that long and downstream freshness targets are missed.

Correct Approach

Choose the delay from the business’s tolerance for a stalled pipeline, and use faster failure detection and automated worker replacement to keep real outages short.

ANTI-PATTERN-06 Avoid
Problem

Workers are force-killed by the platform after a very short grace period during every deployment.

Why It’s Harmful

Workers cannot stop their tasks or leave the group politely, so each restart looks like a crash. The cluster must wait out heartbeat timeouts and treats the work as lost, prolonging every deployment.

Correct Approach

Allow a shutdown grace period longer than the slowest expected task stop, and make sure the stop signal actually reaches the worker process.

ANTI-PATTERN-07 Avoid
Problem

The session timeout is raised very high to stop workers from being declared dead, instead of investigating why they miss heartbeats.

Why It’s Harmful

The underlying pauses or network trouble remain, and real crashes now take much longer to detect. The symptom moves from noisy to sluggish without being cured.

Correct Approach

Find the cause of the missed heartbeats, such as memory pressure or network problems, fix it, and keep the timeout at a sensible moderate value.

ANTI-PATTERN-08 Avoid
Problem

A connector is written to recompute its task list constantly, causing frequent task reconfiguration requests.

Why It’s Harmful

Each change in the task list triggers a rebalance across the whole cluster. A single restless connector can cause a stream of rebalances that disturbs every other pipeline.

Correct Approach

Have connectors request reconfiguration only when the outside world truly changes, apply sensible minimum intervals, and isolate very dynamic connectors in their own cluster.

ANTI-PATTERN-09 Avoid
Problem

Two separate Connect clusters accidentally share the same group name or the same internal topics.

Why It’s Harmful

The workers treat each other as members of one group, mix up configurations, and fight over connectors, leading to bizarre behavior and constant rebalancing.

Correct Approach

Give every Connect cluster a unique group name and its own configuration, offsets, and status topics.

Quick Reference: Mistakes and Their Fixes

MistakeSymptom You Will SeeFix
One worker on an old protocolAll tasks stop on every rebalanceAlign all workers and alert on protocol fallback
Delay shorter than restart timeTasks shuffle back and forth during deploymentsRaise the delay above restart time
Tasks ignoring stop requestsLong rebalances and duplicate writesAdd timeouts and responsive stop logic
Flapping workerRepeated rebalances with no deploymentsFix pauses or network issues on that worker
Only worker layer tunedSink connectors still pause on task changesReview the consumer assignment strategy of sink tasks

27Troubleshooting Guide: From Symptom to Cause

A practical checklist for the moments when the cluster feels restless.

What You ObserveLikely CauseWhat to Check First
Every task stops when a worker joins or leavesGroup is using eager rebalancingProtocol setting on every worker and the active protocol metric
Rebalances keep happening with no deploymentsA flapping worker or a restless connectorWorker heartbeat problems and connector task reconfiguration frequency
Rebalances take a very long timeA slow task stop or an overloaded workerTask shutdown time and per-worker resource use
A worker was removed while healthyRebalance or session timeout too tightTiming settings compared with real stop and pause times
Tasks are unassigned after a crashWaiting out the scheduled delayTime since the crash versus the configured delay
New worker holds few or no tasksRebalance not yet complete, or stickinessRebalance metrics and count of tasks per worker
One worker runs hot while others idleBalance by count, not by loadTask weights and which heavy tasks landed together
Sink connector pauses after a moveConsumer group rebalance inside the connectorThe connector’s consumer assignment strategy
Duplicate records after deploymentsMoved tasks resuming from saved positionsWhether the destination tolerates repeats

A Simple Investigation Order

1

Confirm What Protocol Is Really Active

If the group is not using cooperative rebalancing, nothing else matters until that is fixed.

2

Find the Trigger

Match the rebalance times with worker joins, leaves, connector edits, and task count changes.

3

Look at Durations

Long rebalances point at slow stops, overloaded workers, or timeouts that are too tight.

4

Check Both Layers

Decide whether the pain comes from the worker group, the sink consumer groups, or both.

5

Apply the Smallest Fix and Verify

Change one setting or fix one connector, then watch the metrics to confirm that the cluster has calmed down.

i
Design Tip

Change only one thing at a time while troubleshooting. When several settings are changed together, you cannot tell which one helped, and you risk introducing a new problem while curing the old one.

28Frequently Asked Questions

Short, honest answers to the questions people ask most often.

Q1What does “incremental cooperative” actually mean?

Incremental means only the work that needs to move is moved. Cooperative means workers keep running during a rebalance and release specific pieces of work when asked, so a piece is released by its old owner before it is granted to its new one.

Q2Does cooperative rebalancing remove rebalances?

No. The same events still cause rebalances. What changes is the cost: most work keeps running, and only the pieces that must move are interrupted.

Q3How do I know which protocol my cluster is using?

Check the worker rebalance metrics, which report the protocol the group agreed on. Do not rely only on the settings of individual workers, because the group uses the least capable common option.

Q4What is the difference between compatible and sessioned?

Compatible lets workers speak both eager and cooperative languages, mainly to support upgrades. Sessioned is cooperative rebalancing plus signed internal requests between workers using rotating keys.

Q5Why doesn’t the leader move tasks immediately when a worker crashes?

Because the worker might come back soon, for example after a quick restart. The leader waits for the scheduled delay so that a returning worker can reclaim its own tasks without disturbing anyone else.

Q6Does a failed task cause a rebalance?

No. A failed task simply stays in a failed status until someone restarts it. Rebalancing concerns who owns work, not whether the work is healthy.

Q7Are duplicates still possible with cooperative rebalancing?

Yes, around each move, because tasks resume from saved positions that may be slightly behind. There are simply far fewer moves, so far fewer duplicates. Destinations should still tolerate repeats.

Q8Is worker rebalancing the same as consumer group rebalancing?

No. Worker rebalancing divides connectors and tasks among workers. Each sink connector also has a consumer group that divides topic partitions among its tasks, with its own settings. The two layers can trigger each other.

Q9Can I balance the cluster by CPU or memory use?

Not directly. The leader balances by counts of connectors and tasks. To handle uneven load, split heavy connectors into more tasks, separate heavy workloads into their own cluster, and leave headroom on every worker.

Q10Is it safe to upgrade a running cluster to cooperative rebalancing?

Yes, with care. Upgrade the software everywhere, move workers to the compatible setting one at a time, and the group switches to cooperative behavior when the last worker changes. Avoid mixing incompatible settings.

Q11What happens if a task will not stop when asked?

After the shutdown timeout, the worker moves on and the task may keep running as a zombie beside its replacement. Prevent this with responsive stop logic and timeouts on all outside calls.

Q12Does standalone mode rebalance?

No. Standalone mode runs a single process with no group of workers, so there is nothing to divide. Rebalancing belongs to distributed mode.

Q13Should I set the scheduled delay to zero?

Only if you prefer immediate takeover over gentle restarts, for example on very unreliable machines where workers rarely come back. Otherwise a moderate delay avoids needless movement.

Q14Do these behaviors depend on my Kafka version?

Yes. Cooperative rebalancing arrived in Kafka 2.3, and newer releases have refined defaults and added features. Check the documentation for your exact version before relying on specific setting names or default values.

29Summary and Key Takeaways

A Kafka Connect cluster shares connectors and tasks among workers, and every change in membership or workload requires the group to divide that work again. The original eager protocol solved this by stopping everything and starting from scratch, which was simple but made the cost of every change equal to the size of the whole cluster. Incremental cooperative rebalancing keeps most work running, moves only what must move, and always releases a piece from its old owner before granting it to a new one. A scheduled delay prevents needless shuffling when a worker returns quickly, and protocol settings let clusters upgrade safely through a compatible stage. Good operation still depends on clean shutdowns, responsive tasks, sensible timeouts that agree with one another, repeat-safe destinations, attention to the separate consumer layer inside sink connectors, and metrics that show how often and how long the cluster rebalances.

Key Takeaways

  • Eager stops everything, cooperative stops only what moves — the same events cause rebalances, but the disruption now matches the size of the change.
  • Release before assign — a moving task is revoked from its old worker in one round and granted to its new worker in the next, so it never has two owners.
  • The scheduled delay is a grace period — it lets restarting workers reclaim their own tasks; size it above restart time and below the outage you can tolerate.
  • The group speaks the least capable language — one worker on an old setting drags everyone back to eager, so upgrade through the compatible setting and verify the active protocol.
  • There are two rebalancing layers — workers share tasks, and sink tasks share partitions; tune and monitor both.
  • Balance is by count, not load — split heavy tasks, separate heavy workloads, and keep headroom on every worker.
  • Clean stops and safe destinations — graceful shutdowns, timeouts on outside calls, and repeat-tolerant destinations turn rebalances into non-events.