All questions
Showing of 41Explain the core components of Kafka architecture.
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:
Last attempt -
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.
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 ↓
What is a Kafka topic and how does partitioning work?
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:
Last attempt -
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.
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 ↓
What was ZooKeeper's role in Kafka, and what replaced it?
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:
Last attempt -
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.
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 ↓
What are Kafka Headers and when would you use them?
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:
Last attempt -
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.
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 ↓
What are Kafka's log retention and cleanup policies?
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:
Last attempt -
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=168keeps data for 7 days by default.log.retention.bytes=-1sets no size limit by default, and any limit applies per partition.log.segment.bytes=1073741824sets 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.
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 ↓
What is the difference between Kafka and traditional message queues?
Explain Kafka producers and their key configurations.
How do Kafka consumers work and what is a consumer group?
What is offset management in Kafka?
Explain Kafka's replication mechanism.
What are Kafka's delivery semantics?
What is Kafka Streams and when would you use it?
Explain Kafka Connect and its purpose.
How does Kafka ensure high throughput?
Explain Kafka's log compaction feature.
What is the difference between poll and fetch in a Kafka consumer?
How do you handle schema evolution in Kafka?
Explain Kafka's security features.
What is the purpose of the __consumer_offsets topic?
How do you monitor Kafka cluster performance?
What causes consumer lag and how do you address it?
What is the difference between Kafka and Apache Pulsar?
What is Kafka MirrorMaker and its use cases?
What is Kafka's approach to backward compatibility?
Explain Kafka's compression and its trade-offs.
What is the difference between at-rest and in-transit encryption in Kafka?
How do you handle duplicate messages in Kafka?
What triggers a consumer group rebalance, and how do the rebalance protocols differ?
How do you choose the number of partitions for a Kafka topic?
How do you handle poison messages in a Kafka consumer?
What is tiered storage in Kafka, and what problem does it solve?
What are Kafka's consistency guarantees?
What are Kafka transactions and how do they work?
Explain Kafka's ISR (In-Sync Replica) mechanism.
How do you tune Kafka for maximum performance?
Explain Kafka's exactly-once semantics implementation.
How does Kafka handle network partitions and split-brain scenarios?
What are some common Kafka anti-patterns to avoid?
How do you implement event sourcing with Kafka?
What is the role of the Kafka Controller?
How do you implement CQRS (Command Query Responsibility Segregation) with Kafka?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
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.
Apache Kafka cheatsheet
- Topics & partitions01
- Producer settings02
- Consumer groups & offsets03
- Replication & durability04
- Delivery guarantees05
- Retention & compaction06
- Controllers & KRaft07
- Speed & monitoring08
- Security09
- Streams, Connect & patterns10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 26 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in36 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.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.