Apache Kafka & Stream Processing Fundamentals · Lektion

Rack Awareness und Multi-AZ-Platzierung

Lernen Sie, wie Kafka mithilfe von Rack Awareness Replikate über Racks und Availability Zones verteilt, um Ausfälle auf Rechenzentrumsebene zu überstehen.

Lektion 4 von 413 Schritte

Rack Awareness und Multi-AZ-Platzierung ist eine kostenlose Apache Kafka & Stream Processing Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Apache Kafka & Stream Processing Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Apache Kafka & Stream Processing Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What Is Rack Awareness?

Rack awareness tells Kafka about the physical (or cloud) topology of your brokers.

Without it, all replicas of a partition could land on brokers sharing the same rack or availability zone. If that zone fails, the partition becomes unavailable.

  • Each broker advertises a broker.rack value.
  • Kafka then places replicas on different racks when possible.

Configuring broker.rack

Set broker.rack in each broker's server.properties to identify its rack or zone.

# server.properties on a broker in us-east-1a
broker.id=1
broker.rack=us-east-1a

# Another broker in a different zone
broker.id=2
broker.rack=us-east-1b

How Replicas Get Spread

When a topic is created, Kafka's replica assignment algorithm alternates across racks.

For a partition with replication factor 3 and 3 racks, each replica lands on a distinct rack — guaranteeing the partition survives the loss of any single rack.

Cloud Availability Zones

In AWS, GCP, or Azure, map broker.rack to the availability zone (AZ).

  • AZs are physically isolated within a region.
  • Spreading replicas across AZs protects against a full AZ outage.
  • Beware cross-AZ network costs for replication traffic.

Creating a Rack-Aware Topic

No special flag is needed — if brokers have broker.rack set, topic creation is automatically rack-aware.

kafka-topics.sh --create \
  --bootstrap-server localhost:9092 \
  --topic orders \
  --partitions 6 \
  --replication-factor 3

Verifying Replica Placement

Use --describe to inspect which brokers hold each replica, then cross-check against broker racks.

kafka-topics.sh --describe \
  --bootstrap-server localhost:9092 \
  --topic orders

The min.insync.replicas Tie-In

Rack awareness protects placement, but durability also depends on min.insync.replicas.

With replicas spread across 3 AZs and min.insync.replicas=2, a producer using acks=all can still write even if one entire AZ is down.

Follower Fetching from Closest Replica

Kafka 2.4+ supports fetch from follower. Consumers can read from a replica in their own rack, cutting cross-AZ traffic and latency.

# broker config
replica.selector.class=org.apache.kafka.common.replica.RackAwareReplicaSelector

# consumer config
client.rack=us-east-1a

Limitations to Know

Rack awareness is best-effort:

  • If racks < replication factor, some replicas share a rack.
  • Reassignments triggered manually do not always respect racks unless you generate a rack-aware plan.
  • It does not rebalance existing topics when you add broker.rack later.

Generating a Rack-Aware Reassignment

To fix existing topics after enabling rack awareness, generate a reassignment plan with the reassign-partitions tool.

kafka-reassign-partitions.sh \
  --bootstrap-server localhost:9092 \
  --topics-to-move-json-file topics.json \
  --broker-list 1,2,3 \
  --generate

Design Checklist

Before going to production:

  • Replication factor >= number of racks you want to tolerate losing + 1.
  • Set min.insync.replicas to at least 2.
  • Use acks=all on critical producers.
  • Enable follower fetching to control cross-AZ costs.

Quick Check

Test your understanding of rack awareness.

Recap

You learned how rack awareness spreads replicas across racks and availability zones.

  • Set broker.rack per broker.
  • Topic creation becomes automatically rack-aware.
  • Combine with min.insync.replicas and acks=all for AZ-failure resilience.
  • Use follower fetching to reduce cross-AZ cost.
Kostenlos starten

Lerne Apache Kafka & Stream Processing Fundamentals mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
48

Häufig gestellte Fragen

Ist die Lektion „Rack Awareness und Multi-AZ-Platzierung“ kostenlos?

Ja — der vollständige Text von „Rack Awareness und Multi-AZ-Platzierung“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Apache Kafka & Stream Processing Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Apache Kafka & Stream Processing Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Rack Awareness und Multi-AZ-Platzierung“?

Lernen Sie, wie Kafka mithilfe von Rack Awareness Replikate über Racks und Availability Zones verteilt, um Ausfälle auf Rechenzentrumsebene zu überstehen. Du übst Apache Kafka & Stream Processing Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Apache Kafka & Stream Processing Fundamentals zu starten?

Keine Vorkenntnisse erforderlich. Apache Kafka & Stream Processing Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Rack Awareness und Multi-AZ-Platzierung“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Apache Kafka & Stream Processing Fundamentals-Lektion Code schreiben und ausführen?

Ja. Jede Apache Kafka & Stream Processing Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Replikation und Fehlertoleranz
  2. Rollen von Controller und ZooKeeper/KRaft
  3. Einen Kafka-Cluster entwerfen
  4. Rack Awareness und Multi-AZ-Platzierung
← Zurück zu Apache Kafka & Stream Processing Fundamentals