top of page

Kafka Replication

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • May 2
  • 2 min read

šŸŒ Kafka in Multi-Region (Active-Active or Active-Passive) Setup

šŸ” Data Replication Flow: Region A ↔ Region B

1. Active-Passive Setup (One-Way Replication)

ā–¶ Use Case:

Region A is active, Region B is backup (DR).

ā–¶ Flow:

  1. Producers write to Region AĀ Kafka cluster.

  2. MirrorMaker 2Ā replicates data to Region B.

  3. Consumers in Region B are inactive until failover.

Benefits:

  • Simpler, more consistent

  • Region B can take over if Region A fails (Disaster Recovery)

2. Active-Active Setup (Bi-Directional Replication)

ā–¶ Use Case:

Both Region A and Region B actively handle traffic (e.g., global users).

ā–¶ Flow:

  1. Producers in Region A write to Kafka A; producers in Region B write to Kafka B.

  2. MirrorMaker 2 (or Confluent Replicator) replicates:

    • Region A → Region B

    • Region B → Region A

  3. You must prefix topicsĀ to avoid cyclic replication:

    • regionA.orders, regionB.orders

Important Caveats:

  • Avoid conflict: Same topic names can cause infinite loops.

  • Use deduplicators, topic renaming, or routing rules.

  • Maintain global IDsĀ (e.g., UUIDs) to track message uniqueness.

āš™ļø Example Kafka Replication Topology

pgsql

+------------------------+

| Kafka Cluster A |

| (Azure - East US) |

+------------------------+

| |

MirrorMaker2 MirrorMaker2

(East → West) (West → East)

| |

+------------------------+

| Kafka Cluster B |

| (Azure - West Europe) |

+------------------------+

šŸ” Networking and Security Between Regions

  • VNET PeeringĀ or ExpressRouteĀ for fast & secure transfer

  • TLS Encryption, SASL Auth, ACLs

  • Can use Azure Private LinkĀ or VPN Gateway

āœ… Tips for Successful Replication

Challenge

Solution

Message duplication

Use message deduplicationĀ logic via UUIDs

Topic conflicts

Use prefixes or renamingĀ strategy

Replication lag

Monitor with Prometheus/Grafana

Network latency

Use regional edge zonesĀ or ExpressRoute

Failover complexity

Implement external DNS + Traffic Manager


Ā 
Ā 
Ā 

Recent Posts

See All
why springbatch job??

Spring Batch Job Spring Batch is designed exactly for batch workloads Ā like Pro*C migrations. āœ… Advantages: Chunk-oriented processing...

Ā 
Ā 
Ā 
Pro*c Job to Spring Batch Job

Example1: šŸ“Œ Background Pro*C job  → Written in C with embedded SQL, often used for batch ETL-like jobs in Oracle. Spring Batch job  →...

Ā 
Ā 
Ā 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page