In Kafka Connect, how to connect with multiple kafka clusters?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka Connect is a component of Apache Kafka that allows for simple and scalable data import and export to and from Kafka. It is commonly used to integrate Kafka with various databases, message queues, or file formats. However, connecting Kafka Connect with multiple Kafka clusters is not as straightforward and often requires a specific configuration setup.
Understanding Kafka Connect
Kafka Connect is an integration framework that is part of the broader Kafka ecosystem. It is designed to facilitate streaming data between Kafka and other data systems in a reliable manner. Its primary function is to abstract away the details of reading from and writing to different systems using a common framework.
Modes of Operation
Kafka Connect can operate in two modes:
- Standalone Mode: Suitable for small, non-critical tasks where the configuration is stored in a local file. This is easy to set up but does not benefit from the fault tolerance and scalability of a distributed system.
- Distributed Mode: Used for scalable, fault-tolerant deployments. Configuration is stored in Kafka itself, and the work is distributed across multiple workers.
Connecting with Multiple Kafka Clusters
To integrate Kafka Connect with multiple Kafka clusters, configurations must be specified to ensure each connector or task connects to the appropriate cluster. This might involve dealing with multiple source and sink clusters.
Configuration Details
Given the lack of native support in Kafka Connect for communicating with multiple clusters directly in a single Connect cluster, a typical approach includes setting up separate Connect clusters for each Kafka cluster or carefully managing producer and consumer configurations.
Example: Separate Kafka Connect Clusters
A common setup might involve deploying two separate Kafka Connect clusters; each is configured to connect to a different Kafka cluster. For instance:
Cluster A – Connect Cluster Configuration:
Cluster B – Connect Cluster Configuration:
Handling Multiple Clusters within a Single Connect Cluster:
To directly handle multiple Kafka clusters within the same Connect cluster (though less common and more complex), one would have to carefully manage the configuration files for each connector to point to different clusters.
Example Configuration for a Sink Connector Connecting to a New Cluster:
Summary Table
| Configuration Aspect | Description | Example Value |
bootstrap.servers | Kafka cluster to connect to. | kafka-cluster-a:9092 |
group.id | Unique string that identifies the Connect cluster group. | connect-cluster-a |
key.converter | Converter class for key serialization. | org.apache.kafka.connect.json.JsonConverter |
value.converter | Converter class for value serialization. | org.apache.kafka.connect.json.JsonConverter |
config.storage.topic | Kafka topic to store connector and task configurations. | connect-cluster-a-configs |
offset.storage.topic | Kafka topic to store offsets. | connect-cluster-a-offsets |
status.storage.topic | Kafka topic to store connector and task status updates. | connect-cluster-a-status |
producer.override.bootstrap.servers | Overrides the producer bootstrap.servers configuration for specific connectors. | kafka-cluster-c:9092 |
Conclusion
Integrating Kafka Connect with multiple Kafka clusters involves careful consideration of configurations, especially when dealing with multiple destination clusters in a single connect instance. The key is to ensure that each connector's configuration correctly points to its respective cluster, achieving data integrity and isolation across different systems and their respective clusters.
Related reading
- In Kafka HA, why minimum number of brokers required are 3 and not 2
- In Kafka how to get the exact offset according producing time
- in Kafka, how to make consumers consume from local partition?
- In Kafka is each message replicated across all partitions of a topic?
- In MVVM model should the model implement INotifyPropertyChanged interface?
- In MVVM should the ViewModel or Model implement INotifyPropertyChanged?
- In kafka, When producing message with transactional, Consumer offset doubled up
- In Pika or RabbitMQ, How do I check if any consumers are currently consuming?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.