1. Basic questions : Kafka fundamentals.
    1. Kafka Basics
    2. Kafka Components
    3. Kafka Internals
    4. Kafka Configuration and Management
  2. Medium-level questions : Kafka’s architecture, configuration, and best practices, deeper understanding of Kafka beyond the basics.
    1. Kafka Architecture and Internals
    2. Kafka Configuration and Tuning
    3. Kafka Operations
    4. Kafka Stream Processing
  3. Advanced Kafka questions: deep technical knowledge, covering Kafka’s architecture, configuration nuances, optimization, and troubleshooting.
    1. Kafka Deep Architecture
    2. Kafka Performance Optimization
    3. Kafka Reliability and Fault Tolerance
    4. Kafka Streams and Complex Use Cases

Basic questions : Kafka fundamentals.

Kafka Basics

  1. What is Kafka?
    Answer: Kafka is a distributed streaming platform used for building real-time data pipelines and streaming applications.
  2. Explain the difference between Kafka and traditional message brokers.
    Answer: Kafka is designed for high-throughput and fault tolerance with persistent logs, while traditional brokers focus on message queuing and are typically limited to lower-throughput applications.
  3. What is a Kafka topic?
    Answer: A topic is a category or feed name to which records are published; it’s where data is stored in Kafka.
  4. What is a Kafka partition?
    Answer: Partitions are subsets of a topic, allowing parallel processing and scaling. Each partition is an ordered, immutable sequence of records.
  5. What is a Kafka broker?
    Answer: A broker is a Kafka server that stores and serves data to consumers and producers, managing data for a part of or all topics.

Kafka Components

  1. What is the role of a Kafka producer?
    Answer: A producer sends data to Kafka topics, publishing messages to specific topics within a Kafka cluster.
  2. What is a Kafka consumer?
    Answer: A consumer reads data from Kafka topics, typically forming consumer groups to consume messages across partitions.
  3. Explain the role of the Kafka Consumer Group.
    Answer: Consumer groups allow consumers to share the load of reading messages from a topic’s partitions, ensuring each partition’s messages are only read by one consumer in the group.
  4. What is ZooKeeper’s role in Kafka?
    Answer: ZooKeeper manages and coordinates Kafka brokers, tracks configurations, and handles leader election for partitions.
  5. What is a Kafka Cluster?
    Answer: A Kafka cluster is a collection of brokers working together to provide high availability and fault tolerance.

Kafka Internals

  1. What is Kafka’s offset?
    Answer: An offset is a unique identifier for each record within a partition, used to keep track of consumer reads.
  2. Explain replication in Kafka.
    Answer: Replication is copying data across multiple brokers to ensure reliability and fault tolerance; each partition has a set of replicas.
  3. What is ISR in Kafka?
    Answer: ISR (In-Sync Replica) is a list of replicas that are fully synced with the leader for a particular partition.
  4. How does Kafka ensure data durability?
    Answer: Kafka writes data to disk and replicates it across brokers, ensuring persistence and resilience.
  5. What happens if a Kafka consumer crashes?
    Answer: The consumer’s offset is tracked, allowing another consumer in the same group to resume reading from the last committed offset.

Kafka Configuration and Management

  1. What is log compaction in Kafka?
    Answer: Log compaction removes old records with the same key, retaining only the latest version, to reclaim storage and reduce log size.
  2. How does Kafka handle backpressure?
    Answer: Kafka uses a pull-based approach, where consumers fetch messages at their own rate, avoiding overloading consumers.
  3. What is the purpose of Kafka Streams?
    Answer: Kafka Streams is a library for building real-time stream processing applications directly within Kafka.
  4. How can you achieve exactly-once processing in Kafka?
    Answer: Use Kafka’s exactly-once semantics, supported by transactions and idempotent producers and consumers.
  5. What is Kafka Connect?
    Answer: Kafka Connect is a framework for streaming data between Kafka and external systems, simplifying data integration.

These questions cover foundational concepts and should give a recruiter a quick gauge of a candidate’s Kafka knowledge.


Medium-level questions : Kafka’s architecture, configuration, and best practices, deeper understanding of Kafka beyond the basics.

