Per thread how many consumers are allowed, and can the consumer be multi-threaded?

Study for the Apache Kafka CCDAK Test. Use flashcards and multiple choice questions, with hints and explanations for each answer. Prepare effectively for your certification!

Multiple Choice

Per thread how many consumers are allowed, and can the consumer be multi-threaded?

Explanation:
A Kafka consumer is not thread-safe, so one thread should own a single consumer instance and use it in that thread only. If you need parallelism, run multiple consumer instances in the same consumer group, each in its own thread. Kafka assigns partitions to the consumers in the group, and a partition is consumed by exactly one consumer, which enables parallel work across the group. Therefore, per thread there is one consumer, and that consumer should not be multi-threaded. You can still process messages concurrently by handing off records to a worker pool after polling, but the consumer object itself remains single-threaded.

A Kafka consumer is not thread-safe, so one thread should own a single consumer instance and use it in that thread only. If you need parallelism, run multiple consumer instances in the same consumer group, each in its own thread. Kafka assigns partitions to the consumers in the group, and a partition is consumed by exactly one consumer, which enables parallel work across the group. Therefore, per thread there is one consumer, and that consumer should not be multi-threaded. You can still process messages concurrently by handing off records to a worker pool after polling, but the consumer object itself remains single-threaded.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy