Skip to main content

Enable follower fetching in Aiven for Apache Kafka®

Enabling follower fetching in Aiven for Apache Kafka® allows your consumers to fetch data from the nearest replica instead of the leader, optimizing data fetching and enhancing performance.

Prerequisites

note

Follower fetching is supported on AWS (Amazon Web Services) and Google Cloud.

Identify availability zone

Enable follower fetching

Use either of the following methods to enable follower fetching on your Aiven for Apache Kafka service:

  1. Access the Aiven Console, and select your Aiven for Apache Kafka service.
  2. Click Service settings.
  3. Scroll to Advanced configuration and click Configure.
  4. Click Add configuration options.
  5. Select follower_fetching.enabled from the list and set the value to Enabled.
  6. Click Save configurations.

Client-side configuration

To enable follower fetching at the client level, configure the client.rack setting in the Apache Kafka client. Set the client.rack value to the corresponding AZ ID for AWS or AZ name for Google Cloud for each client. This ensures the client fetches data from the nearest replica.

Example configuration for your consumer properties file:

client.rack=use1-az1 # AWS example
client.rack=europe-west1-b # Google Cloud example

Example scenario: follower fetching in different AZs

Assume you have an Aiven for Apache Kafka cluster running in two AZs in the us-east-1 region for AWS and in the europe-west1 region for Google Cloud:

Cluster setup and consumer distribution

CloudRegionAZs for brokersAZs for consumers
AWSus-east-1use1-az1, use1-az2use1-az1, use1-az2, use1-az3
Google Cloudeurope-west1europe-west1-b, europe-west1-ceurope-west1-b, europe-west1-c, europe-west1-d

Consumer configuration

Set the client.rack value to the respective AZ ID for AWS or AZ name for Google Cloud for each consumer:

# AWS consumers in use1-az1
client.rack=use1-az1

# AWS consumers in use1-az2
client.rack=use1-az2

# AWS consumers in use1-az3
client.rack=use1-az3

# Google Cloud consumers in europe-west1-b
client.rack=europe-west1-b

# Google Cloud consumers in europe-west1-c
client.rack=europe-west1-c

# Google Cloud consumers in europe-west1-d
client.rack=europe-west1-d

Fetching behavior

CloudConsumer locationFetching behaviorNotes
AWSuse1-az1Fetch from the nearest replica in their AZReduced latency and network costs
AWSuse1-az2Fetch from the nearest replica in their AZReduced latency and network costs
AWSuse1-az3Fetch from the leader (no matching broker.rack)No follower fetching possible
Google Cloudeurope-west1-bFetch from the nearest replica in their AZReduced latency and network costs
Google Cloudeurope-west1-cFetch from the nearest replica in their AZReduced latency and network costs
Google Cloudeurope-west1-dFetch from the leader (no matching broker.rack)No follower fetching possible

Verify follower fetching

After configuring follower fetching, monitor for a decrease in cross-availability zone network costs to verify its effectiveness.