Video in progress

How do you build a disaster recovery plan for a Kafka cluster, and which failure scenarios do you consider?

I split the scenarios into levels: a single disk/broker, a whole zone, a whole region, and human error (a topic deleted, a wrong offset reset). Each needs an RPO/RTO target, a path to recovery (automatic or manual), and regular drills.

📖 Answer

A broker or disk. RF=3, min ISR=2, with broker.rack so replicas are in different zones. Automatic: the leader moves to another replica. Recovery: the broker is replaced and the replicas catch up. What to check here is the replication throttle (leader.replication.throttled.rate); otherwise the recovery traffic chokes prod.

A whole zone. If the stretched cluster spans 3 zones, two zones remain and writes continue. The KRaft controllers must also be spread across 3 zones: if 2 of 3 controllers are in one zone, the quorum goes down with that zone.

A whole region. Asynchronous replication to a second region (MM2, Cluster Linking). RPO is the replication lag (seconds). RTO is the time to switch clients to the new cluster: DNS, configuration, translating consumer offsets. This should be a manual decision; automatic region failover creates a split-brain risk.

Human error is the most common, and replication doesn't protect against it: if a topic is deleted, it may be deleted in the copy too. Protection:

  • restrict delete.topic.enable, and manage topics only through GitOps;
  • keep prod admin rights to a minimum;
  • back up important topics to object storage (a sink connector or tiered storage);
  • export consumer group offsets periodically, so you can go back after a wrong reset.

Related systems: the schema registry (it has its own _schemas topic, which must be replicated too, otherwise in the second region you can't read messages), Kafka Connect configurations, ACLs and certificates.

The value of a plan is only verified by drills. I run a game day once a quarter: shut down a zone in staging, kill a broker, and measure the RTO for real. The first drill usually finds that "the command in the runbook doesn't work", which is exactly why you drill.