Kafka Architecture and Internals

  1. Explain the concept of leader and follower replicas in Kafka.
    Answer: In Kafka, each partition has a leader replica responsible for all reads and writes. Follower replicas replicate the leader’s data for redundancy and take over if the leader fails.
  2. What is the role of a Kafka controller?
    Answer: The controller is a broker responsible for managing partition leaders, replica assignments, and performing administrative tasks like detecting broker failures.
  3. How does Kafka handle failover for partitions?
    Answer: If a leader replica fails, Kafka’s controller reassigns leadership to an in-sync replica (ISR), ensuring high availability.
  4. What is the difference between consumer offset commit strategies: ‘auto-commit’ vs. ‘manual commit’?
    Answer: Auto-commit automatically commits offsets after a set interval, while manual commit provides more control, allowing commits only after processing messages successfully.
  5. What is idempotence in Kafka, and how does it work?
    Answer: Idempotence ensures that Kafka producers write each message exactly once, preventing duplicates. This is achieved through unique producer IDs and sequence numbers.

Kafka Configuration and Tuning

  1. How can you configure Kafka for high availability?
    Answer: Use multiple brokers, replication factor >1, and distribute replicas across brokers. Configure ZooKeeper appropriately for managing the cluster.
  2. What is the significance of min.insync.replicas in Kafka?
    Answer: This setting defines the minimum number of ISR replicas that must acknowledge a write for it to be successful, ensuring stronger data durability.
  3. How does Kafka achieve fault tolerance for messages?
    Answer: By replicating partitions across multiple brokers and storing messages to disk, Kafka can recover data even if brokers fail.
  4. Explain the purpose of Kafka’s retention policy settings.
    Answer: Retention policies control how long Kafka retains messages, which can be set by time or size limits, and affect storage management.
  5. How would you optimize Kafka for low latency?
    Answer: Tune settings like linger.ms, batch.size, and fetch.min.bytes to reduce batching delays and network latency. Use SSDs and optimize OS/network settings.

Kafka Operations

  1. How can you monitor Kafka’s health and performance?
    Answer: Use tools like JMX, Kafka Manager, or Prometheus to monitor metrics like broker throughput, request latency, ISR counts, and consumer lag.
  2. What is consumer lag, and why is it important?
    Answer: Consumer lag is the difference between the latest offset and the consumer’s committed offset. It indicates whether consumers are keeping up with the data production rate.
  3. Explain Kafka compaction and its use case.
    Answer: Compaction removes older records with the same key, keeping only the latest version. It’s used for topics that require a record of the latest state, like log data.
  4. How would you expand a Kafka cluster?
    Answer: Add new brokers, rebalance partitions, and, if necessary, reconfigure topics with higher replication or partition counts to leverage new resources.
  5. What happens if acks=all is set but fewer replicas are available?
    Answer: If fewer than min.insync.replicas are available, the producer receives an error, ensuring durability but risking message loss if not handled.

Kafka Stream Processing

  1. What is the difference between Kafka Streams and Kafka Connect?
    Answer: Kafka Streams is for processing and transforming data within Kafka, while Kafka Connect handles data ingestion and extraction from external systems.
  2. How does Kafka handle message ordering across partitions?
    Answer: Within a partition, messages are strictly ordered by offset. Across multiple partitions, there’s no global ordering.
  3. Explain the purpose of stream joins in Kafka Streams.
    Answer: Stream joins allow you to combine data from different Kafka topics or streams based on key, enabling enriched, real-time data processing.
  4. How does Kafka manage transactions and exactly-once processing?
    Answer: Kafka uses producer transactions, which mark groups of messages as atomic, and stores offsets as part of the transaction, ensuring exactly-once semantics.
  5. What’s the purpose of windowing in Kafka Streams?
    Answer: Windowing enables time-based aggregation, allowing operations like counting or summing events within a time window, useful for event stream processing.

These questions offer a balance of technical depth and practical application, giving insight into the candidate’s ability to work effectively with Kafka in real-world scenarios.


Advanced Kafka questions: deep technical knowledge, covering Kafka’s architecture, configuration nuances, optimization, and troubleshooting.

