Rack Awareness is a built-in feature that physically or logically separates brokers and replicas (across racks, availability zones, or data centers) to reduce the chance that a single failure causes an outage or data loss. The two operational keys are: set the correct rack on every broker, and tune replication settings on the assumption that a rack can fail.
This article walks through broker placement, the partition placement algorithm, RF combined with min.insync.replicas, and failure-time behavior, all grounded in stable behavior from the official documentation. We close with the CCAAK-specific points to remember for the exam.
Kafka's Rack Awareness spreads replicas across different racks as much as possible when topics are created or replicas are reassigned. As a result, even if an entire rack fails or is taken down for planned maintenance, a replica on another rack can keep the leadership and continue serving reads and writes.
The prerequisite is simple: every broker must have a consistent rack label (broker.rack). Without it, the controller cannot use rack information and the risk of replicas piling up on the same rack rises sharply.
broker.rack is a static per-broker setting. Rack and AZ names must be consistent across the cluster, with no typos or accidental duplicates. After setting it, apply with a rolling restart. Replica placement for existing topics does not change automatically, so plan reassignments where needed.
Verify in practice by inspecting broker configuration via the admin API, or by creating a fresh test topic and checking that its replicas are spread across different racks.
Example broker.rack configuration and verification topic creation
# 各ブローカー server.properties(一例)
broker.id=1
broker.rack=r1
# 他設定は省略
# Kubernetes 等では環境変数を使ってテンプレート展開する例もある
# KAFKA_BROKER_RACK=r1
# 検証用に RF=3 のトピックを作成
kafka-topics --bootstrap-server <host:port> \
--create --topic rack-test --partitions 3 --replication-factor 3
# 配置の確認(レプリカが複数 rack に分散しているか)
kafka-topics --bootstrap-server <host:port> --describe --topic rack-test
# AdminClient(API)でブローカー構成(broker.rack)を参照しても良いAt topic creation time, the controller takes broker.rack into account and places replicas on different racks where possible. It also balances per-broker partition and replica counts so that no single rack becomes overloaded.
When a rack fails, the leader is elected from an in-sync replica on another rack. With RF=3, min.insync.replicas=2, and acks=all, the cluster keeps accepting writes even after losing one rack (= one replica).
Example of rack spread (RF=3, 3 racks, 6 brokers)
To survive rack failures, you need more than just replica spread; you also need an appropriate write-quorum configuration. In particular, treat RF, min.insync.replicas (minISR), and producer acks as a single tuning unit, and understand the trade-off between continuity during a failure and data safety.
For a 3-rack setup, RF=3, minISR=2, and acks=all is the general recommendation. This keeps writes flowing through a single-rack loss while disabling unclean leader election to prevent data loss.
| Configuration | Rack-failure tolerance | Write availability during failure | Typical use case / caveats |
|---|---|---|---|
| broker.rack not set + RF=3 + minISR=2 + acks=all | Theoretically possible but actual placement may concentrate on one rack | Depending on placement, writes may fail | First step: get broker.rack set on every broker |
| broker.rack set + RF=3 + minISR=2 + acks=all | Handles a single-rack failure | Available (while 2 replicas remain healthy) | Standard CCAAK answer; disable unclean leader election |
| broker.rack set + RF=2 + minISR=2 + acks=all | Weak against single-rack failures (RF=2 fails on one-rack loss) | Not available (quorum not met) | Low cost, but unsuitable where rack-failure tolerance is required |
| broker.rack set + RF=3 + minISR=1 + acks=1 | Replica spread works but data safety is weak | Available (but with consistency risk) | For temporary, latency-first workloads; not recommended for critical data |
For planned maintenance, avoid rack-wide work and prefer rolling at the broker level. If a full-rack shutdown is unavoidable, review minISR and traffic patterns in advance and, if needed, apply temporary throttles or tune producer back-off.
When reassigning replicas, generate a rack-aware plan and set rebalance throttles appropriately. From a monitoring angle, focus on whether partition leadership is skewed toward a particular rack and whether ISR shrink events are cascading.
CCAAK tests practical fundamentals: the rack-aware replica spread mechanism, how RF/minISR/acks interact, whether writes succeed during a rack failure, and the rollout order (broker.rack set on every broker). Covering the points below reduces avoidable losses.
Also, client-side near-replica reads are a separate configuration area; do not confuse them with Rack Awareness (which is about replica placement).
CCAAK
問題 1
On a Kafka cluster with brokers evenly placed across 3 racks (r1, r2, r3), you want to keep writes flowing through a full-rack failure while avoiding data loss. Which combination is most appropriate?
正解: A
To plan for rack failures, replicas must be spread across racks (broker.rack on every broker), the quorum conditions RF=3 and minISR=2 must be met, and acks=all must confirm commits. Disable unclean leader election to prevent data loss. RF=2 fails the quorum on a rack loss, and missing or partial rack settings do not guarantee spread.
If I change broker.rack later, will existing topic replicas move automatically?
No, they do not move automatically. The rack value is only used in placement calculations for newly created topics or reassignments. To spread existing partitions across racks, you need to plan and execute a reassignment with the reassignment tool or admin API.
What happens if the replication factor is larger than the number of racks?
Kafka spreads replicas across as many racks as possible, but the remaining replicas end up on the same rack as another replica. Full rack isolation is impossible in this case, so depending on requirements consider adding racks, lowering RF, or revising the placement policy.
Can consumers be made to read preferentially from replicas in the same rack?
This is a separate concern from replica placement Rack Awareness. Kafka offers client- and broker-side settings that prefer fetching from nearby replicas, by combining client.rack with related replica selector settings. Availability and defaults vary by version, so check the official documentation for the version you are running.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Kafka Topics & Partitions: Distribution Fundamentals (2026)
How Kafka topics and partitions enable scale — ordering guar...
CCDAK Exam Guide: Confluent Certified Developer (2026)
Complete prep for the CCDAK exam — Producer/Consumer API, St...
CCAAK Exam Guide: Confluent Certified Administrator (2026)
Pass the CCAAK exam — cluster management, partitions, securi...
Kafka Replicas & ISR: Fault Tolerance Explained (2026)
Replica placement, in-sync replicas (ISR), leader election. ...
Kafka Offsets: Commit Modes & Consumer Position (2026)
Offset semantics — auto vs. manual commit, __consumer_offset...