Scrivio Interview library
CodingFoundations6 min read · updated 13 November 2026

MirrorMaker 2 is the open-source tool for copying topics and consumer group positions from one Kafka cluster to another.

Write a minimal MirrorMaker 2 configuration for dedicated mode that replicates all topics starting with orders from a cluster called primary to a cluster called dr, including consumer group offsets. Name the connectors it runs and the internal topics it creates, and say what the replicated topic is called in dr by default.

A minimal mm2.properties declares clusters=primary,dr with their bootstrap servers, enables the primary->dr flow with topics=orders.* and groups=.*, turns on sync.group.offsets.enabled=true and sets replication.factor=3, and runs with connect-mirror-maker.sh mm2.properties. It runs three connectors: MirrorSourceConnector copies records and topic configs, MirrorCheckpointConnector emits translated consumer group offsets, and MirrorHeartbeatConnector emits heartbeats. With the default replication policy, orders appears in dr as primary.orders, alongside internal topics for offset syncs, checkpoints, heartbeats and the workers' own state, and because offsets differ between clusters, consumers must fail over with translated offsets.

Why this question is asked

Most teams meet MirrorMaker 2 when they need a disaster recovery copy of their topics in another cluster. It is part of Apache Kafka, so it is the first tool to reach for, and a minimal setup is only a handful of lines. What surprises people is what those lines create: renamed topics, several internal topics and offsets that do not match the source. Interviewers ask for the configuration to check whether we know these consequences before a failover depends on them. In this answer, we will recap what MirrorMaker 2 is, write the configuration, look at the three connectors, explain the topic naming, list the internal topics, and see why consumers need translated offsets.

1A Quick Recap: MirrorMaker 2 and Kafka Connect

MirrorMaker 2, MM2 for short, copies data between Kafka clusters. It is built on Kafka Connect, the framework Kafka uses to move data in and out with pluggable connectors. MM2 is a set of three connectors that read from one cluster and write to another.

We can run those connectors on an existing Connect cluster, or in dedicated mode, where MM2 starts its own Connect workers from a single properties file. Dedicated mode is the simplest way to start, and the question asks for it. Each cluster gets an alias, a short name such as primary or dr, used in the configuration and in topic names.

2The Configuration File

The file names the clusters, says how to reach them, and enables the flows we want, one direction at a time. A flow is written as source->target.

Properties
# mm2.properties
clusters = primary, dr
primary.bootstrap.servers = p-kafka-1:9092,p-kafka-2:9092
dr.bootstrap.servers = d-kafka-1:9092,d-kafka-2:9092
primary->dr.enabled = true
primary->dr.topics = orders.*
primary->dr.groups = .*
sync.group.offsets.enabled = true
replication.factor = 3 # for the replicated topics in dr
checkpoints.topic.replication.factor = 3
heartbeats.topic.replication.factor = 3
offset-syncs.topic.replication.factor = 3
# start it on one or more machines:
# bin/connect-mirror-maker.sh mm2.properties

Notice that topics and groups are regular expressions: orders.* matches orders, orders.v2 and so on, and .* replicates offsets for every group, minus some internal ones MM2 excludes by default. sync.group.offsets.enabled is off by default; with it on, MM2 writes translated offsets directly into the dr cluster's consumer groups, so a consumer started in dr finds an offset there. Security settings for each cluster, such as primary.security.protocol, go in the same file with the alias prefix. Running the command on two or three machines with the same file gives a fault-tolerant group of workers.

3The Three Connectors It Runs

Each enabled flow starts three connectors. MirrorSourceConnector does the main work: it consumes from the matching topics in primary and produces the records to dr, creates the target topics, and keeps their partition counts and configs in sync. MirrorCheckpointConnector reads consumer group offsets in primary, translates them to the matching offsets in dr, and emits them as checkpoints, and with sync.group.offsets.enabled also commits them to the groups in dr. MirrorHeartbeatConnector emits a heartbeat record at a fixed interval; seeing heartbeats arrive downstream proves the flow is alive, and they let MM2 and tools trace which clusters data has passed through.

Step throughOne flow, primary to dr
primaryMM2 workersdr
consume orders
produce primary.orders
write offset sync: source 5000 = target 4870
read group billing offsets
checkpoint: billing at 4870 in primary.orders
commit 4870 to group billing (sync enabled)
heartbeat

7 messages in order. Play them, or step through them one at a time.

Records, offset translation and heartbeats are three separate jobs.

4What the Topic Is Called in dr

