DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • How To Install CMAK, Apache Kafka, Java 18, and Java 19 [Video Tutorials]
  • Event Mesh: Point-to-Point EDA
  • Kafka Fail-Over Using Quarkus Reactive Messaging
  • Next-Gen Data Pipes With Spark, Kafka and k8s

Trending

  • Pitching Kotlin: An Engineering Leader's Guide to Legacy Modernization
  • Reading GC Logs: Memory Leak or Undersized Heap?
  • Getting Started With Milvus: Vector Search for Enterprise Java Applications
  • Simplifying the Hugging Face AI Agent Incident

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Designing a Multi-Region Kafka Cluster for Tier-0 Workloads

Designing a Multi-Region Kafka Cluster for Tier-0 Workloads

This article discusses the design choices to consider when setting up a multi-region Kafka cluster for mission-critical Tier-0 workloads.

By 
Harini Rajendran
·
Nov. 23, 26 · Analysis
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
30 Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Most of the Kafka deployments in the industry plan to survive the loss of a single Kafka broker or an availability zone. But that’s not enough for a critical Tier-0 infrastructure where downtime or data loss of even a few seconds could have a massive business impact. 

In such scenarios, the failure model should consider not just the loss of a broker or a zone, but the loss of an entire region. The business is expected to operate without interruption even when a whole region goes down, and it should be possible to also roll the cluster safely while operating in that state, to apply any break-glass changes. This article focuses on that kind of high-stakes deployment.

Goal

Design a Kafka architecture that continues to serve traffic even if one complete region goes down, with the ability to roll the cluster, one broker at a time, without availability hits.

Design Decisions for Tier-0 Workloads

Just running brokers in multiple regions is not the solution here. In fact, that’s the easy part. The hard question is, what guarantee remains when one of those regions disappears, and does it solve the business needs? To design for that, you need to consider several decisions together. Let’s dive into those in detail below.

1. Replica Placements Across Failure Domains

This is the foundational step. For a tier-0 multi-region Kafka cluster, we need three regions with isolated failure domains and at least two brokers in each region. This ensures that one region doesn’t impact the availability of the cluster. Brokers in each region should be configured with rack awareness to indicate their failure domains as follows.

Properties files
 
# Region A
broker.rack=region-a

# Region B
broker.rack=region-b

# Region C
broker.rack=region-c


For tier-0 workloads, each topic's partitions should be configured to have a replication factor (RF) of 6. Kafka’s rack-aware replica assignment will spread the replicas across the three regions. If the automatic replica assignment doesn’t allocate two replicas per region, we have to explicitly reassign replicas immediately after topic creation to meet our availability guarantees.

This way, if one region goes down entirely, we still have four replicas surviving, and the cluster would still continue to operate.

Partition replica placement

2. Define When Kafka Should Stop Accepting Writes

The next step is to define what is considered a successful write in this Kafka setup. For this, we need two configs:

Properties files
 
# Topic level config
min.insync.replicas=3


min.insync.replicas determines the minimum number of replicas that should be present in the in-sync replica set (ISR) of a partition for Kafka to accept any writes to it. This should be set at the time of topic creation to ensure high availability.

Properties files
 
# Producer side config
acks=all


acks=all is a producer side config that ensures that the producer will get an ack back only if the write is successful in all the in-sync replicas.

These two settings work together to satisfy the durability guarantees we want. When all three regions are healthy, ISR would include all six replicas. Let’s say one region goes down; then the ISR would drop down to four. During that time, if you roll the cluster one node at a time, the ISR will go down to three. But since minISR is three, writes will still continue to work. Kafka will stop accepting writes only when one whole region and two brokers in a different region go down at the same time.

Cluster state

ISR Min isr=3 writes

All 3 regions healthy

    6

   Satisfied

    Continue

Region-A down

    4

   Satisfied

    Continue

Region-A + one broker down

    3

   Satisfied

    Continue

Region-A + two brokers down

    2

  Not satisfied

    Rejected


The goal isn’t availability at any cost; rather, the system should be available as long as the durability guarantees that we designed for can be maintained.

3. Architecting the KRaft Quorum for Tier-0

So far, we focused on the data plane. Now switching gears, the KRaft controllers have a completely different availability model. They form the metadata quorum, and a majority is needed to continue operation.

In our setup, we can distribute five controllers as 2 + 2 + 1 across the three regions, requiring a majority of three to maintain quorum. If either of the regions containing two controllers goes down, three controllers remain. If the region containing one controller goes down, four remain. So, the controller quorum survives the loss of any one region.

