Apache Kafka high availability

A practical guide to designing Apache Kafka high availability in KRaft mode: controller quorum sizing, replication settings, rack placement, broker failure handling and recovery testing, with the decisions and effort drivers that shape the work.

On this page

How to design Apache Kafka high availability before production depends on it

In KRaft mode, high availability means that producers and consumers keep working when a broker or a controller fails, without losing acknowledged data and without manual intervention beyond what you have rehearsed. Kafka no longer uses ZooKeeper, so the controller quorum is part of the cluster itself: a small set of controller nodes stores cluster metadata in a replicated log, and losing enough of them to break quorum stops metadata changes even if brokers keep serving partitions. Sizing that quorum, and keeping its nodes on separate failure domains, is the first design decision.

Setting a replica count is not enough because availability is the product of several settings working together. The replication.factor of each topic, the min.insync.replicas value, and the producer acks setting decide whether a write survives a broker loss and whether the partition keeps accepting writes while a replica is down. Rack placement decides whether those replicas actually sit in different failure domains. Client retry and timeout settings decide whether applications ride through a leader election. Each of these can look correct on its own and still fail together during a real outage, which is why recovery must be tested rather than assumed.

Security is optional in Apache Kafka. Clusters can run without TLS or authentication, or mix secured and unsecured listeners, so the choice of encryption and authentication must be made deliberately and recorded as part of the design. Decide which listeners are secured, which identities brokers and clients use, and how controller traffic is protected before you set availability targets, because changing these later on a live cluster adds rolling restarts and risk to the same failover paths you are trying to prove.

Which Kafka components decide whether a failure is survivable

A Kafka cluster survives a failure only when its controllers, brokers, partition replicas, rack placement and write acknowledgement settings agree with each other. Each component below answers a different question: who holds the metadata, which copies of data exist, and how many copies must confirm a write. Review them together, not one at a time.

KRaft controllers and metadata log

In KRaft mode, controllers store cluster metadata such as topics, partitions, leaders and ACLs in an internal metadata log that they replicate among themselves. If a controller is lost and the metadata log is intact on the others, the cluster keeps its state. Check how many controllers you run, where they sit, and whether their storage is durable. Confirm the controller and quorum settings against the 4.3 documentation before you size the set.

Kafka 4.3 upgrade notes

Brokers as data-serving nodes

Brokers receive produced records, store them on disk and serve consumers. A broker failure is survivable only when the partitions it led have other replicas that can take over leadership. Plan spare broker capacity so the remaining brokers can absorb the load of a failed node without saturating disks or network. Ask your team to test a single broker stop during business hours before go-live.

Partition replicas and leader election

Each partition has a leader that handles reads and writes, and follower replicas that copy its log. The replication factor sets how many copies exist. When a leader fails, a follower that is in sync can be promoted. Replicas that have fallen behind are not eligible, so a high replication factor only helps if followers keep up. Review replication factor per topic, not once for the whole cluster.

Controller quorum vote

The controller quorum uses a majority vote to choose an active controller and to commit metadata changes. If too many controllers are down to form a majority, the cluster cannot change its metadata, even if brokers still serve existing partitions. Count the controllers you can lose in each failure zone and keep an odd number of voters so a majority remains after a single loss. Confirm the quorum behavior in the KRaft section of the 4.3 documentation.

Broker rack placement

The broker.rack setting tells Kafka which failure domain each broker belongs to, such as a rack, availability zone or data hall. Replicas of a partition should land in different racks so a single domain outage does not remove every copy. Without the setting, Kafka cannot spread replicas by domain. Verify the rack label on every broker and check where replicas landed after a topic is created.

Acks and min.insync.replicas

The producer acks setting and the topic or broker min.insync.replicas value together decide how many in-sync copies must confirm a write before it counts as committed. A write acknowledged by too few copies can be lost during a leader change. A write refused because too few replicas are in sync stops producers, which is the trade-off you accept for durability. Set both values deliberately for each topic class and test what producers see during a broker outage.

