This is extra practice for CCDAK review: 40 Kafka questions worth remembering: 34 multiple-choice questions I wrote myself, covering what that post doesn’t ask. They are not real exam questions and aren’t copied from any exam; they’re written from the exam’s knowledge domains, with scenarios of my own. Finish a section before opening its answers.
At a glance:
mindmap
root((CCDAK practice 2))
Cluster: one active controller
Producer: linger.ms builds batches
Consumer: assign vs subscribe
Schema Registry stores only schemas
Connect: source in, sink out
KTable state, KStream events
Trap: wrong circulated answers
1. How to use this post
Key idea: read the question, pick your answer and say the reason out loud (English practice too), then open the folded answers at the end of each section. Anything you miss, go back to the matching theory post.
- Questions with several correct answers say “(choose N)”.
- Answers follow Kafka 3.x/4.x and the current Confluent Platform; where older questions differ, there’s a note.
- Background: Why Kafka is fast and durable, Tuning Kafka for your goal, Kafka in practice (1) and (2).
2. Cluster, CLI and security
Key idea: know the KRaft-era CLI, the controller’s role, bootstrapping and host-based ACLs.
Q1. On Kafka 3.x you need to list partitions where at least one replica has dropped out of the ISR. Which command? A) kafka-topics --zookeeper zk:2181 --describe --under-replicated-partitions · B) kafka-topics --bootstrap-server b:9092 --describe --under-replicated-partitions · C) kafka-topics --bootstrap-server b:9092 --describe --unavailable-partitions · D) kafka-consumer-groups --describe --all-groups
Q2. A cluster of 6 brokers, 4 producer apps, 10 consumers. How many controllers are active at any moment? A) 6 · B) 4 · C) 1 · D) 3
Q3. A consumer’s bootstrap.servers lists only one of 9 brokers. Can it read partitions led by other brokers? A) No, only partitions led by that broker · B) Yes, bootstrap is only for the first metadata fetch · C) Yes, but all data flows through the bootstrap broker
Q4. A producer with acks=1 writes to a partition with RF 2; the leader broker dies suddenly. What’s true? (choose 2) A) The producer refreshes metadata and continues with the new leader · B) The topic is unusable until the old broker returns · C) Records the leader acknowledged but the follower hadn’t copied may be lost · D) The producer must be restarted
Q5. A service worked on its old VM; on a new VM it connects fine but every send fails with TOPIC_AUTHORIZATION_FAILED. Most likely cause? A) The broker must be restarted · B) The ACL for that principal only allows the old VM’s host (IP) · C) A producer can’t run on two machines
Q6. Can a record already written to a topic be modified? A) Yes, with the AdminClient · B) No, the log is append-only · C) Yes, if the topic is compacted
Answers to section 2
- Q1: B.
--zookeeperwas removed fromkafka-topicsin Kafka 3.0 (A is the ZooKeeper-era answer). C lists partitions with no live leader, which is different from “missing replicas”. - Q2: C. There’s always exactly one active controller. With KRaft, the quorum has 3 or 5 voters but only one leader (the active controller). Producer and consumer counts are irrelevant.
- Q3: B. Every broker can answer metadata requests, so the client learns each partition’s leader and connects to it directly. List 2–3 brokers so startup still works if one is down.
- Q4: A, C. The client gets
NOT_LEADER_OR_FOLLOWERor a network error, refreshes metadata and retries against the new leader. Withacks=1, records that only existed on the old leader are lost when the follower takes over. - Q5: B. An ACL has a principal, an operation, a resource and a host. An ACL pinned to a specific IP breaks the service when it moves. Add an ACL for the new host, or use
*if principal-based authentication is enough. - Q6: B. Data is immutable. To “change” it, write a new version; on a compacted topic the latest value per key replaces older ones when compaction runs, and a tombstone (null value) deletes the key. C is wrong because compaction doesn’t edit records, it drops old ones.
3. Producer
Key idea: know which knob grows batches, which one prevents duplicates, and what a key is for.
Q7. Batches usually leave only a third full; you want bigger batches for better compression without changing the send rate. What do you change first? A) Raise batch.size · B) Raise linger.ms to 10–20 ms · C) Set acks=all · D) Raise max.request.size
Q8. The producer runs flat out, batches are always full, and the network is the bottleneck. What raises throughput? (choose 2) A) Enable compression (lz4 or zstd) · B) Lower batch.size · C) Raise batch.size · D) Lower linger.ms
Q9. After network timeouts, consumers see duplicate records caused by producer resends. Which fix doesn’t hurt throughput? A) max.in.flight.requests.per.connection=1 · B) enable.idempotence=true · C) retries=0 · D) batch.size=1
Q10. A teammate wants customer_id as the key so consumers can “subscribe to customer 42 only”. Right? A) Yes, consumers filter by key at the broker · B) No, the key decides partition and order, it isn’t a broker-side filter · C) Yes, if they use assign()
Q11. The broker has auto.create.topics.enable=false; a producer sends to a topic that doesn’t exist. What happens? A) The topic is created with 1 partition · B) send() waits for metadata up to max.block.ms, then throws TimeoutException · C) The record is silently dropped
Answers to section 3
- Q7: B.
batch.sizeis only a ceiling; batches leave half-empty because the producer doesn’t wait.linger.msmakes it wait a few ms to gather more, so batches grow and compress better. Since Kafka 4.0,linger.msdefaults to 5 ms. - Q8: A, C. Batches are already full, so waiting longer (
linger.ms) changes nothing. Bigger batches and compression let each request carry more data over the same bandwidth. - Q9: B. The idempotent producer tags batches with a producer ID and sequence numbers; the broker drops duplicates and still allows up to 5 in-flight requests. It’s on by default since Kafka 3.0. A also keeps order but kills throughput; C loses messages.
- Q10: B. Consumers don’t filter by key at the broker; they read whole partitions. The key decides the partition (per-key order) and is the unit of compaction.
- Q11: B. The producer waits for the topic’s metadata up to
max.block.ms(default 60 seconds), thensend()throwsTimeoutException. With auto-create on, the topic is created from the broker’snum.partitionsanddefault.replication.factor.
4. Consumers, assignors and offsets
Key idea: tell subscribe from assign, understand how assignors split partitions, and where offsets get committed.
Q12. An inspection tool needs to read only partition 3 of topic audit, outside any group. Which is right? A) consumer.subscribe("audit", 3) · B) consumer.assign(List.of(new TopicPartition("audit", 3))) · C) subscribe() then assign()
Q13. Code calls subscribe(List.of("a")), then subscribe(List.of("b")), then subscribe(List.of("c")). Which topics does the consumer read? A) a, b, c · B) only c · C) only a · D) it throws
Q14. A group has C1 and C2, both subscribed to topics T1 and T2 with 3 partitions each. With RangeAssignor, how many partitions does each get? A) 3 and 3 · B) 4 and 2 · C) 6 and 0
Q15. Same group, using RoundRobinAssignor. Which result matches? A) C1: T1-0, T1-2, T2-1; C2: T1-1, T2-0, T2-2 · B) C1: T1-0, T1-1, T2-0, T2-1; C2: T1-2, T2-2 · C) Two consumers can’t read two topics at once
Q16. A service restarts every night and always re-reads the topic from the beginning. Likely cause? A) group.id is generated randomly on each start · B) enable.auto.commit=true · C) The topic has too many partitions
Q17. How does a consumer commit offsets? A) It writes directly to the __consumer_offsets topic · B) It sends a request to the group coordinator, which writes to __consumer_offsets · C) It writes to ZooKeeper
Q18. You run kafka-console-consumer --bootstrap-server b:9092 --topic logs without --group. What’s true? A) It uses no group · B) It uses a randomly named group like console-consumer-12345 · C) It always uses the group console
Q19. A dashboard can tolerate losing a few events but must never show duplicates. Which commit strategy? A) Commit after processing · B) Commit right after poll(), before processing · C) Never commit, read from the start each time
Answers to section 4
- Q12: B. There’s no
subscribe(topic, partition)in the Java API (the circulating set marks that option correct too). Mixingsubscribe()andassign()on one consumer throwsIllegalStateException. - Q13: B. Each
subscribe()call replaces the whole previous list. For several topics, pass one list, or aPatternlikePattern.compile("topic\\..*"). - Q14: B. Range splits per topic: for T1 (3 partitions, 2 consumers), C1 takes 0 and 1, C2 takes 2; T2 repeats exactly. C1 gets 4, C2 gets 2. The more topics, the worse the skew.
- Q15: A. Round robin lines up every partition of every topic and deals them out in turn, so each gets 3. The Java 3.x client defaults to
[RangeAssignor, CooperativeStickyAssignor]; groups on Kafka 4.0’s new protocol (KIP-848) let the broker pick the assignor. - Q16: A. A new group has no committed offsets, so
auto.offset.resetapplies (hereearliest). Use a stablegroup.id. Addgroup.instance.id(static membership) so quick restarts don’t trigger a rebalance. - Q17: B. The consumer sends
OffsetCommitto the group coordinator, the broker leading the__consumer_offsetspartition forhash(group.id) % 50. That broker writes the offset to the topic. - Q18: B. The console consumer picks a random group. Without
--from-beginningit starts at the end of the log. - Q19: B. Commit before processing: a crash midway drops the unprocessed part (loss) but never processes anything twice. The circulating set marks “commit after processing” for a similar question, which is wrong: that’s at-least-once.
5. Schema Registry, Avro and REST Proxy
Key idea: Schema Registry only holds schemas and compatibility rules; records carry the schema’s ID, and clients look it up and cache it.
Q20. A consumer using KafkaAvroDeserializer meets a record whose schema ID isn’t in its local cache. What happens? A) It throws SerializationException immediately · B) It asks Schema Registry for the schema by ID and caches it · C) It reads the schema embedded in the record
Q21. Which is not a Schema Registry job? A) Storing schemas · B) Checking compatibility rules when a new schema is registered · C) Storing the Avro records · D) Assigning schema IDs
Q22. In an Avro record schema, which attribute is optional? A) name · B) fields · C) doc · D) type
Q23. How are Java SpecificRecord classes created? A) Written by hand · B) Generated from .avsc files at build time by Avro’s Maven/Gradle plugin · C) Generated by the Registry at runtime
Q24. An app sends binary data through the REST Proxy (base64 inside JSON) to topic blobs. What does a Java consumer reading the topic directly get? A) A base64 string it must decode · B) The original bytes · C) JSON
Q25. Which formats does the current Confluent Platform REST Proxy support natively? (choose all) A) binary · B) JSON · C) Avro · D) Protobuf · E) JSON Schema
Answers to section 5
- Q20: B. Records follow Confluent’s wire format: 1 magic byte (0), a 4-byte schema ID, then the data. The deserializer checks its cache and, on a miss, calls
GET /schemas/ids/{id}over HTTP(S) and caches the result. It only fails if the Registry doesn’t have that ID. - Q21: C. Records live on brokers. The Registry stores schemas in the compacted
_schemastopic, assigns IDs and checks compatibility. The Registry itself (not the broker) rejects an incompatible schema, when the serializer registers it. - Q22: C.
type,name,fieldsare required;doc,namespace,aliasesare optional. - Q23: B.
avro-maven-pluginor the Gradle plugin generates classes from.avsc. Without code generation, useGenericRecord. - Q24: B. The REST Proxy decodes the base64 and sends bytes to Kafka; a direct consumer receives bytes.
- Q25: A, B, C, D, E. Protobuf and JSON Schema arrived in Confluent Platform 5.5 (APIs v2 and v3). The circulating set says Protobuf is “not supported”, an outdated answer.
6. Kafka Connect
Key idea: sources bring data in, sinks take it out; the task count is capped by tasks.max and by the data source (number of tables, number of partitions).
Q26. Which kind of connector syncs new rows from PostgreSQL into Kafka? A) Sink · B) Source · C) Kafka Streams · D) REST Proxy
Q27. An S3 sink connector reads a 4-partition topic with tasks.max=10 on a 5-worker Connect cluster. How many tasks actually get partitions to work on? A) 10 · B) 5 · C) 4 · D) 20
Q28. A connector using JsonConverter reports “JsonConverter with schemas.enable requires ‘schema’ and ‘payload’ fields”. The data is plain JSON. How do you fix it? A) Switch to AvroConverter · B) Set value.converter.schemas.enable=false (and the same for the key) · C) Add an SMT to wrap the message
Q29. Which is not an internal topic of Connect in distributed mode? A) the config topic · B) the offset topic · C) the status topic · D) a topic holding plugin jar files
Answers to section 6
- Q26: B. Source: external system → Kafka (JDBC source, Debezium). Sink: Kafka → external system (S3, Elasticsearch, JDBC sink).
- Q27: C. Sink tasks are consumers in one group; beyond the partition count, extra tasks have nothing to read. Set
tasks.max=4. Likewise, a JDBC source over 3 tables withtasks.max=2creates 2 tasks; over 2 tables withtasks.max=5, it creates 2. - Q28: B.
schemas.enable=trueexpects a{schema, payload}envelope. Plain JSON has no envelope, so turn it off. - Q29: D. The three internal topics are
config.storage.topic(connector configs),offset.storage.topic(source offsets),status.storage.topic(connector and task status). Plugins live on each worker’s disk underplugin.path. The circulating set explains the status topic as “for leader election”, which is wrong.
7. Kafka Streams and ksqlDB
Key idea: tell stateless from stateful, KStream from KTable, and remember ksqlDB runs on Kafka Streams.
Q30. Which applications are stateless? (choose 2) A) Converting events from JSON to Avro · B) Publishing the 10 best-performing stocks each day · C) Routing ERROR logs to a high-priority topic and the rest to a normal one · D) The lowest and highest price for each trading day
Q31. A shoe store. Which data should be modelled as a KTable? (choose 2) A) Current inventory per SKU · B) The stream of sales transactions · C) Total revenue so far · D) The stream of website clicks
Q32. Which statements about ksqlDB are true? (choose 2) A) It complies with ANSI SQL · B) It runs on the Kafka Streams library · C) To read a topic from the start in the CLI, run SET 'auto.offset.reset'='earliest'; · D) It always reads from the start of a topic
Q33. Which ksqlDB statements start a continuously running query that writes results to a Kafka topic? (choose 2) A) CREATE STREAM s WITH (KAFKA_TOPIC='x', VALUE_FORMAT='JSON') · B) CREATE TABLE t AS SELECT ... · C) INSERT INTO s SELECT ... · D) SHOW STREAMS
Q34. A Streams application reads one 6-partition topic. You run 3 instances with 4 stream threads each. How many threads have work? A) 12 · B) 6 · C) 3
Answers to section 7
- Q30: A, C. Each record is processed from itself alone (map, filter, branch). B and D need to remember data across records (daily aggregates).
- Q31: A, C. A KTable is “the latest value per key”: current inventory, running totals. Sales and clicks are event sequences, so KStream. The circulating set leaves “current inventory” out of the answer, which I think is wrong: it’s the textbook KTable example.
- Q32: B, C. ksqlDB isn’t ANSI-compliant (there’s no standard for SQL over streams). It reads from the end (
latest) by default. - Q33: B, C. CTAS/CSAS and
INSERT INTO ... SELECTcreate persistent queries that read and write Kafka. A only registers metadata (written to ksqlDB’s command topic; it creates the topic if you givePARTITIONS).SHOW,DESCRIBE,EXPLAINonly query the server. - Q34: B. 6 partitions become 6 tasks; each task runs on one thread, and the other 6 threads idle (still useful as spares when an instance dies).
8. Wrong or outdated answers in the circulating set
Key idea: checked against the Kafka docs, at least these questions in the set handed out with the course need correcting. When you meet one of these, answer from the “Correct” column.
| Topic | Circulating set says | Correct |
|---|---|---|
| Reading a specific partition | subscribe(topic, partition) or assign() |
only assign() |
| Number of controllers | marks both 3 and 5 | 1 |
| Streams exactly-once | Kafka → Kafka and Kafka → external | only Kafka → Kafka |
| At-most-once | commit after processing | commit before processing |
| Who rejects a bad schema | the Registry and the broker | only the Registry |
| When compaction runs | on partition creation and when a segment closes | once segments are closed and the dirty ratio is high enough |
| KTable | revenue, returned items | revenue, current inventory |
| ZooKeeper ports | 2888 “peer”, 3888 “leader” | 2888 followers to leader, 3888 leader election |
| Connect status topic | used for leader election | stores connector and task status |
| REST Proxy and Protobuf | not supported | supported since CP 5.5 |
--zookeeper in the CLI |
used normally | removed from kafka-topics in 3.0; Kafka 4.0 drops ZooKeeper |
| Auto-create config name | auto.create.topic.enable |
auto.create.topics.enable |
Remember
- Write code that reads one specific partition and code that reads several topics via a
Pattern, and know why callingsubscribeseveral times is wrong. - Split partitions between two consumers by hand, with Range and with RoundRobin.
- Explain Confluent’s wire format (magic byte + schema ID) and what the Registry does and doesn’t do.
- Work out the useful task count of a sink connector and of a Streams application.
- Classify a dataset as KStream or KTable, and an operation as stateless or stateful.
Interview questions
Junior
How do subscribe() and assign() differ?
subscribe() joins a consumer group, so Kafka splits partitions and rebalances; assign() picks fixed partitions yourself, with no group management.
assign() suits replay or inspection tools, or managing offsets externally. The two can’t be mixed on one consumer.
How do KStream and KTable differ?
A KStream is a sequence of events, each record something that happened; a KTable is the latest state per key, where a later record overwrites an earlier one.
Transactions are a KStream, current balances a KTable. Aggregating a KStream produces a KTable.
Mid
How do RangeAssignor and CooperativeStickyAssignor differ?
Range splits per topic, so it skews when you subscribe to many topics; CooperativeSticky balances evenly, keeps the previous assignment as much as possible and rebalances incrementally without stopping the whole group.
With Range, every rebalance makes every consumer give up all its partitions (eager). Cooperative only moves the partitions that must move, so other consumers keep running.
How does Schema Registry work during one produce and consume?
The serializer registers (or looks up) the schema, gets an ID and writes it into the record’s first 5 bytes; the deserializer reads the ID, checks its cache or asks the Registry, then decodes.
The Registry checks compatibility at registration and stores schemas in the _schemas topic. Brokers never read payloads, so they never reject data over a schema.
Senior
A sink connector is slow. How do you scale it?
Raise tasks.max up to the source topic’s partition count, add workers if their CPU or network is saturated; beyond the partition count you must add partitions.
First check whether the bottleneck is the target system (S3, Elasticsearch): more tasks just pile more load on it. Tuning the connector’s batching (flush size, records per write) is often more effective than more tasks.
How do you assess a candidate who only memorised CCDAK questions?
Ask for reasons instead of answers: why Range skews, why committing first is at-most-once, what the Registry does when it meets an unknown ID.
People who memorised usually get the letter right but can’t explain it, and often carry the circulating set’s wrong answers. I give a new scenario (changing the partition count, moving a service to another machine) to see whether they can reason it through.
Useful phrases for interviews
- “The range assignor works per topic, so it can be unbalanced.”
- “Calling subscribe again replaces the subscription; it doesn’t add to it.”
- “Static membership avoids a rebalance on a quick restart.”
- “Offset commits go to the group coordinator, not straight to the topic.”
- “The wire format starts with a magic byte and a four-byte schema ID.”
- “SpecificRecord classes come from code generation at build time.”
- “A source connector pulls rows from PostgreSQL into Kafka; a sink pushes them out.”
- “Sink tasks can’t usefully outnumber the topic’s partitions.”
- “Filtering and mapping are stateless; daily aggregates are stateful.”
- “CREATE TABLE AS SELECT starts a persistent query.”
Notes based on the Advanced Backend course (Ronin Engineer), rewritten in my own words.