Scrivio Interview library

Running Kafka in production

36 questions in 8 subtopics.

About this topic

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.

ScenarioFoundations6 min read

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.

Estimate the disk it needs per broker, state your assumptions, and explain what else you must leave room for.
DebuggingIntermediate6 min read

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?
ScenarioIntermediate6 min read

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.
DesignAdvanced7 min read

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.
LeadershipPrincipal7 min read

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.

ConceptFoundations7 min read

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.
DebuggingFoundations7 min read

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?
DebuggingIntermediate7 min read

On a broker with four JBOD data directories, one disk starts returning I/O errors.

The broker log shows KafkaStorageException 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.
DesignIntermediate6 min read

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.
ScenarioAdvanced7 min read

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.

ConceptFoundations6 min read

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.
CodingFoundations6 min read

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 over SASL_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?
CodingIntermediate7 min read

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.

Write the kafka-acls.sh commands that give it least privilege, and explain each permission.
DebuggingIntermediate7 min read

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.
DesignAdvanced6 min read

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.

CodingFoundations6 min read

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.
DebuggingIntermediate7 min read

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.
DesignAdvanced6 min read

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.
LeadershipPrincipal6 min read

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.

CodingFoundations6 min read

MirrorMaker 2 is the open-source tool for copying topics and consumer group positions from one Kafka cluster to another.

Write a minimal 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.
DebuggingIntermediate7 min read

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.

The group reprocesses about 40 minutes of events instead of the few seconds the team expected, and another group that had been started in DR a day earlier for a dry run got no offset sync at all. Explain both and how to make failover tighter.
DesignAdvanced6 min read

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 the MirrorMaker 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.
LeadershipPrincipal6 min read

Your company runs Kafka in three regions and replicates between them with self-managed MirrorMaker 2 clusters that need frequent attention.

A vendor offers offset-preserving replication between its managed clusters, and some teams propose writing events to two regions directly from their applications. As the platform's technical leader, how do you choose the long-term cross-region replication approach?

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.

ConceptFoundations7 min read

You must upgrade a KRaft cluster with 3 controllers and 9 brokers from Kafka 4.0 to 4.1.

Describe the rolling upgrade, explain what metadata.version and the other feature versions are, and say when you finalize them and why you wait.
DebuggingIntermediate6 min read

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 with min.insync.replicas=2 log NotEnoughReplicasException, and two partitions briefly have no leader. Explain what went wrong and describe the safe restart procedure.
ScenarioIntermediate6 min read

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.
ScenarioAdvanced6 min read

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.

ConceptFoundations7 min read

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.
ScenarioIntermediate7 min read

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.
ScenarioIntermediate6 min read

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.

What happened inside Kafka, what can you recover, and what changes prevent a repeat?
DesignAdvanced6 min read

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?
LeadershipPrincipal6 min read

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.

ConceptFoundations6 min read

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.
ScenarioIntermediate6 min read

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.
DesignAdvanced6 min read

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.
LeadershipPrincipal5 min read

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?