How controllers, brokers and racks fit into failure domains

The diagram starts at the client application outside the trust boundary, where a producer sends a write over an encrypted listener into the cluster. The broker that leads the target partition accepts the write and replicates it to follower replicas placed on brokers in other racks. Three KRaft controllers, one per rack, hold the metadata quorum, so losing a single rack leaves a majority running. Check that each rack truly fails independently in your facility, that replicas for each partition land in different racks, and that the client listener enforces TLS and authentication.

Illustrative layout only; map racks, controllers and replicas to your own facility.

Which high availability settings to choose and what each costs to run

This table compares the main Kafka resilience choices: controller quorum size, replication factor, min.insync.replicas with producer acks, rack placement and whether to add a second cluster. Read each row as a decision with an operational cost, and treat the right answer as the one your failure scenarios and staffing can support.

OptionWhen it fitsWhat it costs you operationally
Three KRaft controllersSingle-site clusters where losing one controller host is the failure you must surviveTolerates one controller failure. Any second loss stops metadata changes until a voter returns, so host maintenance needs care.
Five KRaft controllersClusters that must keep metadata changes running through two simultaneous controller losses or longer planned maintenanceMore voter hosts to provision, patch and monitor. Quorum needs three of five votes, so more hardware and more failure domains to place.
Replication factor of threeProduction topics where losing a broker must not lose committed dataRoughly three copies of every partition on disk and on the network. Storage and inter-broker traffic scale with this number, so plan capacity before raising it.
min.insync.replicas with acks=allTopics where an acknowledged write must exist on more than one broker before the producer proceedsWrites are rejected when too few replicas are in sync. Brokers down for maintenance can halt producers, so set the value against your broker count and maintenance plan.
Rack awareness within one siteSingle data center deployments that need replicas spread across racks or power domainsRequires accurate rack labels per broker and a placement check at topic creation. Mislabeled racks give false confidence and uneven replica placement.
Racks spread across sitesDeployments where a whole site loss must not take down the clusterInter-site latency affects produce and replication, and the stretched cluster needs a tested failover plan. Confirm the latency and link capacity your design needs with your network team.
Single clusterOne site, one operations team, and failure domains that a single cluster can coverLowest run cost and simplest client configuration, but a cluster-wide fault affects every workload on it.
Second cluster with MirrorMaker 2Regional or disaster recovery needs beyond what one cluster can tolerate (see the MirrorMaker 2 sibling topic)A second cluster to size, secure and monitor, plus replication lag tracking, offset translation during failover and runbooks for switching consumers and producers.

How min.insync.replicas and acks decide what a broker failure costs

The producer acks setting and min.insync.replicas together decide whether a broker failure slows writes, refuses them, or quietly leaves a partition with fewer copies than you planned. The replication factor sets how many copies of each partition exist. The in-sync replica set (ISR) is the subset of those copies currently caught up with the partition leader. With acks=all, the leader acknowledges a write only after the ISR has received it, and min.insync.replicas sets the smallest ISR size at which a write is still accepted. If the ISR shrinks below that minimum, the broker rejects the write with an error such as NotEnoughReplicas, and the producer must decide whether to retry, buffer or fail the request.

Consider a replication factor of three, illustratively with one broker in the replica set down. With min.insync.replicas=2, the ISR holds two members, so writes continue and every acknowledged record exists on two brokers. Lose a second broker and the ISR drops to one, so writes are refused. Your data stays consistent, but the topic is unavailable for writes until a broker returns. With min.insync.replicas=1, the same first failure is invisible to producers, yet a single surviving copy accepts writes. If that broker then fails before the others catch up, acknowledged records can be lost. The lower minimum buys availability by accepting a weaker durability guarantee, and the failure cost moves from a visible outage to silent data loss.

