liveBook · Manning

Client.rack

As explained in Apache Kafka in Action

client.rack is a Kafka client configuration that assigns a rack or location identifier used to select a nearby replica for fetching records.

client.rack assigns a rack or location identifier to a Kafka client. Consumers use it to fetch records from a replica in the same rack or data center, reducing cross-location traffic; producers still send records to the partition leader. section 9.1.2 section 16.1.4

Apply client.rack with these operational considerations:

  • Set it on consumers when brokers span data centers or availability zones and cross-location traffic is costly. section 16.1.4
  • Pair it with broker rack identifiers so Kafka can represent broker locations and distribute replicas across fault domains. section 9.1.2
  • Expect consumers to prefer a nearby replica, while producers continue communicating with the partition leader. section 9.1.2
Figure 9.1 The consumers are consuming from the nearest replica (in the same rack), but producers still have to produce to the leader of the partition.
A close-up of a black background

AI-generated content may be incorrect.

Visualizes consumers reading from replicas in their rack while producers write to the partition leader. section 9.1.2

How Apache Kafka in Action covers it

How deep it goes
Explains the client setting, replica-selection purpose, and producer caveat without detailing its implementation internals.
Examples
Uses a stretched cluster example where consumers read from same-data-center replicas while producers contact leaders.
What it assumes
Assumes broker locations use rack identifiers and distinguishes consumer fetching from producer communication with leaders.
What you can do after
Operate consumers with client.rack to favor local replicas and reduce inter-data-center traffic.
How it connects
Connects client.rack with broker.rack, replicas, partition leaders, fault domains, and availability zones.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.