Design a high-availability Kafka setup considering broker failures and network partitions.
Instruction: Outline a resilient Kafka architecture that maintains high availability and data integrity in the face of failures.
Updated
Official answer
Begin with the failure model and recovery targets. Broker crashes, one-zone loss and a regional partition are different requirements. State which operations may become unavailable to preserve acknowledged-data safety.
For an illustrative regional design, distribute partition replicas across three suitable failure domains, use replication factor three, producer acks=all and min.insync.replicas=2. Verify current eligible-leader-replica settings and actual synchronization. This is a starting design, not proof that any arbitrary two failures or every network split remains writable.
Kafka 4.x uses a KRaft controller quorum. Three voting controllers can tolerate one unavailable voter; five can tolerate two, provided a communicating majority remains. Separate controller roles and fault domains appropriately. The controller quorum is distinct from a partition's replicas and ISR.
A network partition can leave one side unable to obtain a metadata majority or enough eligible synchronized data replicas. Accept unavailability when the configured safety requirements cannot be met; unclean election can sacrifice acknowledged data. Adding brokers alone does not fix quorum loss or unsafe replica placement.
Provision capacity for surviving brokers, reassignment and recovery traffic. Configure authenticated encrypted listeners, least-privilege access, client retry/timeouts and idempotent handling of ambiguous outcomes. Consumers normally fetch leaders, with follower fetching available when configured.
Test broker loss, controller loss, slow disks and isolated failure domains. Measure user-visible interruption, acknowledged data, replay and restoration time. Monitor quorum health, offline/under-replicated partitions, disk runway and client errors, and retain runbooks for replacement and disaster recovery.