blog by OSO

How to Migrate Kafka Cluster with Limited Downtime

Sion Smith
Sion Smith 18 August 2023
OSO guide to migrating an Apache Kafka cluster with limited downtime using replication, schema migration and a staged cutover, with white title text on a navy panel and a lime Blogs label.

Updated October 2026: We have restructured this guide, added a comparison of the replication tools and a step-by-step cutover plan, and clarified how schema registry wire formats differ. If you are moving from ZooKeeper to KRaft on the same cluster, that is an in-place migration rather than a cluster-to-cluster one: see our guide on how to migrate Kafka to KRaft mode.

Migrating Apache Kafka clusters can be complex, especially when you are moving large amounts of data between environments, providers or vendors. A successful Kafka migration depends on four things: the replication technology you choose, how you handle schemas, the configuration changes you make along the way, and a realistic plan for moving the applications.

What does a Kafka cluster migration involve?

A cluster-to-cluster Kafka migration moves topics, data, schemas, consumer offsets and configuration from a source cluster to a new target cluster. Common reasons include:

  • moving from self-managed Kafka to a managed service, or between providers
  • changing vendor distribution, for example from Cloudera to Confluent or Apache Kafka
  • replacing old hardware or an old Kafka version that can’t be upgraded in place
  • redesigning topics, partitions, security or ACLs on a fresh cluster

To keep downtime low, the old and new clusters run side by side. Data is replicated continuously, so applications can move across when they are ready instead of in a single big-bang outage.

Which tools can you use to migrate a Kafka cluster?

Three replication technologies cover most Kafka migrations:

ToolLicenceOffsetsSchemasBest for
MirrorMaker 2Open source (Apache Kafka)Translated through checkpoints; can sync group offsetsNot replicated by itselfAny Apache Kafka compatible source and target
Confluent ReplicatorCommercial (Confluent)Translated for Java consumers through an interceptorSchema translation between registriesConfluent Platform migrations that need schema translation
Cluster LinkingCommercial (Confluent Server and Confluent Cloud)Preserved: mirror topics keep the same offsetsSchema Linking keeps schemas in syncConfluent to Confluent migrations

MirrorMaker 2 runs on Kafka Connect. By default it prefixes replicated topics with the source cluster alias. For a migration you usually want the same topic names on the target, so use the identity replication policy (available since Kafka 3.0):

replication.policy.class=org.apache.kafka.connect.mirror.IdentityReplicationPolicy
emit.checkpoints.enabled=true
sync.group.offsets.enabled=true

How do you migrate schemas between schema registries?

When you migrate a Kafka cluster that uses Avro, Protobuf or JSON Schema, the schemas must move with the data. Each message carries a schema ID in its header bytes, so the consumers on the new cluster must be able to resolve that ID.

You have three main options:

  1. Translate schemas while replicating. Confluent Replicator can translate schemas from one schema registry to another while it replicates the data, so schemas and data move together.
  2. Keep the schema IDs the same. Schema Linking, or importing the schemas into the new registry with their original IDs, means the messages work unchanged.
  3. Re-serialise the messages. Use schema-aware serialisers to deserialise each message with the source registry and serialise it again with the target registry. This adds overhead, but aligns the schema IDs with the new registry.

Not all schema registries use the same wire format. Confluent serialisers write a magic byte of 0 followed by a 4-byte schema ID. Cloudera Schema Registry serialisers write their own protocol byte and schema identifiers. So when you move from Cloudera to Confluent, you can’t simply mirror the topics or import the schemas: Confluent deserialisers won’t understand the messages.

To fix this, either write a custom Single Message Transform (SMT) or connector that rewrites the header bytes into the Confluent format, or run an application that reads with the Cloudera deserialiser and writes with the Confluent serialiser. Test it with real messages in a lower environment first: wire format mismatches tend to show up as deserialisation errors late in testing.

How do you change compression during a Kafka migration?

A migration is a good opportunity to change compression. MirrorMaker 2 and Replicator consume the messages and produce them again, so you can set a compression type on their producers. Even if the source cluster doesn’t compress messages, they can be compressed as they are written to the new cluster.

Make sure the topic setting and the producer setting agree:

Topic compression.typeProducer compressionResult on the broker
producer (default)AnyBatches stored as the producer sent them
Same codec as the producerSameStored as sent, no extra work
Different codecDifferentThe broker decompresses and recompresses every batch, costing CPU

The usual approach is to compress on the producer and leave the topic set to producer, so the broker stores the batches as they arrive.

How do you cut over applications with limited downtime?

Once replication is running and the target has caught up, move the applications in a controlled order:

  1. Prepare the target. Create the topics, partitions, ACLs, quotas and service accounts on the new cluster.
  2. Start replication. Mirror the topics and schemas, and let the target catch up with the source.
  3. Validate. Compare message counts and consumer lag, and test sample consumers against the target.
  4. Move the consumers. Stop each consumer group, check its translated offsets on the target, and restart it pointing at the new cluster.
  5. Move the producers. Repoint the producers once their consumers are on the target, keeping the gap between the two short.
  6. Stop replication. When every application on a topic has moved, stop mirroring it and decommission the old topics.

Moving one application or domain at a time keeps each change small and easy to roll back. If you control all the applications and can schedule a short outage, you can move faster by stopping producers, letting the target catch up and switching everything at once.

How long does a Kafka cluster migration take?

The length of a Kafka migration depends mostly on the strategy and planning. You need a clear picture of your application dependencies, data lineage and data model. Once the strategy is in place, setting up the replication itself doesn’t take long.

WorkTypical effort
Replication setup and data migration with few changesAbout one to two weeks
New ACLs, topic layouts or partition countsExtra design and performance testing
Coordinating application teamsOften the longest part, depending on the organisation

Changing partition counts needs performance testing, because fewer partitions means less parallelism for consumers. Be realistic about the timeline and communicate it to every stakeholder: migrations often take longer than first planned because of dependencies between teams.

What are the common Kafka migration pitfalls?

Migrating a Kafka cluster sounds easy. The complexity lies in the strategy and planning, not in moving the bytes. Watch out for:

  • Underestimating coordination. Teams and departments need time to agree a cutover window and test their applications.
  • Ignoring schemas until late. Wire format and schema ID mismatches break consumers on the new cluster.
  • Skipping offset translation. Consumers that restart without translated offsets either reprocess data or skip it.
  • Changing too much at once. Every new partition scheme, ACL model or compression change adds testing.
  • No rollback plan. Keep the source cluster running until every application has moved and proved stable.

Plan carefully, measure twice and cut once. Read the documentation, run trial migrations in lower environments, or work with engineers experienced in Kafka migrations. Our list of Apache Kafka common mistakes and our guide to Kafka performance best practices help you avoid carrying old problems onto the new cluster.

Key takeaway: Migrate a Kafka cluster with limited downtime by running the old and new clusters side by side, replicating data with MirrorMaker 2, Replicator or Cluster Linking, moving schemas and translated offsets with the data, and cutting applications over one group at a time. Plan for coordination to take longer than the technical setup.

Frequently asked questions

Can you migrate a Kafka cluster with zero downtime?

You can get close. With continuous replication and translated consumer offsets, each application only pauses briefly while it restarts against the new cluster. A short, scheduled outage is simpler if you control all the applications.

What is the best tool to migrate a Kafka cluster?

MirrorMaker 2 is the open source default and works between any Apache Kafka compatible clusters. Cluster Linking is the simplest option between Confluent clusters because it preserves offsets. Confluent Replicator adds schema translation between schema registries.

Does MirrorMaker 2 migrate consumer offsets?

Yes. MirrorMaker 2 emits checkpoints that map consumer group offsets from the source to the target cluster. With group offset sync enabled, it writes the translated offsets to the target so consumers can resume where they left off.

How do you migrate from Cloudera Schema Registry to Confluent Schema Registry?

Cloudera and Confluent serialisers use different wire formats, so you can’t mirror the messages unchanged. Rewrite the header bytes with a custom Single Message Transform or connector, or re-serialise each message with a Cloudera deserialiser and a Confluent serialiser.

How long does a Kafka migration take?

Setting up replication and migrating the data typically takes one to two weeks if you make few changes. Coordinating application teams often takes longer, so the whole project can run for several weeks or months.

Migrate your Kafka cluster with OSO

Talk to OSO's Kafka engineers about planning a low-downtime migration, moving schemas and offsets, and cutting your applications over safely.

CONTACT US
OSO
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.