Kafka Connect architecture - Time & Space Complexity
We want to understand how the work Kafka Connect does grows as we add more data or connectors.
How does the system handle more tasks and data without slowing down too much?
Analyze the time complexity of this simplified Kafka Connect task assignment loop.
// Pseudocode for Kafka Connect task assignment
for each connector in connectors:
for each task in connector.tasks:
assign task to worker
process task data
This code assigns and processes tasks for each connector in the system.
Look at what repeats as input grows.
- Primary operation: Looping over connectors and their tasks.
- How many times: Number of connectors times number of tasks per connector.
As we add more connectors or tasks, the work grows.
| Input Size (connectors x tasks) | Approx. Operations |
|---|---|
| 10 connectors x 5 tasks | 50 |
| 100 connectors x 5 tasks | 500 |
| 100 connectors x 20 tasks | 2000 |
Pattern observation: The total work grows roughly by multiplying connectors and tasks.
Time Complexity: O(c * t)
This means the work grows proportionally to the number of connectors times the number of tasks per connector.
[X] Wrong: "Adding more connectors does not affect processing time much because tasks run independently."
[OK] Correct: Even if tasks run independently, the system still loops over all connectors and tasks to assign and manage them, so more connectors increase total work.
Understanding how Kafka Connect scales with connectors and tasks helps you explain system behavior clearly and shows you can think about performance in real systems.
"What if Kafka Connect used parallel processing for tasks? How would that change the time complexity?"
Practice
Solution
Step 1: Understand Kafka Connect components
Kafka Connect architecture includes workers, connectors, and tasks. Workers run connectors and tasks.Step 2: Identify worker's role
Workers execute connectors and tasks to move data between Kafka and external systems.Final Answer:
To run connectors and tasks that move data between Kafka and external systems -> Option AQuick Check:
Worker = runs connectors/tasks [OK]
- Confusing workers with Kafka brokers
- Thinking workers store data permanently
- Mixing up producers and workers
Solution
Step 1: Recall Kafka Connect startup commands
Standalone mode uses connect-standalone.sh with worker and connector config files.Step 2: Match correct command syntax
connect-standalone.sh worker.properties connector.properties matches the correct command format: connect-standalone.sh worker.properties connector.propertiesFinal Answer:
connect-standalone.sh worker.properties connector.properties -> Option BQuick Check:
Standalone mode uses connect-standalone.sh [OK]
- Using connect-distributed.sh for standalone mode
- Confusing Kafka broker start scripts with Connect scripts
- Wrong file names or missing config files
{
"name": "my-source-connector",
"config": {
"connector.class": "FileStreamSource",
"tasks.max": "2",
"file": "/tmp/input.txt",
"topic": "test-topic"
}
}What does the
tasks.max setting control?Solution
Step 1: Understand the tasks.max parameter
In Kafka Connect, tasks.max sets how many tasks a connector can run in parallel.Step 2: Apply to given config
Here, tasks.max is 2, so the connector can run up to 2 tasks to increase throughput.Final Answer:
The maximum number of tasks to run for this connector -> Option AQuick Check:
tasks.max = max tasks per connector [OK]
- Confusing tasks.max with broker count
- Thinking it limits message size
- Assuming it controls topic count
Solution
Step 1: Analyze why tasks don't start
If connectors don't start tasks, a common cause is an invalid connector class name.Step 2: Check other options
Missing tasks.max defaults to 1 task, so not likely cause. Brokers offline cause other errors. Empty worker.properties would prevent worker start. Misspelled connector class prevents task creation.Final Answer:
The connector class name is misspelled in the configuration -> Option DQuick Check:
Misspelled connector class blocks tasks [OK]
- Assuming missing tasks.max stops tasks
- Ignoring connector class name correctness
- Not verifying worker config completeness
Solution
Step 1: Understand Kafka Connect modes
Standalone mode runs a single worker, no fault tolerance or scaling. Distributed mode runs multiple workers, supports scaling and fault tolerance.Step 2: Match requirements to mode
For fault tolerance and horizontal scaling, distributed mode is required.Final Answer:
Distributed mode, because it supports multiple workers and fault tolerance -> Option CQuick Check:
Fault tolerance needs distributed mode [OK]
- Choosing standalone for fault tolerance
- Thinking standalone balances tasks
- Believing distributed mode needs no config
Ready to prove it?
Pass the test and this pattern moves unknown