Treat the combination as a decision you make per topic class, not a cluster-wide default you inherit. Confirm the producer settings your clients actually use, since acks defaults and idempotence settings vary by client library and version, and check the current defaults in the Apache Kafka documentation for your release. Then test the chosen pair with your own clients: stop one broker, then two, during a produce load, and record what each producer sees, how long it retries, and whether consumers observe gaps or duplicates. Make the results part of the sign-off for each topic, because client libraries, not the broker alone, determine whether a refused write becomes an outage or a retry.

How to build a highly available KRaft cluster step by step

This sequence takes a team from choosing a supported Kafka release to a cluster that keeps producing and consuming after a broker is stopped, with each step closed by a check the team can run and record.

  1. Confirm the target release and upgrade path

    Start on the Kafka downloads page and choose a supported release line, then read the upgrade notes for that version before provisioning anything. The downloads page lists 4.3.1, 4.2.2 and 4.1.2 as supported, and Kafka 4.0 and later run only in KRaft mode, so a new build should be KRaft from the start. If you are moving from an older 3.x cluster, the upgrade notes recommend reaching 3.9.x first. The owner of this step should record the chosen version, the Java runtime (Java 17 for brokers and Connect) and the client Java versions in the design document. Done means the version, Java baseline and upgrade path are written down and signed off by the platform owner.

  2. Map failure domains and racks

    Before choosing hosts, list the failure domains you actually have: separate hardware racks, power feeds, network switches, availability zones or data halls. Decide which domain each controller and broker will occupy, and confirm with your infrastructure team that a single rack or zone failure cannot remove a majority of controllers or every replica of a partition. Ask the cloud or data center provider how zones are isolated, because two VMs in one host group are not separate domains. Done means a written placement table exists, with each node tagged by domain, and the infrastructure team has confirmed it against their real topology.

  3. Provision controllers and brokers across domains

    Deploy the KRaft controllers and the brokers on separate nodes, placing them according to the placement table so that controllers are spread across at least three domains. Keep controllers on dedicated machines where possible so that broker load and broker restarts do not compete with metadata operations. Install the same Kafka release and Java runtime everywhere, and confirm that time synchronization, disk layout and firewall rules are identical on every node. Done means every node starts, reports its role and is reachable on the controller and broker listeners from every other node.

  4. Set controller quorum and broker identities

    Configure controller.quorum.voters with the full, stable set of controller IDs and endpoints, and give every node a unique node.id. Use the same cluster ID on all nodes when formatting storage, and format each log directory once. Choose the number of controllers based on how many simultaneous failures you must survive, and confirm the quorum size with your own failure analysis rather than assuming a default. Done means the controller quorum has elected a leader, and the metadata quorum status command lists every expected voter as a member with no lag.

  5. Set replication and minimum in-sync defaults

    Set default.replication.factor and min.insync.replicas at the broker level so new topics inherit safe values, and align them with the number of brokers and failure domains. A replication factor of three with a minimum of two in-sync replicas is a common starting point for topics that must survive a single broker loss while still accepting acknowledged writes, and producers should use acks=all. Confirm the values with the data owners for each topic class, because durability and availability trade against each other here. Done means the broker configuration shows the chosen defaults and a test topic created without overrides reports the expected replication factor and minimum.

  6. Configure rack awareness

    Set broker.rack on each broker to the failure domain name from the placement table, so the controller places replicas of each partition in different domains. Confirm that the assignment is spread, not just configured: create a test topic and inspect its partition assignments to check that each partition's replicas land on brokers with distinct rack values. Note that rack placement applies when partitions are assigned, so existing topics may need reassignment after the change. Done means the describe output for the test topic shows replicas spread across all domains and no partition has all replicas in one domain.

  7. Validate client and producer settings

    Configure producer and consumer clients with bootstrap servers spanning brokers in several domains, producers with acks=all, and idempotence enabled where your client library supports it. Check that client retry and timeout settings cover the time a leader election takes, so applications retry rather than fail on a normal broker restart. Confirm that application teams have tested with the same client library version they will run in production. Done means a test producer and consumer run through a full cycle with no errors, and the team has recorded the timeout and retry values in the client standard.

  8. Run the first broker failure test

    With a steady test load running, stop one broker cleanly and watch the cluster. Check that the under-replicated partition count rises and then returns to zero once the broker rejoins, that leadership moves to in-sync replicas, and that a produce test with acks=all still succeeds during the outage. Repeat with a controller stop only if your quorum size allows it, and record the observed election and recovery times. Done means the test log shows zero failed acknowledged writes, the recovery is documented, and any gap against your availability target is logged as a finding with an owner.

