Why connectors integrate external systems in Kafka - Performance Analysis
When connectors link Kafka to outside systems, we want to know how the work grows as data grows.
How does the time to move data change when more data or systems are involved?
Analyze the time complexity of the following code snippet.
connector.poll() {
records = externalSystem.fetchRecords()
for (record in records) {
kafkaTopic.send(record)
}
}
This code fetches records from an external system and sends each one to a Kafka topic.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping over each record fetched from the external system.
- How many times: Once for every record received in each poll call.
As the number of records fetched grows, the time to process them grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 sends to Kafka |
| 100 | 100 sends to Kafka |
| 1000 | 1000 sends to Kafka |
Pattern observation: The work grows directly with the number of records fetched.
Time Complexity: O(n)
This means the time to process grows in a straight line with the number of records.
[X] Wrong: "The connector time stays the same no matter how many records come in."
[OK] Correct: Each record needs to be handled, so more records mean more work and more time.
Understanding how connectors scale with data helps you explain real-world system behavior clearly and confidently.
What if the connector batches records before sending? How would the time complexity change?
Practice
Solution
Step 1: Understand the role of connectors
Connectors are designed to link Kafka with external systems to automate data movement.Step 2: Identify the main purpose
The main purpose is to move data automatically, not to create topics or monitor health.Final Answer:
To automatically move data between Kafka and other systems -> Option AQuick Check:
Connectors move data automatically = A [OK]
- Thinking connectors create Kafka topics
- Confusing connectors with monitoring tools
- Assuming connectors require manual data transfer
Solution
Step 1: Identify the correct command for standalone mode
The commandconnect-standalone.shis used with two config files: worker and connector.Step 2: Check the options
connect-standalone.sh config/connect-standalone.properties config/my-connector.properties correctly shows the worker config and connector config files together.Final Answer:
connect-standalone.sh config/connect-standalone.properties config/my-connector.properties -> Option AQuick Check:
Standalone mode uses two config files = A [OK]
- Using topic commands instead of connector commands
- Passing only one config file
- Confusing distributed and standalone commands
{
"name": "my-source-connector",
"config": {
"connector.class": "FileStreamSource",
"tasks.max": "1",
"file": "/tmp/input.txt",
"topic": "test-topic"
}
}What will this connector do when started?
Solution
Step 1: Identify connector type and direction
The connector class isFileStreamSource, which reads from a file and sends data to Kafka.Step 2: Understand configuration parameters
Thefileparameter points to the input file, andtopicspecifies the Kafka topic to send data to.Final Answer:
Read data from /tmp/input.txt and send it to Kafka topic 'test-topic' -> Option BQuick Check:
FileStreamSource reads file to Kafka = C [OK]
- Confusing source with sink connectors
- Thinking it writes to the file instead of reading
- Assuming it creates topics automatically
{
"name": "my-sink-connector",
"config": {
"connector.class": "FileStreamSink",
"tasks.max": "1",
"file": "/tmp/output.txt",
"topic": "input-topic"
}
}But no data appears in /tmp/output.txt after running. What is the likely problem?
Solution
Step 1: Check connector class correctness
The classFileStreamSinkis correct for writing Kafka data to a file.Step 2: Verify topic existence and data flow
If the topicinput-topicdoes not exist or has no data, no output will be written.Final Answer:
The topic name 'input-topic' does not exist or has no data -> Option CQuick Check:
Sink needs data in topic to write = B [OK]
- Assuming connector class is wrong when it is correct
- Ignoring topic data availability
- Thinking tasks.max affects data flow directly
Solution
Step 1: Understand connector purpose for databases
Connectors automate moving data between Kafka and external systems like databases.Step 2: Eliminate incorrect options
Connectors do not replace databases, do not require manual polling, and support databases, not just files.Final Answer:
Connectors automate data transfer between the database and Kafka without custom code -> Option DQuick Check:
Connectors automate integration without manual code = D [OK]
- Thinking connectors replace databases
- Assuming manual polling is needed
- Believing connectors only work with files
Ready to prove it?
Pass the test and this pattern moves unknown
