LearnThatStack Ace your next interview
Backend Development

Apache Kafka.

Start free Change topic Change
Practice · Questions

All questions

Showing of 41
Beginner 5
01

Explain the core components of Kafka architecture.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Kafka's architecture has producers that write events, brokers that store them and consumers that read them, while controllers manage the cluster's metadata. Kafka also calls an event a record.

  • Producers are applications that publish, or write, events and choose each event's partition.
  • Consumers are applications that subscribe to topics and read events in order within each partition.
  • Brokers are the Kafka servers that store events on disk and serve client requests.
  • Topics are named feeds, such as payments, that producers publish to.
  • Partitions split each topic into ordered logs across brokers, for parallelism and scalability.
  • Controllers keep the metadata, such as which topics exist and where each partition lives.

Older clusters kept this metadata in ZooKeeper, a separate coordination service. Since Kafka 4.0, clusters run only in KRaft mode. The controllers agree on each change through Raft, a protocol in which a majority must accept it.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is a Kafka topic and how does partitioning work?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

A topic is a named stream that producers send messages to and consumers read from. Kafka calls each message a record, and divides each topic into partitions, which are ordered logs spread across brokers.

The producer picks each record's partition. A keyed record goes to a partition chosen by hashing its key, so one key maps to one partition while the partition count is unchanged. A record without a key goes to a sticky partition, which changes once at least batch.size bytes have gone to it.

Partitions bring these benefits:

  • Several consumers can read a topic in parallel.
  • Records spread across brokers.
  • Order holds within each partition, though not across partitions.
  • A topic scales out as you add partitions and brokers.

For example, a topic user-events with 3 partitions stores records in partitions 0, 1 and 2.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What was ZooKeeper's role in Kafka, and what replaced it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

ZooKeeper was the external service that held Kafka's cluster metadata, until Kafka 4.0 removed it in favour of KRaft mode.

In ZooKeeper mode it handled:

  • Broker discovery and health monitoring
  • Topic, partition and configuration metadata
  • Electing the controller broker, which then chose partition leaders
  • Consumer group coordination for the legacy consumer

In KRaft mode, a few controller nodes keep this metadata in a log inside Kafka. They agree on each change with Raft, a consensus protocol where a majority must accept it. Operators run one system instead of two. A Kafka cluster still in ZooKeeper mode must migrate to KRaft before upgrading to 4.x.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What are Kafka Headers and when would you use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Kafka headers are optional key-value pairs of metadata attached to each record, next to its key and value. Use them for information about a message that should not live inside the payload.

Common uses:

  • Routing, where consumers route messages based on a header.
  • Tracing, where a correlation ID follows a request across services.
  • Security context, such as an authentication token.
  • Content metadata, such as the MIME type or encoding.
  • Source identification, naming the origin system.
// Producer adding headers
ProducerRecord<String, String> record = new ProducerRecord<>(
    "my-topic", "key", "value");
record.headers().add("correlation-id", "12345".getBytes());
record.headers().add("source-system", "order-service".getBytes());

Headers do not affect partitioning, and they add metadata without changing the message payload.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What are Kafka's log retention and cleanup policies?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Kafka has two cleanup policies, set per topic with cleanup.policy: delete, the default, and compact.

Delete removes whole old log segments once they pass a time or size limit:

  • log.retention.hours=168 keeps data for 7 days by default.
  • log.retention.bytes=-1 sets no size limit by default, and any limit applies per partition.
  • log.segment.bytes=1073741824 sets the segment size to 1 GB.

Compact keeps the latest value for each key, which suits changelog topics. A background process compacts the log and keeps the order of records within each partition.

Both can run together.

cleanup.policy=compact,delete
# Both compaction and time-based deletion

Track log size and compaction metrics to make sure cleanup keeps up.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

Intermediate 26
06

What is the difference between Kafka and traditional message queues?

Part of Pro Visual
07

Explain Kafka producers and their key configurations.

Part of Pro
08

How do Kafka consumers work and what is a consumer group?

Part of Pro Visual
09

What is offset management in Kafka?

Part of Pro
10

Explain Kafka's replication mechanism.

Part of Pro Visual
11

What are Kafka's delivery semantics?

Part of Pro
12

What is Kafka Streams and when would you use it?

Part of Pro
13

Explain Kafka Connect and its purpose.

Part of Pro
14

How does Kafka ensure high throughput?

Part of Pro Visual
15

Explain Kafka's log compaction feature.

Part of Pro Visual
16

What is the difference between poll and fetch in a Kafka consumer?

Part of Pro Visual
17

How do you handle schema evolution in Kafka?

Part of Pro
18

Explain Kafka's security features.

Part of Pro
19

What is the purpose of the __consumer_offsets topic?

Part of Pro
20

How do you monitor Kafka cluster performance?

Part of Pro
21

What causes consumer lag and how do you address it?

Part of Pro Visual
22

What is the difference between Kafka and Apache Pulsar?

Part of Pro
23

What is Kafka MirrorMaker and its use cases?

Part of Pro
24

What is Kafka's approach to backward compatibility?

Part of Pro
25

Explain Kafka's compression and its trade-offs.

Part of Pro
26

What is the difference between at-rest and in-transit encryption in Kafka?

Part of Pro
27

How do you handle duplicate messages in Kafka?

Part of Pro Visual
28

What triggers a consumer group rebalance, and how do the rebalance protocols differ?

Part of Pro Visual
29

How do you choose the number of partitions for a Kafka topic?

Part of Pro
30

How do you handle poison messages in a Kafka consumer?

Part of Pro Visual
31

What is tiered storage in Kafka, and what problem does it solve?

Part of Pro Visual
Expert 10
32

What are Kafka's consistency guarantees?

Part of Pro
33

What are Kafka transactions and how do they work?

Part of Pro Visual
34

Explain Kafka's ISR (In-Sync Replica) mechanism.

Part of Pro Visual
35

How do you tune Kafka for maximum performance?

Part of Pro
36

Explain Kafka's exactly-once semantics implementation.

Part of Pro
37

How does Kafka handle network partitions and split-brain scenarios?

Part of Pro Visual
38

What are some common Kafka anti-patterns to avoid?

Part of Pro
39

How do you implement event sourcing with Kafka?

Part of Pro Visual
40

What is the role of the Kafka Controller?

Part of Pro
41

How do you implement CQRS (Command Query Responsibility Segregation) with Kafka?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Apache Kafka? Send them this set.
Quick recap

Apache Kafka in pictures.

A quick recap of Apache Kafka in 31 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 26 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

36 of 41 Apache Kafka answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git