Self-hosted Apache Kafka in KRaft mode becomes shared infrastructure quickly
Deploy Apache Kafka in KRaft mode with dedicated controllers, agreed topic conventions and TLS from the first day. Kafka 4.0 supports only KRaft mode and has removed ZooKeeper mode, so every new cluster uses KRaft and every ZooKeeper cluster must migrate first. Kafka stores streams of records in partitioned, replicated topics. Producers write without knowing who will read, and each consumer group reads at its own pace from retained data. The project is licensed under Apache-2.0.
Kafka Connect moves data between Kafka and other systems, and Kafka Streams is a client library for stream processing. Typical uses include event distribution between services, change data capture, buffering for log and telemetry pipelines, and integration feeds read by several teams.
Once a few teams depend on a cluster, topic naming, ownership, retention and schema contracts matter as much as broker count. Agree on them before the first production topic, because renaming and repartitioning later affect every producer and consumer.
Pick a release line on purpose. The downloads page lists 4.4.0 (released October 22, 2026), 4.3.2 (October 23, 2026) and 4.2.2 (September 29, 2026) as supported releases. The project goal is 3 releases a year, one every 4 months, and bugfix releases are made for supported releases only. Releases 4.0.x and 3.9.x are archived. Plan upgrades so the cluster stays on a supported line.
Components to plan for a production Kafka cluster
Give each component an owner, a version and a recovery path.
Brokers
Brokers store partition replicas on local disks and serve clients. Set broker.rack so replicas land in different racks or zones. Set controlled.shutdown.enable=true for graceful stops. With a replication factor of 2 or 3, rolling restarts do not interrupt consumption. Start with at least 100000 file descriptors, and give each broker an owner and a replacement runbook.
KRaft controllers
KRaft controllers form a Raft quorum that holds cluster metadata. Administrators typically choose 3 controllers, which tolerate one failure, or 5, which tolerate two. Tolerating N failures needs 2N + 1 controllers. Run controllers apart from brokers in critical environments. Format every server with the same cluster ID from bin/kafka-storage.sh random-uuid. On Kafka 3.9 and newer, quorum membership can change at runtime.
Kafka Connect
Connect workers run source and sink connectors that move data between Kafka and other systems. Each connector plugin has its own version, license and failure modes. Keep an approved inventory and review new versions before import. Treat connector upgrades like application releases, and route failed records to a dead letter topic with a named owner.
Schema registry
A schema registry stores record schemas and enforces compatibility between producers and consumers. Decide which compatibility rule each subject uses and who approves a change. Run it inside the same boundary as the cluster and back it up. Check the license of the product you choose before adopting it. Treat schema contracts as part of topic ownership.
MirrorMaker 2
MirrorMaker 2 replicates topics, consumer group offsets and ACLs between clusters. It runs on Kafka Connect and ships with Apache Kafka. By default it names replicated topics {source}.{source_topic_name}, so consumers on the target cluster read prefixed names. Decide the direction of replication per topic before you deploy it, and plan failover tests.
Kafka partitions, replication and retention planning
These settings drive disk, network and consumer parallelism. Review them per topic with the owning team.
| Setting | What it controls | Plan for |
|---|---|---|
| Partition count | The limit on parallel consumers within one consumer group. Ordering holds only within a partition. | Adding partitions does not change the partitioning of existing data, so the key-to-partition mapping can shift. Pick a count with headroom before launch. |
| Replication factor and min.insync.replicas | How many copies exist, and how many must confirm a write sent with acks=all. | Three replicas with two in sync required is a common starting point for important topics. A replication factor of 2 or 3 allows rolling restarts without interrupting consumption. |
| Retention | How long or how much data a topic keeps. | Disk is roughly ingest rate times retention times replication factor, plus headroom. |
| Cleanup policy | Delete removes old segments. Compact keeps the latest record per key. | Compacted topics suit state and reference data, and consumers must handle tombstones. Tiered storage does not support compacted topics. |
| Tiered storage | Moves older segments to remote storage while recent data stays on brokers. | It is production-ready since Kafka 3.9 and off by default. Enable it with remote.log.storage.system.enable. Kafka provides no RemoteStorageManager, so you need a plugin for your object store. Per topic, set remote.storage.enable and local.retention.ms or local.retention.bytes. Test reads from old data. |
| Operating system limits | File descriptors, memory map areas and filesystem choice. | Start with at least 100000 file descriptors. Each partition needs at least 2 memory map areas, so 50000 partitions on a broker need 100000 and can exceed a vm.max_map_count default near 65535 and crash the broker. EXT4 and XFS are the most used filesystems, and noatime is recommended on data directories. |
| Rebalancing | Moving replicas between brokers when the cluster changes. | Throttles set with kafka-reassign-partitions.sh --throttle must be removed in a timely manner. Confirm with --verify. |
Kafka ZooKeeper to KRaft migration before the Kafka 4.0 upgrade
Clusters in ZooKeeper mode must migrate to KRaft before they can upgrade to 4.0.x. Kafka 3.9, announced on November 6, 2024, is the final major release with ZooKeeper mode, so it is the bridge. Broker upgrades to 4.0.0 and higher require KRaft mode with software and metadata versions of at least 3.3.x. KRaft clusters older than 3.3.x should first move to 3.9.x.
The 3.9 migration guide requires brokers on software version 3.9.1 with the inter-broker protocol version set to 3.9. KRaft controller node IDs must differ from existing broker IDs. Migration starts with zookeeper.metadata.migration.enable=true on controllers and ZooKeeper-mode brokers, and it begins automatically once the last ZooKeeper-mode broker restarts with the needed configuration. Do not change inter.broker.protocol.version during migration, because that is unsupported and may break the cluster. Reverting to ZooKeeper is possible only while the cluster is still in migration mode.
Check runtimes and clients at the same time. In Kafka 4.0, brokers, Connect and tools require Java 17, while clients and Kafka Streams require at least Java 11. Clients, including Streams and Connect, must be on version 2.1 or higher before the upgrade. Kafka 4.0 also removed the consumer poll(long) method in favor of poll(Duration), dropped Scala 2.12 support and removed KafkaLog4jAppender in favor of the log4j2 appender. An old client in a forgotten service can block the upgrade, so inventory them early.
The 4.0 upgrade restarts brokers one at a time, then finalizes with bin/kafka-features.sh upgrade --release-version 4.0. Metadata downgrade is not supported for this version. Rehearse on a staging cluster with production-like topics, ACLs and load. Set checkpoints with a rollback decision at each. Retire the ZooKeeper ensemble only after the KRaft cluster has run through normal operations and a rolling restart.
Deploy Apache Kafka on virtual machines, Kubernetes or air-gapped sites
Dedicated hosts with local or block storage, managed through configuration management. This gives direct control over disks and network. Kafka documentation says it should run well on any unix system and has been tested on Linux and Solaris, and that Windows is not well supported. XFS needs no changes to its default settings. Rolling restarts, certificate renewal and broker replacement need scripted runbooks. Put KRaft controllers on separate hosts from brokers in critical environments, and spread brokers across racks or zones with broker.rack. Verify file descriptor and vm.max_map_count limits on every host before the first topic is created.
Strimzi describes itself as a way to run Apache Kafka on Kubernetes. It manages topics, users, MirrorMaker and Kafka Connect through custom resources, and it calls itself a CNCF incubating project. This suits teams already running stateful workloads on Kubernetes. Keep Strimzi resources, topics and users in version control so every change is reviewed. Spread broker pods across zones to match the rack settings you would use on virtual machines. Give storage the same attention as on dedicated hosts, because partition replicas live on those volumes. Test node drains and rolling updates on staging with production-like topics before the first production change.
Mirror distributions, images and connector plugins into an internal repository. Docker images are published as apache/kafka from version 3.7.0, so mirror the exact tag you run. Plan the certificate authority, schema registry and monitoring inside the boundary, and review new connector versions before import. Keep the Java 17 runtime for brokers, Connect and tools in the same repository, along with a Java 11 or newer runtime for clients. Record the source and checksum of each imported artifact, and keep a list of which clusters run which version so upgrades stay predictable.
Kafka security: TLS, SASL SCRAM, OAUTHBEARER and ACL authorization setup
Kafka carries data from many systems, so every client needs its own identity and only the access it uses.
| Layer | Approach | Check |
|---|---|---|
| Listeners | Separate listeners for clients, inter-broker traffic and controllers, each with TLS. SSL is disabled by default and adds some performance cost, so size brokers with it on. | No plaintext listener is reachable outside the cluster network. ssl.client.auth=requested is not used, because it gives a false sense of security. |
| Hostname verification | It is on by default since Kafka 2.0.0. Turning it off means setting ssl.endpoint.identification.algorithm to an empty string, which the documentation advises against. | No client or broker configuration sets that property to empty. |
| Authentication | Kafka lists SSL and SASL with GSSAPI (Kerberos), PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 and OAUTHBEARER. Use PLAIN only with SSL and SCRAM only with TLS. SCRAM stores credentials in the metadata log. | Each application has its own principal, and shared credentials are retired. |
| OAUTHBEARER and tokens | The default OAUTHBEARER implementation creates and validates unsecured JSON Web Tokens and suits only non-production installs. Production needs custom callback handlers. Delegation tokens keep delegation.token.secret.key as plain text in server.properties. | No production broker runs the default handlers, and the file holding the secret key is access controlled. |
| Authorization | For KRaft clusters, set authorizer.class.name to org.apache.kafka.metadata.authorizer.StandardAuthorizer. A resource with no matching ACL is open only to super users unless allow.everyone.if.no.acl.found=true. Use --resource-pattern-type prefixed in kafka-acls.sh for team topic namespaces. | A test principal cannot reach topics outside its grant. super.users lists only named operators, separated by semicolons. |
| Data at rest | Use encrypted disks on brokers and on the remote storage that holds tiered data. | Encryption is confirmed on every broker and on every remote storage location. |
| Administration | Restrict admin tools and Connect REST endpoints to operators. | Topic deletion and ACL changes are limited to named roles and logged. |
Kafka MirrorMaker 2 replication and recovery beyond the cluster
Partition replication covers broker and disk failure inside one cluster. It does not help with a deleted topic, a producer writing bad data, or the loss of a site. Decide which topics need a second cluster, which need a copy in long-term storage through a sink connector, and which can be rebuilt from source systems.
MirrorMaker 2 replicates topics, consumer group offsets and ACLs to a target cluster. Per the geo-replication documentation, it runs in dedicated mode with bin/connect-mirror-maker.sh connect-mirror-maker.properties. An active/passive pattern enables one direction only, such as primary->secondary.enabled = true.
Replicated topics carry the source cluster alias as a prefix by default, with a period as the default replication.policy.separator. That affects how consumers find topics after failover. Document how applications switch clusters, where they resume and how you fail back. Keep topic configurations, ACLs, schemas, connector configurations and Strimzi resources in version control as well.
Kafka operating ownership
The platform team runs the cluster. Topic owners are responsible for what flows through it. Write these duties down before the first production topic exists.
Platform
- Monitor under-replicated partitions, controller health, disk and request latency.
- Run rolling restarts, broker replacement and upgrades.
- Rebalance partitions when brokers change, and remove throttles afterward.
Topic owners
- Request topics with partitions, retention and schema rules set.
- Watch consumer lag and handle poison messages.
- Retire unused topics and consumer groups.
Security
- Issue principals per application and review ACLs.
- Rotate certificates and SASL credentials before expiry.
- Review logs for topic deletion and permission changes.
Integration
- Operate Connect workers and approve connector versions.
- Route failed records to dead letter topics with an owner.
- Run MirrorMaker 2 and test cross-site failover.
Kafka deployment questions
Do we still need ZooKeeper for Apache Kafka?
No, not for new clusters. Kafka 4.0 supports only KRaft mode and ZooKeeper mode has been removed. A ZooKeeper-based cluster must migrate to KRaft before it can upgrade to 4.0.x, and Kafka 3.9 is the bridge for that migration. Rehearse it first, because reverting is no longer possible after the migration is finalized.
What is the right Kafka KRaft controller quorum size?
Three or five. Kafka documentation says administrators typically choose 3 or 5 controllers, which tolerate one or two failures. Tolerating N failures needs 2N + 1 controllers, so a fourth controller adds cost without tolerating more failures than three. Choose five only when the environment must survive two simultaneous controller failures.
Should we use Kafka combined mode or dedicated controllers?
Use dedicated controllers for production. Combined mode runs brokers and controllers on the same nodes. Kafka documentation says it suits development and is not recommended in critical deployment environments. Dedicated controller nodes also keep the metadata quorum size separate from the broker count.
How many partitions should a topic have?
Enough for the consumer parallelism the topic needs over its life, with some headroom. Adding partitions later shifts the key-to-partition mapping. Very high counts add open files, memory map areas and recovery time. Size from measured throughput per consumer, then set retention from ingest rate, retention time and replication factor.
How does Kafka tiered storage work and what does it need?
It moves older segments to remote storage while recent data stays on brokers. It is production-ready since Kafka 3.9, off by default, and enabled at the broker with remote.log.storage.system.enable. Kafka provides no RemoteStorageManager, so you need a plugin for your object store. Compacted topics are not supported, so test reads from old data.
How do we set up SASL/SCRAM with TLS?
Put TLS under SASL. Kafka documentation says SSL is disabled by default, SASL/PLAIN should be used only with SSL and SCRAM only with TLS. SCRAM stores credentials in the metadata log with SHA-256 or SHA-512 and a minimum iteration count of 4096. Give each application its own principal, and avoid ssl.client.auth=requested.
Can we run the apache/kafka Docker image in production?
Docker images are published as apache/kafka from version 3.7.0. The GraalVM-based apache/kafka-native image, available from 3.8.0, is labeled experimental and not recommended for production. Pin image tags, and mirror them to an internal repository for air-gapped sites. Check which Kafka version each tag carries against your upgrade plan.
Scope and handover
DeployOpen plans the cluster layout and topic conventions with you and deploys Kafka in KRaft mode on virtual machines or Kubernetes. It configures TLS and ACLs and connects client authentication to your identity provider where it fits. It sets up monitoring and cross-site replication, migrates ZooKeeper-based clusters, carries out upgrades and documents runbooks. Ongoing support is available if you want it.
Scope depends on clusters, environments, connectors, client teams and whether a ZooKeeper migration is involved. A single cluster with a few client teams needs a different plan from several environments with cross-site replication and a migration from ZooKeeper.
Handover includes the cluster and controller layout, listener and certificate design, principal and ACL model, topic register with owners and retention, approved connectors and client settings, failover runbooks with the latest test result, alert routes and the version plan.
Sources and further reading
- Apache Kafka 4.0 upgrade notes ↗
- Apache Kafka 3.9.0 release announcement ↗
- KRaft operations documentation ↗
- Strimzi project ↗
- Kafka 3.9 KRaft docs ↗
- Apache Kafka downloads ↗
- Apache Kafka GitHub ↗
- Kafka 4.0 authorization docs ↗
- Kafka 4.0 SSL docs ↗
- Kafka 4.0 SASL docs ↗
- Kafka 4.0 security overview ↗
- Kafka 4.0 Docker docs ↗
- Kafka 4.0 geo-replication docs ↗
- Kafka 4.0 tiered storage docs ↗