How the high availability design changes by environment

In a single data center with several racks, the failure domains are physical: top-of-rack switches, power feeds and rack-level hardware. The design work is to spread controllers and brokers so that losing one rack leaves a KRaft quorum and enough in-sync replicas for every partition. Broker rack placement is set with broker.rack so Kafka can distribute replicas across racks.

  • Controller placement: Put controller nodes in different racks, and confirm that a single rack or power feed failure still leaves a controller majority.
  • Broker rack labels: Set broker.rack on every broker from an inventory source, not by hand, so replica placement matches the physical layout.
  • Storage: Use local disks with a known RAID or failure behavior per broker. Confirm whether a failed disk is replaced in place or the broker is rebuilt.
  • Recovery testing: Pull a rack's power or network in a maintenance window and measure leader election, under-replicated partitions and client errors.

Confirm with the platform team which racks share power, switches and maintenance windows, since those shared dependencies decide what a rack failure really takes down.

How to test that Kafka fails safely before go-live

Before go-live, the test that matters most is a controlled broker failure under producer load, because it shows whether the min.insync.replicas setting and replication factor behave the way your design predicts. Start by choosing a topic that matches production durability settings, with acks=all on the producers, and run a steady load generator at a rate your producers will really sustain. Stop one broker that leads partitions and record what the producers see: whether writes succeed while the in-sync replica count stays at or above the minimum, and whether they fail with not-enough-replicas errors when it drops below. Confirm the outcome against the design document rather than against what the team expects. Then restart the broker and check that it catches up and rejoins the in-sync set.

Controller tests are a separate exercise. Stop one active KRaft controller in your controller quorum and confirm that a new leader is elected and that metadata operations such as topic creation keep working. Repeat the test with a controller that is not the leader, and make sure you understand how many controller failures your quorum can absorb before metadata changes stop. Drain a whole rack or availability zone next, if you configured rack awareness, and verify that partition leaders and replicas spread across the remaining racks. For each test, have consumers running and check that they resume after the failure, that committed offsets are not lost, and that no messages are skipped or duplicated beyond what your delivery guarantees allow. Record the observed recovery time in your own environment, since the number depends on your hardware, network, data volume and client settings, and confirm it with your operations team before accepting it.

A passing test at a light load does not prove the cluster will fail safely at full load. Recovery takes longer when partitions carry more data, when followers must catch up, and when producers are close to the limits of the cluster, so repeat the key scenarios at production-level throughput and partition counts before go-live. Rerun the full suite after every Kafka upgrade and after any change to broker configuration, listener security, or the rack layout, because these changes can shift leader placement and timing. The Apache Kafka upgrade notes are the place to check for behavior changes that could affect the results. Keep the test scripts, load profiles and results under version control so the next run can be compared with this one.

What drives the effort and cost of a highly available Kafka design

This table lists the design inputs that change how much work a highly available Kafka cluster takes and what it costs in people and hardware time. Read each row as a question to answer before requesting a quote, since quotes follow the written scope.

