Failing over between Kafka clusters is hard because Kafka clients are tightly coupled to the cluster they connect to:
- Every client hardcodes the cluster address: Producers and consumers are configured with the bootstrap servers of one cluster. To move them, you have to change the configuration of every application and restart it, often across many teams.
- Credentials and ACLs are tied to the cluster: The standby cluster needs the same users, credentials, and ACLs as the primary, and clients may need new credentials to reach it.
- Producers keep writing during the switch: While clients move one by one, some write to the old cluster and some to the new one. Records written to the old cluster after replication stops are lost.
- Offsets don’t move with the data: Consumer group offsets are stored per cluster, so consumers that switch clusters can skip or reprocess records. See Consumer offsets.
With Kong Event Gateway, clients connect to a virtual cluster instead of to the brokers. The virtual cluster forwards traffic to a backend cluster. Failover becomes a control plane change: you point the virtual cluster at a different backend cluster, and clients keep the same address and credentials.
In this guide, you’ll run a planned failover from a primary cluster to a standby cluster.
The following diagram shows how clients connect to the payments virtual cluster, which forwards traffic to primary-kafka before the failover and to secondary-kafka after it:
flowchart LR
C[Kafka clients] --> VC
subgraph GW [Event Gateway]
VC[payments virtual cluster<br/>ACL policies]
end
VC -->|before failover| P[(primary-kafka)]
VC -.->|after failover| S[(secondary-kafka)]
P -. replication .-> STo stand in for replication and simplify the demo, this guide creates the same topics on both clusters. In production, use a replication tool such as MirrorMaker 2 or Confluent Cluster Linking to copy records and consumer offsets to the standby cluster.