Running Kafka in production
36 questions in 8 subtopics.
Running Kafka in production is about keeping a shared, stateful system healthy while traffic grows and teams change it every day. Operators size clusters and partition counts, watch the metrics that show trouble early, secure every connection, keep tenants from hurting each other, replicate data between clusters, upgrade without downtime and recover when hardware, people or whole regions fail. Costs matter as much as uptime, especially on managed services with many billing dimensions. The questions in this topic cover capacity planning, monitoring, TLS, SASL and ACLs, quotas and multi-tenancy, MirrorMaker 2, upgrades and the move to KRaft, disaster recovery and the economics of managed Kafka. They range from on-call commands and configuration to platform design and long-term decisions on topology, contracts and investment.
Capacity planning and partition counts
Capacity planning turns produce rates, retention, replication and consumer fan-out into disk, network, CPU and partition budgets per broker. Understand how to estimate each one with headroom, why new brokers do not take load on their own, how skew appears even with balanced partition counts, and when to add brokers versus split clusters.
A new topic will receive 5 MB/s of compressed data at peak and about 3 MB/s on average, with retention.ms set to 7 days and replication factor 3, on a 6-broker cluster.
In a 9-broker cluster, broker 4's data disk is at 91 percent while the others sit between 52 and 60 percent, and broker 4 also has the highest bytes-in rate. Partition counts per broker are almost equal.
What do you check, how do you relieve broker 4 now, and how do you prevent it from happening again?A 6-broker cluster runs at 75 percent disk and 70 percent network at peak. You add 3 brokers, but a day later they hold almost no partitions and the old brokers are as busy as before.
Explain why, and describe how you move load to the new brokers safely while production traffic continues.You run a shared Kafka platform for 120 teams: 4 clusters, 60 brokers, 45,000 partition replicas, with traffic growing about 6 percent a month. Two outages last year came from disks filling up and from a cluster with too many partitions per broker.
Design the capacity model and process: what you measure, which headroom rules you set, and when you add brokers or split clusters.Your company has grown from one Kafka cluster to 14, created over the years by different departments: some huge and shared, some tiny and used by one team. Costs, upgrade effort and incident blast radius are all high.
As head of the streaming platform, what cluster topology strategy do you set for the next five years, and how do you get there?Monitoring and key metrics
Kafka exposes thousands of metrics through JMX, but a few reveal most problems: under-replicated and offline partitions, controller health, request latency, idle percentages, disk usage and consumer lag. Understand what each metric means, which values should page someone, how to collect metrics without overloading the monitoring system, and what broker metrics cannot see.
You take over on-call for a Kafka 4.x cluster that has no alerting.
Name the broker and controller metrics you would alert on first, what each one means, and which values should page someone.At 02:00 an alert reports that /var/kafka/data on four of nine brokers is 88 percent full and rising about 2 percent an hour. Yesterday a team released a change that doubled its message size.
Which commands and metrics do you use to find what is growing, what do you do in the next hour, and what must you not do?On a broker with four JBOD data directories, one disk starts returning I/O errors.
The broker log showsKafkaStorageException and a message about stopping serving replicas in dir /data3, OfflineLogDirectoryCount becomes 1, and about 300 partitions report under-replication, but the broker process keeps running. Explain what Kafka did, the impact on clients, and how you recover.A large shared Kafka cluster needs monitoring that serves two audiences: the platform team that runs it and the application teams that depend on it.
Design the monitoring for a 30-broker Kafka 4.x cluster serving 80 applications: what you collect and how, how you watch clients and consumer lag, how you detect problems that broker metrics miss, and what the dashboards show to the platform team versus the application teams.The Prometheus stack that scrapes 40 brokers keeps falling over: the JMX exporter emits per-partition and per-client-id metrics, about 6 million time series, scrapes take 90 seconds and dashboards time out. Teams rely on some per-topic graphs.
How do you restructure Kafka metrics collection, and which rules do you set across the platform?Security with TLS, SASL and ACLs
Kafka secures traffic with listeners that combine TLS encryption with SASL authentication, and authorizes actions with ACLs on topics, groups and transactional ids. Understand how listeners and advertised addresses work, which SASL mechanism suits which client, how to grant least privilege, and how to rotate certificates and credentials without downtime.
A Kafka 4.x cluster must accept connections from applications inside the data centre, from a partner over the internet, and between brokers and controllers.
Explain listeners, advertised listeners,listener.security.protocol.map and the four security protocols, and say which SASL mechanism you would choose for which kind of client.Most production Kafka clusters accept only encrypted and authenticated connections, and every Spring Boot client has to be configured to match.
Show the Spring Boot configuration for a service that connects to Kafka overSASL_SSL with SCRAM-SHA-512, trusting the company's private CA, without committing the password to Git. Which errors appear if the truststore or the credentials are wrong?A service with principal User:billing-svc consumes orders with group id billing and transactionally produces to invoices with transactional ids starting billing-tx-. The cluster runs the KRaft StandardAuthorizer with allow.everyone.if.no.acl.found=false.
kafka-acls.sh commands that give it least privilege, and explain each permission.Broker certificates for a Kafka cluster expire in 10 days.
In a test cluster a team replaced one broker's keystore with a certificate signed by a new intermediate CA and restarted it; afterwards that broker's followers dropped out of the ISR, and clients logged SSLHandshakeException: PKIX path building failed and No subject alternative names matching. Explain both errors and plan a certificate and CA rotation without downtime in production.A shared Kafka platform that carries personal and payment data for many teams needs a single security model that still lets teams move quickly.
Design the security model for a shared Kafka platform used by 150 services owned by 40 teams, including topics with personal and payment data. Cover identity, authorization, encryption, secrets, auditing, and how teams request access without the platform team becoming a bottleneck.Quotas and multi-tenancy
On a shared cluster, one client can starve others of network, request time or partitions. Kafka quotas limit produce and fetch bandwidth and request load per user or client id by throttling rather than rejecting requests. Understand how throttling shows up in client metrics, how to set defaults and overrides, and what isolation quotas cannot provide.
On a shared cluster a batch service, report-loader, produces bursts of 400 MB/s and slows everyone else.
Explain the quota types Kafka offers and how a throttled client behaves, and write the commands that limit report-loader (SASL user report-loader) to 50 MB/s of produce traffic per broker and set a default for all other users.A latency-sensitive checkout producer sees p99 send latency rise from 15 ms to 900 ms every evening. Broker request metrics look healthy, but the producer's produce-throttle-time-avg is about 700 ms during those hours.
The checkout service shares the SASL user web-apps with 30 other services, and that user has producer_byte_rate set to 20 MB/s. Explain what is happening and how you fix it.You are designing tenancy for a shared Kafka platform where 60 teams create topics, some produce terabytes a day, and one team once created 5,000 partitions by mistake.
Design the isolation model: namespaces, quotas, limits on partitions and topic configs, protection from noisy neighbours, and when a tenant gets its own cluster.Kafka platform costs have tripled in two years, and teams treat the shared cluster as free: idle topics with 30-day retention, consumer groups nobody owns, uncompressed producers. Finance wants costs allocated to teams.
How would you design showback or chargeback for Kafka, and how do you use it to change behaviour without discouraging use of the platform?Multi-cluster replication and MirrorMaker 2
MirrorMaker 2 copies topics, configurations and consumer group offsets between clusters using Kafka Connect. Understand its connectors and internal topics, how remote topics are named, how offsets are translated and synchronised, why failover is never exactly at the last committed record, and how active-active topologies avoid replication loops.
MirrorMaker 2 is the open-source tool for copying topics and consumer group positions from one Kafka cluster to another.
MirrorMaker 2 configuration for dedicated mode that replicates all topics starting with orders from a cluster called primary to a cluster called dr, including consumer group offsets. Name the connectors it runs and the internal topics it creates, and say what the replicated topic is called in dr by default.In a DR test, consumer group billing is stopped in the primary cluster and started against primary.orders in the DR cluster with auto.offset.reset=earliest. MirrorMaker 2 runs with sync.group.offsets.enabled=true.
Two regions each run a Kafka cluster and an order service that writes locally. The business wants both regions active, with each region's consumers seeing orders from both.
Design theMirrorMaker 2 topology: topic naming, how consumers subscribe, how loops are avoided, what ordering and conflict guarantees hold, and how failure of one region is handled.Your company runs Kafka in three regions and replicates between them with self-managed MirrorMaker 2 clusters that need frequent attention.
Upgrades and migration to KRaft
Kafka is upgraded broker by broker, and feature versions such as metadata.version are raised only after every node runs the new release. Clusters still on ZooKeeper must migrate to KRaft through a 3.x bridge release before they can run Kafka 4.x. Understand the phases, the safe restart checks and where rollback stops being possible.
You must upgrade a KRaft cluster with 3 controllers and 9 brokers from Kafka 4.0 to 4.1.
Describe the rolling upgrade, explain whatmetadata.version and the other feature versions are, and say when you finalize them and why you wait.During a rolling restart of brokers for a config change, an automation script restarts the next broker as soon as the previous broker's process is up.
Halfway through, producers using acks=all on topics withmin.insync.replicas=2 log NotEnoughReplicasException, and two partitions briefly have no leader. Explain what went wrong and describe the safe restart procedure.A 12-broker cluster still runs Kafka 3.7 with ZooKeeper, and it must reach Kafka 4.x.
Describe the hands-on path to KRaft: which version you go through, the phases of the migration, what you watch in each phase, and up to which point you can roll back.Your company is moving a 24-broker Kafka cluster that serves 200 services from virtual machines to Kubernetes with an operator, and into a new network. Downtime must be near zero, and teams cannot all change client configs on the same day.
Compare growing the existing cluster onto the new platform with building a new cluster and replicating to it, and plan the migration.Disaster recovery and data loss scenarios
Replication protects against broker and disk failure, but not against deleted topics, bad data, operator mistakes or the loss of a whole region. Understand which failures each mechanism covers, how to rebuild a lost broker safely, how to replicate to another region with clear recovery targets, and how to prove a recovery plan actually works.
A manager says: our Kafka topics have replication factor 3, so we do not need backups.
Explain what replication protects against and what it does not, and which options exist to recover Kafka data after a logical failure.A broker in a 12-broker KRaft cluster ran on a cloud instance with local NVMe disks, and the provider retired the instance, taking 6 TB of replica data with it. All topics have replication factor 3.
Describe how you replace the broker, how long re-replication may take, how you keep it from hurting production traffic, and what risk exists while it runs.An engineer ran kafka-topics.sh --delete on the production topic payments-events (48 partitions, 7 days of data) instead of a test topic. Within a minute, producers still writing to it had recreated the topic with 1 partition and replication factor 1.
An event platform that runs in a single cloud region must be able to come back after losing that whole region, within business limits on downtime and data loss.
Design disaster recovery for an event platform that runs in one cloud region: two Kafka clusters, 300 topics, a schema registry, Kafka Connect pipelines and Kafka Streams applications. The requirement is to resume in a second region within one hour and lose at most five minutes of events. What do you replicate, how do clients fail over, and how do you prove it works?After a cloud region outage that took the event platform down for six hours, the board asks for zero data loss and zero downtime next time.
Running a second region fully active would roughly double platform cost. How do you lead the decision on DR targets and investment?Managed Kafka and cost
Managed Kafka services run brokers, upgrades and much of the operational work, but bill along several dimensions such as capacity units, storage, partitions and data transfer. Understand what remains your responsibility, which usage patterns drive cost, how to migrate onto a managed service, and how to weigh vendor features against lock-in.
Your team is deciding whether to use a managed Kafka service instead of running Kafka on virtual machines.
Explain what a managed service typically takes over, what stays your responsibility, and which pricing dimensions you must understand before comparing costs.Your managed Kafka bill doubled in six months while produced bytes grew only 20 percent. The bill is split into capacity units, storage, partitions and data transfer.
Walk through how you find the causes and which changes you would make.Your company will move 150 services from a self-managed Kafka cluster in its data centre to a managed Kafka service in the cloud, which uses its own IAM-based authentication and private networking.
Design the migration: connectivity, security, data replication, client changes and the cut-over order.Your company is negotiating a three-year committed-spend contract with a managed Kafka vendor. Teams have started to use vendor-only features: proprietary connectors, the vendor's stream-processing SQL, and its cluster-to-cluster linking.
The CFO wants the discount; the CTO worries about lock-in. How do you shape the decision and the contract?