When MirrorMaker 2 replicates a topic with the default settings, what does the replicated topic get named on the destination cluster, and why?
answer
- DefaultReplicationPolicy
- source alias + separator
- us-west.orders
- provenance + no collisions
- enables cycle detection
basics
~20 sBy default MirrorMaker 2 prefixes the replicated topic with the source cluster's alias and a dot. A topic named 'orders' from cluster 'us-west' becomes 'us-west.orders' on the destination. This makes the topic's origin visible and prevents name clashes.
solid answer
~40 sMirrorMaker 2 (MM2) uses DefaultReplicationPolicy, which renames replicated topics by prepending the source cluster alias plus a separator (a dot by default). So topic 'orders' on source cluster 'us-west' becomes 'us-west.orders' on the destination. This 'source-prefixed' naming serves two purposes: it makes the topic's provenance explicit, and it lets the same destination cluster hold replicas from multiple sources without collisions (e.g. 'us-west.orders' and 'eu-central.orders' coexist). Crucially, it also enables cycle detection in active/active setups: because the prefix encodes the path a record travelled, MM2 can refuse to replicate a topic back to a cluster it already came from. The prefix and separator are configurable; the separator is controlled by 'replication.policy.separator'.
go deeper
Know that the default adds 'sourceAlias.' in front: orders becomes us-west.orders.
Explain the two motivations (provenance, collision avoidance) and name DefaultReplicationPolicy and the separator config.
Tie prefixing to cycle detection and multi-hop nested prefixes, and contrast with IdentityReplicationPolicy.
Reason about when prefixing helps vs. hurts (DR failover ergonomics, downstream tooling, regex subscriptions) and design the cluster-aliasing scheme accordingly.
## What MirrorMaker 2 is MirrorMaker 2 (MM2) is Kafka's built-in tool for copying (replicating) records from one Kafka cluster to another — used for disaster recovery, geo-distribution, and migrations. It runs on Kafka Connect and copies topic data, consumer offsets, and ACLs. ## The naming problem If MM2 copied topic 'orders' from cluster A to cluster B and kept the name 'orders', two problems arise: (1) you couldn't tell, on B, whether 'orders' is B's own topic or a copy from A; (2) if both A and C replicate their 'orders' into B, the two would collide. ## DefaultReplicationPolicy and source-prefixing MM2's default behavior is governed by a class called `DefaultReplicationPolicy`. It renames each replicated topic by prepending the **source cluster alias** followed by a **separator**. A cluster alias is just the short name you assign each cluster in MM2 config (e.g. `us-west`, `eu-central`). The separator defaults to a dot (`.`). So: - Source cluster alias: `us-west` - Original topic: `orders` - Replicated topic on destination: `us-west.orders` This is called a **source-prefixed** or **remote** topic name. ## Why this matters 1. **Provenance**: anyone looking at `us-west.orders` immediately knows it's a replica originating from `us-west`. 2. **No collisions**: `us-west.orders` and `eu-central.orders` can both live on the same destination. 3. **Cycle detection**: the prefix records the replication path. In active/active topologies (A→B and B→A), MM2 inspects the prefix to detect that a topic already originated from a cluster and refuses to loop it back, preventing infinite replication. 4. **Consumer failover**: clients can subscribe with a regex/pattern (e.g. via `RemoteClusterUtils` / the offset-sync machinery) and follow a topic across a failover because the policy can map remote names back to the original. ## Configurability The separator is set with `replication.policy.separator` (default `.`). The whole renaming scheme is pluggable via `replication.policy.class`; the alternative built-in is `IdentityReplicationPolicy`, which keeps names unchanged. ## Edge cases - Multi-hop replication produces nested prefixes: A→B→C makes `B.us-west.orders` on C (the chain of hops is encoded). - Internal/system topics (offsets, config, MM2's own heartbeats/checkpoints) are filtered or handled specially so they aren't blindly re-prefixed in a way that breaks things.
- What config controls the character between the prefix and the topic name?replication.policy.separator — it defaults to a dot ('.').
- What happens to the name after two hops (A to B to C)?Prefixes nest: C ends up with B.us-west.orders, encoding the full replication path.
saying these in an interview costs you the question
- Saying the replicated topic keeps the same name by default (that's IdentityReplicationPolicy, not the default)
- Claiming the prefix is the destination alias (it's the SOURCE alias)
- Thinking prefixing is purely cosmetic and serves no functional purpose (it enables cycle detection)