Monedula

Scenario 09.2.2 · Failover + RPO

Kafka DR failover with MirrorMaker 2: measuring RPO

Disaster recovery · Advanced · about 4 min · Apache Kafka 4.3

Cut the mirror link, watch lag grow, fail over to the DR region - and measure the records lost (RPO).

Run this scenario in the playground

Failover to dr - RPO 2 records lost; consumer resumes on dr at clamped offset 3. t+3.100s

The failover at t=3000 promotes dr (promotedRegion = dr) and moves p1 there. g1 is re-pointed to primary.orders and resumes at 3, dr's high watermark: the simulator clamps its committed 5, where real MM2 would resume it from the last translated checkpoint, never past the mirrored 3. O4 and O5 exist only on the unreachable primary: RPO is 2 records.

Open at this step: step 4, Failover to dr - RPO 2 records lost; consumer resumes on dr at clamped offset 3

What you start with

Builds on the active-passive mirror: after lag has grown on the inter-region link, we fail the application over to the DR cluster and count the records that never made it across. Those un-mirrored records are the recovery point objective (RPO) - the data lost to the outage.

Step by step

  1. Two regions ready - primary serves orders, dr mirrors; consumer on primary t+0.000s Same active-passive setup as 09.2.1: primary serves orders and mm-1 mirrors it into dr's primary.orders. This time consumer group g1 (member c1) reads orders on primary, so a failover has to move a consumer as well as a producer. Open at this step: step 1, Two regions ready - primary serves orders, dr mirrors; consumer on primary
  2. Mirror caught up (dr HW 3, lag 0); consumer following on primary t+1.700s p1 has written O1, O2 and O3 to primary (HW 3) and g1 has consumed and committed all three (committed = 3). MM2 copied them into dr's primary.orders at offsets 0, 1 and 2 (dr HW 3), so right now a failover would lose nothing. Open at this step: step 2, Mirror caught up (dr HW 3, lag 0); consumer following on primary
  3. Link cut - lag grows (src HW 5, dr 3, lag 2); consumer committed 5 on primary t+2.900s The regions were split at t=2000. p1 kept writing O4 and O5 to primary (HW 5) and g1 committed 5 there, but dr's primary.orders is still at 3. That lag of 2 records is the RPO you would pay on a failover now. Open at this step: step 3, Link cut - lag grows (src HW 5, dr 3, lag 2); consumer committed 5 on primary
  4. Failover to dr - RPO 2 records lost; consumer resumes on dr at clamped offset 3 t+3.100s The failover at t=3000 promotes dr (promotedRegion = dr) and moves p1 there. g1 is re-pointed to primary.orders and resumes at 3, dr's high watermark: the simulator clamps its committed 5, where real MM2 would resume it from the last translated checkpoint, never past the mirrored 3. O4 and O5 exist only on the unreachable primary: RPO is 2 records. Open at this step: step 4, Failover to dr - RPO 2 records lost; consumer resumes on dr at clamped offset 3
  5. Promoted: producer now writes dr, consumer reads the new record t+3.400s p1 produces O6 to dr's primary.orders, where it lands at offset 3 (HW 4), the offset O4 had on primary, and c1 reads it (g1 commits 4). Writing the mirror topic is a simulator shortcut: MM2 expects producers to write only local topics, so a real p1 would write a dr-local orders. Either way O4 and O5 are missing from dr's history. Open at this step: step 5, Promoted: producer now writes dr, consumer reads the new record

The takeaway

RPO is the measurable cost of async DR: any records produced after mirroring fell behind are lost on failover. Smaller mirror lag means a smaller RPO, but with async replication it is never zero.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=09.2.2" title="Kafka Simulator: Failover + RPO" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/dr-failover/">Kafka DR failover with MirrorMaker 2: measuring RPO</a></p>

Further reading

Apache Kafka documentation

More in Disaster recovery

All scenarios