But, unlike brokers, we cannot roll the controllers at that point because taking one controller down would cause the quorum to drop below three. To solve this, we need more controllers, and a 3 + 3 + 3 distribution would provide this. Losing one region would leave six controllers with room to still roll the controllers, as we only need five to maintain quorum.

KRaft quorum after a region failure

On the flip side, an increase in quorum size also increases the coordination overhead. The official Kafka documentation typically recommends three or five controllers, which tolerate one or two concurrent failures, respectively. Our 3 + 3 + 3 setup is driven by the stricter failure requirement we defined above.

You need to consider if you want the same availability guarantee for the controllers as that of the data plane and decide on the controller quorum setup.

4. Hidden Cost of WAN

The availability guarantees we discussed come with their own cost.

The first cost is client latency. With cross-region replication and acks=all, the network latency between these regions directly affects the producer latency. Consumers can also pay the WAN latency cost when they are consuming from partition leaders located in a different region.

The second cost is replication overhead. With RF=6, there is additional storage, network traffic, and replication-related coordination cost in the brokers compared to a smaller number of replicas.

The third cost is the landmine. The WAN itself becomes a failure mode. In this setup, a partly working WAN between two regions can be more dangerous than a link that’s completely down. Increased latency, packet loss, or intermittent connectivity issues between regions can cause replication to lag, ultimately resulting in replicas falling out of ISR. The three regions might be independently healthy, but if the connectivity between them is not, then the availability of the cluster might be impacted.

Going back to the CAP theorem, to tolerate a network partition, we must choose between consistency and availability. So, if a partition's ISR falls below the configured min.insync.replicas of three due to network partition, Kafka stops accepting writes rather than weakening those guarantees. Similarly, if the KRaft controller quorum is lost, then no metadata changes (like leader elections, etc.) can happen in the cluster, even though existing data-plane traffic may continue for some time.

So, in an architecture like this, monitoring the health of the network paths between these regions is as critical as monitoring the Kafka brokers and controllers. Metrics like round-trip latency (RTT) between regions, packet loss, TCP retransmissions, connection errors/timeouts, and network throughput/bandwidth utilization are a good start.

5. Capacity Plan for the Failure State

When one region goes down, all the partition leaders in that region would move to the two other surviving regions. This implies that those two regions would have to handle more producer and consumer traffic, network throughput, and disk I/O.

Even if the cluster is designed to satisfy its ISR and controller quorum requirements, if it's not sized to handle these failures when one region goes down, the surviving regions would be overloaded, resulting in higher latencies, timeouts, and operational instability. So, for Tier-0 infrastructure, capacity planning should always be done for failure states and not stop at normal operations.

Region recovery should be planned as well. When a failed region comes back up, those brokers might have to catch up on a significant amount of data before they start accepting traffic, resulting in a sudden burst of cross-region network traffic and disk I/O across all regions. Therefore, recovery needs to be controlled in order to not overwhelm the healthy part of the cluster. This can be achieved by throttling the replica catch-up with the trade-off of longer recovery time to minimize impact on live production traffic. Replication throttling needs a deeper discussion of its own, so we won’t go into details here.

Tier-0 Multi-Region Kafka Checklist

To summarize, before putting a Tier-0 multi-region Kafka cluster into production, validate these five things:

  • Replica placement: Are brokers spread across three regions with at least two brokers per region configured with the right broker.rack settings?
  • Write durability: Are all Tier-0 topics configured with replication.factor=6, min.insync.replicas=3 and producers use acks=all?
  • KRaft quorum: Can the controllers lose any region and still maintain quorum, with enough headroom to lose or restart another controller if required?
  • Cross-region cost: Is the cross-region latency with acks=all acceptable, and are WAN latency, packet loss, replication lag, and ISR changes actively monitored?
  • Failure-state capacity: Can the two surviving regions handle the production workload, with enough network and disk headroom for the replicas to safely catch up when the failed region recovers?

Conclusion

There is no shortage of ways to deploy Kafka across multiple regions. The challenge is picking the right architecture that meets all our durability guarantees.

For Tier-0 workloads, this means designing the architecture around failures first. What happens when a region goes down? Can we still roll the cluster? What continues to work, and at what point do we deliberately stop accepting writes? Lastly, can we safely bring back the region that was down without impacting the business?

That is ultimately the difference between simply running Kafka in multiple regions versus actually supporting a mission-critical Tier-0 workload.

cluster kafka

Opinions expressed by DZone contributors are their own.

Related

  • How To Install CMAK, Apache Kafka, Java 18, and Java 19 [Video Tutorials]
  • Event Mesh: Point-to-Point EDA
  • Kafka Fail-Over Using Quarkus Reactive Messaging
  • Next-Gen Data Pipes With Spark, Kafka and k8s

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook