# Application Migration

## Concepts

Replicating data from one Kafka cluster to another is great, but what about the consumers? The offsets don't match so if I blindly re-point my consumer to the new cluster it might reprocess data. This might be ok for your use case, it might not.

If its not, app migrations allow you, in conjunction with K2K replicators, to map the consumer groups from one cluster to another.

### How it works

Each message has an offset, in the new cluster when replicated it gets an new offset. The source message also has timestamps.

When replicating the K2K apps can add the source offset and timestamp information into the new message headers.&#x20;

Lenses can then look at the source consumer groups and check when and if its last commited offset is present on the target by looking at the headers. If so creates a new consumer group on the target and sets accordingly the new offset position.

## Creating an App Migration

Select the `Apps` option from the left sidebar, either open the listing for `App Migration` and click `Create App Migration`, or click create from the node in the tree panel.

{% hint style="info" %}
Requires a K2K app with Record timestamp and Tracing Headers offset enabled
{% endhint %}

Select the `Apps` option from the left sidebar, either open the listing for `App Migration` and click `Create Application Migration`, or click `+` from the node in the tree panel. Then

{% stepper %}
{% step %}

### Add name

Give the migration a name
{% endstep %}

{% step %}

### Select the K2K replicator

Choose the replicator that is replicating the topics your consumer group is reading from
{% endstep %}

{% step %}

### Select the consumer group

Select the consumer group to migrate
{% endstep %}

{% step %}

### Stop the consumer

The consumer group needs to be inactive to the source offsets are not a moving target
{% endstep %}

{% step %}

### Confirm you have stopped the consumer

Once stopped, confirm to begin the mirgation process
{% endstep %}
{% endstepper %}

Lenses will then check for the corresponding records in the target cluster for the consumers last commited offsets on the source cluster.

Once found, it will create the corresponding consumer group on the target cluster. You can then update your application with the new bootstrap brokers to consume where it left off on the target cluster.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/user-guide/using/share-and-replicate-data/application-migration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
