Skip to content
Kafka Is FunProgress

SpringSpring Kafka Configuration

What is the difference between concurrency and partitions in Spring Kafka's listener container?

Reference answer

concurrency in ConcurrentKafkaListenerContainerFactory sets the number of consumer threads in the container (effectively the number of Kafka consumers in the group). Each thread is a separate KafkaConsumer instance. If concurrency=3 and your topic has 6 partitions, each thread handles 2 partitions. If concurrency > partition count, extras are idle. The concurrency is local — for more consumers across JVMs, deploy multiple application instances each with their own concurrency. Avoid setting concurrency higher than partition count.

Expected key concepts: concurrency, ConcurrentKafkaListenerContainerFactory, consumer threads, KafkaConsumer, partitions per thread, idle, multiple instances, local consumers