Kafka Deep Architecture

  1. Explain how Kafka ensures data consistency and durability in a distributed environment.
    Answer: Kafka achieves data consistency and durability using a combination of replication, acknowledgments (acks=all), and In-Sync Replicas (ISR). Each message is replicated to multiple brokers, and only committed when acknowledged by all in-sync replicas.
  2. How does Kafka handle data rebalancing when a new broker is added to the cluster?
    Answer: Kafka reassigns partitions across the cluster using the preferred replica leader election or custom partition reassignment tools, redistributing partitions to balance load across brokers.
  3. What is a Kafka compaction strategy, and when would you use it over time-based retention?
    Answer: Kafka compaction keeps only the latest record for each unique key, discarding older duplicates. It’s used when maintaining the latest state is essential, such as for log-based change data capture.
  4. What are Kafka Connectors and Tasks in Kafka Connect?
    Answer: A connector defines how to interact with external systems, while tasks are the execution units that parallelize the workload, allowing connectors to scale horizontally.
  5. How does Kafka’s log segment deletion process work?
    Answer: Kafka splits logs into segments, deleting segments that exceed the defined retention policy (time or size) in the background, which reclaims storage without affecting ongoing operations.

Kafka Performance Optimization

  1. How would you optimize producer throughput in Kafka?
    Answer: Adjust batch.size, linger.ms, and compression.type (e.g., using snappy). Tuning these settings helps maximize message batching and reduces network overhead.
  2. What’s the purpose of the linger.ms parameter in a Kafka producer?
    Answer: linger.ms adds a delay to message batching, allowing more messages to accumulate before sending, which can improve throughput by reducing the number of requests.
  3. How can you prevent unbounded growth of consumer lag?
    Answer: Ensure consumers keep up by scaling the number of consumers, increasing partitions, or optimizing consumer processing logic. Monitor lag and adjust if it grows continuously.
  4. What’s the difference between idempotent and transactional producers?
    Answer: Idempotent producers ensure exactly-once delivery by eliminating duplicates at the partition level. Transactional producers provide exactly-once semantics across multiple partitions or topics by using atomic write operations.
  5. How do you tune fetch.max.bytes and fetch.min.bytes for optimal consumer performance?
    Answer: Set fetch.max.bytes high enough to avoid excessive requests, while fetch.min.bytes should match the producer’s batch size to reduce network calls and improve latency.

Kafka Reliability and Fault Tolerance

  1. How does Kafka handle leader election for partitions?
    Answer: The Kafka controller coordinates leader elections based on the ISR. When a leader fails, it elects the next ISR member as the leader.
  2. What happens if a partition leader goes down and no ISR is available?
    Answer: If no ISR is available, the partition remains unavailable until a replica can catch up and be promoted to the leader, potentially causing downtime.
  3. How does Kafka’s unclean.leader.election configuration affect availability?
    Answer: Enabling unclean leader election allows an out-of-sync replica to become leader if no in-sync replicas are available, improving availability but risking data loss.
  4. Describe how Kafka achieves exactly-once semantics (EOS) with transactions.
    Answer: Kafka uses a combination of idempotent producers, atomic commit of offsets, and transaction IDs to ensure that messages are processed exactly once without duplicates.
  5. How does Kafka handle data loss and recovery after a broker failure?
    Answer: Kafka recovers by electing an ISR replica as the new leader and replicating lost data from remaining replicas if configured with replication factor >1 and sufficient ISRs.

Kafka Streams and Complex Use Cases

  1. What are KTables and KStreams in Kafka Streams? How are they different?
    Answer: KTables represent state stores, holding the latest values for each key (similar to tables in a database), while KStreams are continuous, unbounded streams of records.
  2. Explain the purpose of state stores in Kafka Streams and how they work.
    Answer: State stores persist intermediate states in Kafka Streams applications, allowing for operations like aggregations and joins. They can be backed by RocksDB or in-memory.
  3. How would you handle backpressure in a Kafka Streams application?
    Answer: Use max.poll.records, control buffer sizes, and monitor lag. Increase the number of stream threads or partition counts to distribute load, avoiding consumer lag buildup.
  4. Describe the watermarking concept in Kafka Streams and how it affects windowed operations.
    Answer: Watermarking is a way of managing late-arriving data in time-based windowing. It sets a threshold for processing late data, ensuring windows close at predictable intervals.
  5. How can you implement real-time data enrichment using Kafka and Kafka Streams?
    Answer: Use Kafka Streams join operations, like stream-to-table joins, to merge streams with reference data stored in a KTable, enriching records as they pass through.

These advanced questions explore complex configurations, high-performance tuning, and advanced stream processing capabilities in Kafka, giving a strong assessment of a candidate’s deep technical expertise.

Quote of the week

“Success is not final, failure is not fatal: It is the courage to continue that counts.”

~ Winston Churchill