Skip to main content

Configure rack awareness in Aiven for Apache Kafka® MirrorMaker 2

Configure rack awareness in Aiven for Apache Kafka® MirrorMaker 2 to reduce cross-Availability Zone (AZ) network traffic by preferring follower replicas in the same AZ as the MirrorMaker node.

About rack awareness in MirrorMaker 2

Rack awareness works only when follower fetching is enabled on both the source Kafka service and the MirrorMaker 2 service. When follower fetching is enabled, MirrorMaker 2 prefers reading from follower replicas in the same availability zone when those replicas are in sync, reducing data transfer across zones.

If follower fetching is disabled on either service, MirrorMaker 2 reads from leaders and rack awareness has no effect.

To learn how these features work together, see Follower fetching in Aiven for Apache Kafka®.

Configuration hierarchy

MirrorMaker 2 applies rack awareness using the following rules:

  1. If follower_fetching_enabled = false: rack awareness is disabled for all integrations.
  2. If follower_fetching_enabled = true:
    • External Kafka clusters: rack awareness is always disabled.
    • Aiven-hosted Kafka services:
      • If rack_id is set in the integration configuration, that value is used.
      • If rack_id is not set, the node’s AZ is used as the rack ID.

Prerequisites

  • A running Aiven for Apache Kafka® MirrorMaker 2 service.

  • Follower fetching enabled on the source Aiven for Apache Kafka® service. MirrorMaker 2 applies rack awareness only when both the source Kafka service (follower_fetching.enabled=true) and the MirrorMaker 2 service (kafka_mirrormaker.follower_fetching_enabled=true) have follower fetching enabled.

  • Identify the availability zones (AZs) for your Kafka brokers if you plan to use custom rack_id values:

note

Rack awareness is disabled for integrations with external Kafka clusters.

Enable rack awareness

Rack awareness is controlled using the follower_fetching_enabled flag in the MirrorMaker 2 service configuration.

  1. In the Aiven Console, open your MirrorMaker 2 service.
  2. Click Service settings.
  3. In Advanced configuration, click Configure.
  4. Click Add configuration options.
  5. Set kafka_mirrormaker.follower_fetching_enabled to Enabled or Disabled.
  6. Click Save configurations.

Override the rack ID per integration

To override the default AZ-based rack assignment, set a custom rack_id in the MirrorMaker 2 integration configuration.

  1. In the Aiven Console, open your MirrorMaker 2 service.
  2. Click Integrations.
  3. Select the integration to update.
  4. In Advanced configuration, set the rack_id to your custom value (for example, use1-az1).
  5. Click Save changes.

Example configurations

For a deeper explanation of how rack awareness works with follower fetching, see Enable follower fetching in Aiven for Apache Kafka®.

Below are examples specific to MirrorMaker 2 integrations.

AZ-based rack ID (default)

Node AZRack ID usedBehavior
use1-az1use1-az1Reads/writes to brokers in use1-az1
europe-west1-beurope-west1-bReads/writes to brokers in same AZ

Custom rack ID per integration

{
"cluster_alias": "kafka-source",
"rack_id": "custom-rack-1"
}

This overrides the node's AZ. MirrorMaker uses custom-rack-1 for that integration.

Mixed setup

Integrationrack_id valueRack ID used
Aiven-hosted service ANot setNode’s AZ
Aiven-hosted service Bcustom-rackcustom-rack
External Kafka serviceAny valueRack awareness disabled

Related pages