Kafka Producer Basics — Concept Check
Questions on Kafka Producer Basics. A producer sends records to a topic; it serialises the key and value, selects a partition (by key hash, custom partitioner, or round-robin), and batches records for efficiency.
Questions in this quiz
8 questions on Kafka Producer Basics — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A Kafka producer is configured with `enable.idempotence=true`. What happens if a network issue causes a retry?
- AThe broker deduplicates the retried record.
- BThe producer stops sending records.
- CThe producer switches to a new partition.
- DThe producer sends a duplicate record.
2.A service using Kafka producers experiences high latency. The `linger.ms` is set to 5 ms. What could improve throughput?
- ASet `acks=0` to reduce latency.
- BIncrease `linger.ms` to allow larger batches.
- CDisable idempotence for faster retries.
- DDecrease `linger.ms` to send records faster.
3.Records with the same key always go to the same partition. Why is this important?
- AIt compresses records more efficiently.
- BIt balances load evenly across partitions.
- CIt ensures per-key ordering for consumers.
- DIt reduces the need for retries.
4.A Kafka producer uses a custom partitioner. What is a possible reason for implementing this?
- ATo enable idempotence for certain records.
- BTo decrease the linger time for specific records.
- CTo increase the batch size for all records.
- DTo route specific records to dedicated partitions.
5.A Kafka producer without a key sends records. How are partitions selected in Kafka 2.4+?
- AA random partition is chosen each time.
- BSticky partitioning is used.
- CThe producer fails to send records.
- DRecords are sent to partition 0.
6.You notice duplicate records being sent by a Kafka producer. What configuration might be missing?
- A`compression.type=none`
- B`linger.ms=0`
- C`acks=0`
- D`enable.idempotence=true`
7.In Spring Boot, how is a KafkaTemplate configured for JSON serialization?
- AConfiguring `spring.kafka.producer.retries=0`
- BEnabling `spring.kafka.producer.enable.idempotence`
- CUsing `spring.kafka.producer.value-serializer=JsonSerializer`
- DSetting `spring.kafka.producer.acks=0`
8.A Kafka producer is configured with `acks=all`. What does this guarantee?
- AOnly the leader broker acknowledges the record.
- BAll brokers acknowledge the record, ensuring durability.
- CThe record is sent to all partitions.
- DThe producer sends records without waiting for acknowledgments.