DriverWhy it changes the workHow to keep it down
Topics and partitionsEach partition adds replicas, leader elections and recovery work during broker failures, so a high count raises testing and monitoring effort.Plan partition counts per topic from throughput and consumer parallelism, and avoid creating topics without an owner.
Failure domains and sitesEach additional rack, data center or cloud region needs its own broker placement, rack awareness settings and failover runbooks.Agree the number of failure domains early and limit cross-site replication to topics that truly need it.
Producer and consumer applicationsClient settings such as acks, retries and idempotence determine whether a broker failure causes loss, duplicates or stalled consumers, and each application needs testing.Standardize a client configuration baseline and document which applications tolerate retries or duplicates.
Environments (test, staging, production)Each environment that mirrors production topology needs its own controller quorum, brokers and failure drills, which multiplies build and test time.Use smaller non-production topologies for functional tests and reserve full-topology failure testing for staging and production-like runs.
Compliance evidence requirementsAssessors often ask for documented configuration, access control records, test results and recovery exercise logs, which add documentation and collection work.Confirm the evidence list with the assessor or your compliance lead before design starts, and generate records from the running system where possible.
Team skills and ownershipTeams without prior Kafka operations experience need more design review, training and supervised recovery testing, and the gap grows with the number of failure domains.Name an internal owner for each cluster, document the on-call model and ask any partner what knowledge transfer is included in the written scope.

What to monitor, back up, upgrade and document after go-live

A highly available Kafka cluster stays that way only if someone watches it, can rebuild it, keeps it on a supported release and knows what to do when a broker, controller or rack fails. The four areas below connect because each one produces the evidence and the routines that the others depend on.

Partition and quorum health monitoring

Alert on under-replicated partitions and offline partitions first, since they show a loss of redundancy or availability before clients report errors. Track the controller quorum separately: confirm that every controller voter is reachable, that a leader is elected, and that metadata lag stays small after broker restarts. Review these signals against the replication factor and min.insync.replicas values chosen at design time, and confirm the alerting thresholds with your own monitoring team rather than copying defaults from another environment.

Kafka operations docs

Configuration and metadata backup

Kafka topic data is protected by replicas, but the configuration that defines the cluster is not. Keep versioned copies of server properties, topic and client configurations, ACL definitions, TLS material references and the cluster ID. Metadata for a KRaft cluster lives in the cluster metadata log, so know how your team will snapshot and restore controller state. A backup that has never been restored into a scratch cluster is an assumption, so schedule restore tests and record how long they took and what had to be fixed by hand.

Rolling upgrades within the supported path

Plan every upgrade as a rolling operation that moves one broker or controller at a time while the cluster stays available. Before starting, confirm that your current release is on the supported path and that the target release is one the project still maintains. Check client, Kafka Connect and Streams compatibility, and rehearse the change in a non-production cluster first. The sequence, version jumps and Java requirements belong to the sibling upgrade topic, so use that guidance for the detailed steps.

Runbooks and audit evidence

Write one runbook each for broker loss, controller loss and rack loss. Each should name the alert that starts it, the first checks, the decision to fail over or wait, the commands used, the people to notify and the exit test that proves recovery. Keep the evidence an auditor or internal reviewer will ask for: dated failure drill records, backup restore results, upgrade change records, access reviews for the admin tools and the monitoring configuration in force at each point in time. Confirm with your assessor which evidence format they accept before drills begin.

Kafka security overview

Questions teams ask before designing Kafka high availability

How much effort does a highly available Kafka design take?

The effort depends mostly on how many clusters, sites and availability targets the design must cover, and on how much of the platform already exists. A single cluster spread across failure domains needs controller quorum sizing, replication settings, rack assignment, client configuration review and a documented failure runbook. Each added site, each stateful dependency such as Kafka Connect, and each client team that needs its producers and consumers reviewed adds work. Ask any partner to split the estimate into design, build, client review and recovery testing so you can see where the hours go.

How long does a Kafka high availability project take?

Duration follows scope. A design for one cluster with existing hardware and a clear owner is shorter than a design that spans two data centers, requires new racks, or must be validated against a set of client applications. Testing windows also set the pace, because broker failure and recovery tests need quiet periods and rollback plans. No duration is fixed in this page. Ask for a timeline tied to named milestones, the systems in scope, and the number of test cycles included in the written scope.