With the default DefaultReplicationPolicy, a replicated topic gets the source alias as a prefix, so orders in primary becomes primary.orders in dr. The prefix is deliberate. MM2 uses it to detect cycles: it never replicates a topic back to the cluster named in its prefix, which is what makes two-way replication safe. And consumers can tell local data from replicated data at a glance.

If we want the same name in both clusters, IdentityReplicationPolicy keeps orders as orders. That is convenient for a one-way DR copy, because applications do not change topic names on failover, but MM2 then cannot recognise where a topic came from, so it must never be combined with flows in both directions for the same topics.

5The Internal Topics It Creates

MM2 keeps its state in Kafka topics, and knowing them helps when something goes wrong. Exact names follow the aliases and can differ slightly by version, so check what your cluster shows.

Topics MirrorMaker 2 creates
TopicClusterHolds
mm2-offset-syncs.dr.internalprimary (default)Pairs of source and target offsets
primary.checkpoints.internaldrTranslated group offsets
heartbeatsdrHeartbeats proving the flow works
mm2-configs / mm2-offsets / mm2-statusdrState of the dedicated Connect workers
primary.orders, primary.orders.v2, ...drThe replicated data

The offset-syncs topic lives in the source cluster by default because the source connector writes it while reading there; newer versions let us move it to the target with offset-syncs.topic.location. If we lose or skip it, offset translation stops working.

6Why Offsets Differ and What Consumers Need

MM2 does not copy log files. It consumes records and produces them again in dr, where they get new offsets. The numbers drift apart for several reasons: dr's topic may have been created after primary's retention had already deleted early records, transaction markers in the source take offsets but are not copied, and retries can shift positions. So offset 5,000 in primary.orders is not the record at offset 5,000 in orders.

That is why a consumer that fails over must never reuse its raw offset number from primary. It needs the translated offset, which MM2 provides in the checkpoints topic and, with sync enabled, as a committed offset of the group in dr. Even then, translation is approximate, so consumers should be idempotent and expect to see some records again.

7Follow-up questions

Can the same mm2.properties also replicate dr back to primary?

Yes, by adding dr->primary.enabled=true with its own topics. With the default replication policy, MM2 recognises primary.orders in dr as coming from primary and does not send it back, so no loop forms.

Where should the MM2 workers run?

Usually close to the target cluster, dr here. Consuming across a long link tolerates latency better than producing across it, and the workers' own state topics live in the target.

Is there a way to keep identical offsets?

Not with MirrorMaker 2, because it re-produces records. Some vendors offer replication between their own clusters that preserves offsets; with MM2 we rely on translation.

8Conclusion

In this answer, we wrote a minimal dedicated-mode configuration that replicates topics matching orders.* from primary to dr with group offset sync, and started it with connect-mirror-maker.sh. MM2 runs a source connector for records and configs, a checkpoint connector for translated group offsets and a heartbeat connector for liveness. Topics appear in dr as primary.orders under the default policy, MM2 keeps offset syncs, checkpoints, heartbeats and worker state in internal topics, and because records are re-produced, consumers fail over using translated offsets, never raw numbers.

What to say in the interviewAbout 80 seconds aloud

Open with

In dedicated mode the whole configuration is one properties file. I set clusters to primary and dr, give each a bootstrap.servers line, enable the primary->dr flow, set primary->dr.topics to orders.* and groups to .*, turn on sync.group.offsets.enabled, and set replication.factor to 3, plus the replication factors for the internal topics.

Then, if they want more

Then I start it with connect-mirror-maker.sh mm2.properties, usually on two or three machines near the dr cluster. It runs three connectors. MirrorSourceConnector consumes the matching topics and re-produces them in dr, keeping configs and partitions in sync. MirrorCheckpointConnector reads group offsets in primary, translates them and emits checkpoints, and with sync enabled commits them to the groups in dr.

MirrorHeartbeatConnector emits heartbeats so we can see the flow is alive. With the default replication policy, orders shows up in dr as primary.orders. The prefix lets MM2 avoid loops and lets consumers see where data came from; IdentityReplicationPolicy keeps the name but loses that cycle detection.

The internal topics are the offset-syncs topic, by default in the source, primary.checkpoints.internal in dr, heartbeats, and the workers' config, offset and status topics. Because records are produced again, offsets differ, so failing-over consumers need translated offsets and should be idempotent.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Write a minimal MirrorMaker 2 configuration for dedicated mode that replicates all...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/7d676116a0/