Kafka
Consumer Offsets Topic
Brokers
Data Distribution
Kafka Issues

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.

Practice system design

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:

  1. Partition Count: The __consumer_offsets topic'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.
  2. Replication Factor: Kafka topics are replicated across different brokers to ensure high availability and data durability. The __consumer_offsets topic typically has a default replication factor of 3. Essentially, this means each partition of the __consumer_offsets topic is copied to three different brokers. This again limits the dispersal across all brokers particularly in larger clusters.
  3. Broker Configuration: Kafka administrators can configure which brokers are eligible to store partitions of the __consumer_offsets topic. This might be necessary in scenarios where performance differentiation between brokers (due to hardware configuration, for example) is significant.
  4. 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_offsets topic. 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:

FactorImpact on DistributionDefault Setting
Partition CountLimits number of brokers involved50
Replication FactorLimits spread to fixed number of copies3
Broker ConfigurationMay exclude some brokers purposefullyConfigurable
Cluster SizeMay not cover all brokers in large clustersDependent 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
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design