What must our team provide for a high availability design?

Your team usually provides the infrastructure, network paths, access and an owner who can make decisions. In practice that means:

  • Broker and controller hosts, or cloud accounts, spread across the failure domains you plan to use
  • Network rules between brokers, controllers, clients and monitoring, plus DNS and certificate processes
  • Administrative access to the cluster, hosts and the identity systems used for client authentication
  • A test window where brokers can be stopped and restarted, with a rollback path
  • A named owner for decisions on replication targets, data loss tolerance and client changes

Confirm each item in writing before the work starts.

Can our in-house team design Kafka high availability without outside help?

Yes, if the team has operated Kafka in KRaft mode, understands producer acknowledgments and consumer behavior, and can run controlled failure tests. The Apache Kafka project publishes its documentation and source under the Apache License 2.0, so the knowledge is available without a license fee. The harder part is usually proving the design under failure and getting every client team to adopt the same settings. An outside partner can add an independent review, a test plan and a retest after fixes. Decide based on your team's capacity and on how much evidence your assessors will expect.

How do replication factor and min.insync.replicas affect client behavior?

Replication factor sets how many copies of each partition exist, and min.insync.replicas sets how many of those copies must acknowledge a write when the producer uses acks=all. If the number of in-sync replicas drops below that minimum, the broker rejects writes with an error, so producers must handle retries or failure. Consumers keep reading from available replicas. For example, with a replication factor of 3 and min.insync.replicas set to 2 (illustrative values), one broker can fail without blocking acknowledged writes, but two failures stop writes until replicas recover. Test these settings with your real producers, because retry and timeout settings in client code decide what users see.

Do we need a second Kafka cluster for high availability?

Not always. A single KRaft cluster spread across racks or availability zones can survive broker and controller failures within that cluster, provided replication and rack settings are correct. A second cluster is a separate decision aimed at site-level failure, a regional outage, or a requirement to keep copies in another location. If you add one, MirrorMaker 2 can replicate topics, consumer group offsets and ACLs between clusters, but it adds replication lag, failover procedures and extra operations. Confirm your recovery time and data loss expectations before choosing a topology.

What should we ask for in a fixed-scope quote for this work?

Ask the provider to list the in-scope clusters, sites, client applications, Kafka and Connect components, and the controller and broker counts they assume. The quote should name the deliverables, such as a design document, configuration baseline, rack and quorum layout, failure test plan, test results, runbook and retest after fixes. Ask which costs are one-time, such as design and testing, and which recur, such as monitoring, upgrades or support retainers. Ask for the assumptions behind the effort, the client responsibilities, and what happens if scope changes. Confirm the Kafka release used, since the project lists 4.3.1, 4.2.2 and 4.1.2 as supported releases on its downloads page.

How DeployOpen scopes, builds and hands over Kafka high availability

DeployOpen plans, builds and tests Kafka high availability inside your own infrastructure, starting from a written scope. The work covers controller quorum, replication settings, rack placement and recovery testing, and it ends with documentation your operators can run without us.

How we scope

  • Agree in writing which brokers, controllers and sites the high availability design covers
  • Record the topic replication factor and min.insync.replicas targets each business workload needs
  • Confirm rack or zone layout, failure scenarios to test and the evidence your assessors expect

How we build

  • Deploy KRaft controllers and brokers with rack awareness matched to your actual failure domains
  • Configure replication factor and min.insync.replicas per topic, then check producer acks behavior
  • Run scripted broker and controller failure tests and record recovery times and any data loss

How we hand over

  • Deliver runbooks for broker replacement, controller failover and partition reassignment
  • Document the configuration baseline, test results and open risks in a form your team can review
  • Walk your operators through the failure drills so they can repeat them after handover

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Retesting after configuration changes or Kafka version upgrades can be included in the written scope

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.