Monedula
Kafka guide contents

Markdown

Part VI · Reference

Kafka Improvement Proposal

KIP-392: consumers read from the closest replica

Consumer groups and queues · Shipped · since Kafka 2.4 · status checked November 2026

KIP-392 lets a Kafka consumer read from a follower replica in its own rack or availability zone instead of always from the partition leader. In the cloud that removes most of the cross-zone traffic consumers cause, which is billed. It needs a replica selector on the brokers and client.rack on the consumer.

Proposal
KIP-392, Allow consumers to fetch from closest replica
Status
Shipped Since Kafka 2.4 (2019), opt-in with replica.selector.class and client.rack.
Area
Consumer groups and queues
Read from the follower in az-b. At 905 ms the followers' next fetch carried high watermark 1, and at 1000 ms g-near read O1 from broker-2, its preferred read replica: the in-sync replica in az-b. No consumer byte crossed a zone, at the cost of one fetch round (200 ms here) of freshness. Open this step in the full playground

Why it was needed

Before KIP-392 every fetch went to the leader. With leaders spread over three zones, about two thirds of all consumer traffic crossed a zone boundary, and in a multi-datacenter cluster consumers read across the WAN even when a full copy sat next to them.

What it changes

The consumer sends its client.rack with each fetch. If the broker has a replica selector configured, the leader answers with a preferred read replica: an in-sync replica in the same rack, or itself if there is none. The consumer then fetches from that follower. A follower learns the high watermark only through replication, so new records reach follower readers a little later than leader readers.

How to use it

  • Set broker.rack on every broker and replica.selector.class to the rack-aware selector on the brokers.
  • Set client.rack on each consumer to the zone it runs in.

Where it stands

Shipped in Kafka 2.4 and widely used on cloud clusters. An offset the follower cannot serve yet returns OFFSET_NOT_AVAILABLE and the consumer retries, so reads stay correct.

What comes next

Stable. Producers got the matching feature much later with rack-aware partitioning (KIP-1123, Kafka 4.4), and diskless topics (KIP-1150) aim at the replication traffic neither of them removes.

See it in the simulator

The simulator asks for the preferred read replica on every fetch, so a consumer goes back to its follower as soon as that follower is in sync again, and after OFFSET_NOT_AVAILABLE it retries the same follower. A Kafka consumer keeps the replica the leader named until a fetch error or its next metadata refresh (metadata.max.age.ms, 5 minutes by default), and after an error it asks the leader again. The diskless scenario keeps the default selector and shows the cross-zone leader read that KIP-392 avoids.

Sources

All Kafka KIPs