skip to content

How does tasks.max interact with worker count when balancing load, and what are the failure modes of misconfiguring it?

level: middleimportance: should knowfreq 50%

answer

  1. tasks.max = parallelism cap per connector
  2. effective = min(tasks.max, splittable work)
  3. sink bounded by partition count
  4. too low = idle workers, throughput ceiling
  5. too high = overhead, connection exhaustion
  6. size ~ worker count and granularity

basics

~20 s

tasks.max caps how many tasks a connector creates, which caps how many workers can share its load. Too low wastes workers (idle) and limits throughput; too high creates more tasks than the source can usefully split, adding overhead with no gain.

solid answer

~50 s

`tasks.max` is a per-connector setting bounding how many tasks the connector may create — and tasks are the unit the leader balances across workers. Effective parallelism for a connector is min(`tasks.max`, what the connector can actually split). A source reading 12 Kafka-bound partitions can make 12 tasks; a source reading one non-partitioned table may only ever make 1, ignoring a high tasks.max. **Too low**: if tasks.max < worker count, extra workers sit idle for that connector and you under-use capacity; throughput is capped. **Too high**: you create more tasks than there's distinct work for (some idle) or oversubscribe each worker, adding rebalance and connection overhead with no throughput gain — and you can exhaust connection/thread limits on the source/sink system. The balanced target is tasks.max sized to your work granularity and roughly aligned with worker count, so each rebalance can spread tasks evenly.

go deeper

for a junior

Know tasks.max limits how many tasks a connector makes, and tasks are spread over workers.

for a middle

Explain effective = min(tasks.max, splittable work), and the idle-worker vs. overhead failure modes.

for a senior

Reason about sink partition bounds, downstream connection limits, and aligning tasks.max with worker count for even balancing.

for a principal

Design capacity across many connectors, balancing per-connector granularity, worker fleet size, downstream limits, and rebalance cost.

## What tasks.max is `tasks.max` is a **per-connector** configuration: the maximum number of **tasks** the framework will let that connector create. Recall that a **task** is the actual unit of data-copying work and the unit the Connect leader **balances across workers** during assignment. So `tasks.max` is effectively your lever on a connector's parallelism. ## Effective parallelism = min(tasks.max, splittable work) Setting `tasks.max=10` does **not** guarantee 10 tasks. The connector decides how to split its job, and it can't manufacture parallelism that doesn't exist: - A **source** connector copying a single, non-partitioned database table may only ever produce **1 task**, no matter how high tasks.max is. - A **source** connector watching 12 tables (or a 12-partition log) can produce up to 12 tasks. - A **sink** connector consuming a topic is bounded by the topic's **partition count**: you can't usefully have more sink tasks than partitions, because a partition is consumed by at most one task. So: **effective tasks = min(tasks.max, what the connector can split)**. ## How it interacts with worker count The leader spreads a connector's tasks across the workers. Therefore: - The number of workers that can help a connector ≤ its effective task count. - For even balancing, you want effective tasks ≥ worker count (ideally a multiple), so each worker gets a fair share. ## Failure mode 1: tasks.max too low If effective tasks < worker count: - **Idle workers**: workers with no task for this connector do nothing for it — wasted capacity you're paying for. - **Throughput ceiling**: the connector can't go faster than its few tasks allow; adding workers won't help. - Example: 8 workers, `tasks.max=2` on your highest-volume connector → only 2 workers do that work; you're leaving 6 workers' worth of capacity on the table. ## Failure mode 2: tasks.max too high If tasks.max far exceeds useful work: - **No extra throughput**: you can't parallelize beyond the splittable work; extra tasks are either not created or idle. - **Overhead**: more tasks = more connections/threads to the external system, more state for the leader to assign, larger/slower rebalances. - **Resource exhaustion**: each task often opens its own connection (DB session, HTTP client). A huge tasks.max can blow through the source/sink system's connection or thread limits, or oversubscribe a worker's CPU/memory. - **Oversubscription per worker**: piling many tasks onto few workers can starve each task of resources, hurting throughput rather than helping. ## The balanced target Size `tasks.max` to: 1. The connector's **splittable granularity** (partitions, tables, files) — there's no point exceeding it. 2. Roughly the **worker count** (or a small multiple), so each rebalance can distribute tasks evenly and adding a worker actually offloads work. 3. The **downstream system's** capacity (connection pools, write throughput) — more tasks hammer it harder. ## Rebalancing connection Because tasks are what get moved during a rebalance, a well-chosen `tasks.max` also makes incremental cooperative rebalancing effective: with enough tasks, the leader can shift a few onto a newly joined worker for smooth scale-out. With too few tasks, a new worker may get nothing until you raise tasks.max (which itself triggers a rebalance, since changing tasks.max reconfigures the connector). ## Gotcha: changing tasks.max triggers a rebalance Editing `tasks.max` is a connector reconfiguration, so it causes the connector's tasks to be recomputed and reassigned — under cooperative rebalancing this is incremental and cheap, but it's not free.

  • Why might setting tasks.max=20 on a sink connector for a 4-partition topic give you only 4 active tasks?
    A topic partition is consumed by at most one sink task, so a 4-partition topic supports at most 4 useful tasks. The other 16 have no partition to read and stay idle.
  • What's the risk of setting tasks.max extremely high on a JDBC source connector?
    Each task typically opens its own DB connection, so a very high tasks.max can exhaust the database's connection pool or thread limits, and adds rebalance/assignment overhead without increasing throughput beyond the splittable work.

saying these in an interview costs you the question

  • Claiming tasks.max guarantees that many tasks regardless of the source's splittability.
  • Saying more tasks always means more throughput.
  • Forgetting sink parallelism is bounded by topic partition count.
  • Ignoring downstream connection/thread limits when raising tasks.max.
  • Not realizing changing tasks.max triggers a rebalance.

context