Optimizing Kafka Brokers. How to improve Kafka performance by optimizing your Kafka brokers.

Optimizing Kafka Brokers: Lessons From Managing Fortune 500 Implementations

Published August 2023

Optimizing Kafka broker performance will have a direct impact on your overall Kafka implementation. In this blog post, we cover what a Kafka broker does, why it’s essential, and how to optimize Kafka broker settings. 

We also share firsthand experiences optimizing Kafka brokers from our work with Fortune 500 companies.  We encourage you to use this information to elevate the performance of your Kafka implementation.

What is a Kafka broker?

The Kafka broker is responsible for handling the storage, management, and distribution of data streams. It acts as an intermediary between producers, which generate data, and consumers, which process and consume the data.

Diagram showing the flow of messages from producers to Kafka partitions to consumers.

Figure depicting how the Kafka broker and its associated partitions act as an intermediary between producers and consumers. Figure originally published in the article Does Kafka Guarantee Ordering?

Kafka brokers receive data from producers and store it in topics. A topic represents a particular category or stream to which records are published. Each topic is divided into partitions, and these partitions are distributed across multiple brokers to achieve horizontal scalability and high throughput. Check out our articles on Kafka topics and Kafka Partitions for more information.

Why are Kafka brokers important?

Kafka brokers are critical for optimizing Kafka performance. Let’s explore why Kafka brokers are essential:

  1. Scalability: In the realm of Fortune 500 implementations, the volume of data generated and processed is vast. Kafka brokers facilitate horizontal scalability, allowing the addition of more brokers to the cluster to distribute the workload efficiently. This ensures that Kafka can handle the ever-increasing data streams without compromising on performance.

  2. Fault-Tolerance: In real-time streaming applications, data availability and reliability are essential. Kafka brokers use a mechanism called replication to maintain multiple copies of data across brokers. If one broker fails, its data can be seamlessly accessed from other replicas. This structure ensures data integrity and minimal downtime.

  3. High Throughput: Kafka brokers are optimized for high-speed data ingestion and processing. By leveraging efficient disk structures and batching techniques, Kafka brokers can handle millions of messages per second with low latency. This capability is crucial for meeting the demands of real-time data streaming and analytics.

How are brokers different from other Kafka components?

Several components need to work together for any Kafka implementation. To optimize Kafka brokers effectively, it’s crucial to understand how they differ from other Kafka components:

  1. Kafka Brokers vs. Producers: Producers are responsible for publishing data to Kafka topics. They interact directly with Kafka brokers, sending messages to the appropriate topics. Producers do not store or manage data; their primary focus is on generating and pushing data to the Kafka cluster.

  2. Kafka Brokers vs. Consumers: Consumers subscribe to Kafka topics and process the data streams. They communicate directly with Kafka brokers to consume messages from subscribed topics.  Check out our articles on Kafka Consumer Basics and Understanding Kafka Consumer Offset for more information on consumers.

  3. Kafka Brokers vs. ZooKeeper: ZooKeeper is a distributed coordination service used with Kafka to maintain metadata and track the status of Kafka brokers, producers, and consumers. Kafka brokers, on the other hand, handle the actual storage and distribution of data topics.  We do a deepdive into the importance of ZooKeeper and how to optimize it in this article on What is ZooKeeper & How Does it Support Kafka?.

How to optimize Kafka brokers?

Consider implementing the following techniques to optimize your Kafka broker settings:

  1. Hardware Scaling: The performance of Kafka brokers is significantly influenced by the underlying hardware. In Fortune 500 implementations, we often encounter demanding workloads. Upgrading hardware components, such as CPU, memory, and storage, is instrumental in enhancing broker performance. We found that SSDs (Solid State Drives) for storage significantly reduces disk I/O latency, resulting in faster data ingestion and retrieval.

  2. Replication Factor and Partition Management: Replication is a key feature of Kafka that ensures data durability and availability. Optimizing the replication factor based on fault tolerance needs and cluster size leads to a good balance between data redundancy and storage efficiency. Additionally, thoughtful partition management across brokers prevents hotspots and improves overall data distribution.  Check out our formula for determining how many Kafka partitions are needed for your implementation.

  3. Broker Configuration Tuning: Apache Kafka offers a range of configuration parameters that allow fine-tuning of broker performance. One critical parameter is num.io.threads, which determines the number of threads available for I/O operations. By increasing this value on machines with higher CPU core counts, we can more effectively use available resources and improve data throughput. Start with 8 per disk and modify from there.

    Lastly, adjusting the log.segment.bytes parameter can optimize storage utilization and reduce latency during log segment rollovers.  This parameter is specifically for size-based log retention.  You can additionally or alternatively use time-based retention.

Kafka Broker Key Facts

As Kafka engineers managing Fortune 500 Kafka implementations, we have witnessed firsthand the important role Kafka broker optimizations make in improving Kafka performance. 

Kafka brokers enable the efficient storage, management, and distribution of data streams.  This makes brokers fundamental to Kafka’s core principles of scalability, fault-tolerance, and high throughput.

Optimizing Kafka brokers involves hardware scaling, thoughtful replication factor and partition management, and broker configuration tuning. By implementing these strategies, you can improve the performance of your Kafka implementation to meet the demands of real-time data streaming and analytics.

Have Kafka Questions?

Managed Kafka on your environment with 24/ 7 support.

Consulting support to implement, troubleshoot,
and optimize Kafka.

Schedule a call with a Kafka solution architect.

Published by

Dattell - Kafka & Elasticsearch Support

Benefit from the experience of our Kafka, Pulsar, Elasticsearch, and OpenSearch expert services to help your team deploy and maintain high-performance platforms that scale. We support Kafka, Elasticsearch, and OpenSearch both on-prem and in the cloud, whether on stand alone clusters or running within Kubernetes. We’ve saved our clients $100M+ over the past six years. Without our guidance companies tend to overspend on hardware or purchase unnecessary licenses. We typically save clients multiples more money than our fees cost in addition to building, optimizing, and supporting fault-tolerant, highly available architectures.