Why __consumer_offsets topic in kafka is not spreading to all the brokers?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. Initially coined by LinkedIn and subsequently open-sourced, Kafka has become synonymous with handling massive quantities of data effectively and reliably. An integral part of Kafka’s functionality is managing how data offsets (which keep track of which messages have been consumed by which consumers) are maintained through a special internal topic called __consumer_offsets.
Understanding the __consumer_offsets Topic
The __consumer_offsets topic is a built-in Kafka topic used to store offset commits, which are essentially markers that denote the position up to which a Kafka consumer group has read. This topic ensures that every consumer in a group can resume reading from where it last stopped, thus enabling fault tolerance and balanced processing among consumers in the group.
Why is __consumer_offsets Not Spread Across All Brokers?
Contrary to what one might expect, the __consumer_offsets topic does not necessarily distribute evenly across all Kafka brokers in a Kafka cluster. The spreading of this topic, like others in Kafka, is subject to the topic's configuration settings, specifically its partition count and replication factor. The disposition involves a few key elements:
- Partition Count: The
__consumer_offsetstopic's number of partitions determine how spread out the topic can be across the cluster. By default, the partition count for this topic is set at 50. This means, ideally, in a smaller cluster, this alone can limit the availability of this topic to all brokers. - Replication Factor: Kafka topics are replicated across different brokers to ensure high availability and data durability. The
__consumer_offsetstopic typically has a default replication factor of 3. Essentially, this means each partition of the__consumer_offsetstopic is copied to three different brokers. This again limits the dispersal across all brokers particularly in larger clusters. - Broker Configuration: Kafka administrators can configure which brokers are eligible to store partitions of the
__consumer_offsetstopic. This might be necessary in scenarios where performance differentiation between brokers (due to hardware configuration, for example) is significant. - Cluster Size: In larger Kafka clusters, saying over 50 brokers, having a default partition count of 50 means not all brokers will necessarily hold a piece of the
__consumer_offsetstopic. Hence, its spread is limited to the number of partitions.
Performance and Scalability Concerns
Minimizing the spread of the __consumer_offsets topic can paradoxically aid performance. Having a large number of brokers handle offset commits can lead to increased commit latencies as more brokers are involved in the synchronization of state changes associated with consumer offsets.
Table Summary
Here's a quick summary table outlining how __consumer_offsets topic distribution could be influenced:
| Factor | Impact on Distribution | Default Setting |
| Partition Count | Limits number of brokers involved | 50 |
| Replication Factor | Limits spread to fixed number of copies | 3 |
| Broker Configuration | May exclude some brokers purposefully | Configurable |
| Cluster Size | May not cover all brokers in large clusters | Dependent on actual cluster size |
Conclusion
The __consumer_offsets topic is crucial for Kafka’s consumer management, ensuring consumers can pick up exactly where they left off in the event of a fault. Its distribution across brokers is carefully managed to optimize performance, fault tolerance, and resource utilization. While it may seem counterintuitive not to spread this topic across all available brokers, doing so is actually aligned with Kafka’s goal of providing a robust, scalable, and efficient event streaming platform.
Related reading
- why ADD COLUMN to kafka table is not supported in Clickhouse
- Why are my environment variables not detected when starting up celery?
- Why can't I establish connection to rabbitMQ using python?
- Why can't I find the 'rabbitmq.config' file while I have already installed RabbitMQ?
- Why can't Kafka Producer connect to zookeeper to fetch broker metadata instead of connecting to brokers
- Why can't you look at messages in the Rabbit Queue
- Why consumer hangs while consuming messages from Kafka on DC/OS using Client API for Java?
- Why do .index files exist in the kafka-log directory?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.