Redpanda — Rack Awareness Features

IntVerse.io
7 min readJan 14, 2024

Rack Awareness in Redpanda revolves around the physical layout of broker nodes within an RP cluster. In a typical data center or cloud environment, servers are organized into racks, and racks are further grouped into clusters. Rack Awareness ensures that RP brokers are aware of their respective racks, allowing for strategic placement of partitions and replicas across different racks.

Rack-aware partition assignment in Redpanda consumers is a functionality designed to allocate partitions to consumers while considering the geographical placement of both consumers and brokers. This feature helps to address the potential network latency issues that could otherwise affect the system’s overall performance.

The process of rack-aware partition assignment in Redpanda for consumers involves a strategic approach to allocating partitions, considering the physical location of both brokers and consumers. Each broker and consumer is affiliated with a designated rack, representing a logical grouping of machines that share close physical proximity. This meticulous assignment process ensures that partitions are distributed to consumers in a manner that maximizes efficiency, particularly favoring those consumers situated on the same rack as the broker responsible for serving the partition. This enhances overall system performance and resilience, especially in scenarios where Kafka is deployed across multiple data centers or availability zones.

Here is an overview of the process involved in the rack-aware partition assignment for Redpanda consumers:

  1. Rack Identification:

Assign each Kafka broker and consumer to a specific rack.

Racks represent logical groupings of machines located close to each other in physical terms.

2. Consumer Subscription:

Consumers express their interest in specific topics or partitions through subscriptions.

3. Partition Availability Check:

Assess the availability and distribution of partitions across the Redpanda cluster.

4. Rack Awareness Check:

Verify the rack affinity of each broker and consumer involved in the assignment process.

5. Optimal Rack Matching:

Strive to maximize the number of partitions assigned to consumers situated on the same rack as the broker responsible for serving those partitions.

Adapt the partition assignment dynamically to maintain an optimal and fault-tolerant configuration.

In essence, the rack-aware partition assignment process guarantees an allocation of partitions to consumers that minimizes network latency, enhances resilience, and upholds a well-balanced distribution of partitions across various racks.

Rack awareness in Redpanda involves distributing replicas of partitions across different racks to enhance fault tolerance. When creating a topic, users can specify the number of partitions and replicas. Redpanda considers factors such as the number of racks, replicas, available CPU cores, and broker utilization to strategically place replicas on brokers, aiming for distribution across different failure zones. This approach minimizes data loss in the event of a broker or rack failure, providing improved reliability in a distributed environment.

In the above diagram, the consumer is located in the US-east-2c, and the partition leader is located in the US-east-2a. It increases the number of cross-zone requests and can increase the billing at some cloud providers.

Configuring the Producer :

Rack-aware Partition Assignment for Redpanda Producers involves configuring the producer to send messages to a specific set of brokers based on their physical location. Here’s how to do it:

You can use the broker.rack configuration to assign each broker a rack ID. Brokers will then try to spread replicas across as many racks as possible.

To integrate rack information into the producer’s message distribution process, you’ll configure it by setting the partitioner.class configuration parameter to <your_package>.RackAwareStickyPartitioner. This specialized partitioner leverages the rack information to direct messages to the designated brokers. Importantly, it guarantees message delivery to the same set of brokers for as long as they remain available. This configuration step enhances the producer's ability to align with the rack-aware assignment strategy, contributing to optimized performance and fault tolerance within the Kafka cluster.

Configuring Rack-aware Partition Assignment for Kafka Consumers:

In the same way that you do for brokers, you can configure the new client.rack to assign a rack ID for consumers. When it is enabled, RackAwareReplicaSelector tries to match the consumer client.rack with the available broker.racks. It then selects the replica that has the same rack ID as the client.

If there are multiple replicas in the same rack, RackAwareReplicaSelector always selects the most up-to-date replica. If the rack ID is not specified, or if it can't find a replica with the same rack ID, it will fall back to the leader replica.

Enable rack awareness in the Redpanda cluster as below :

Config of the rack ID in Redpanda at broker level as below :

Rack awareness Use cases:

Redpanda cluster is running on US East Ohio with 3 brokers and 3AZ zones — us-east-2a, us-east-2b, and us-east-2c. Create a topic with 3 partitions and 3 replication factors as below :

Producer:

Now run the producer program with custom partition class and our target is to produce the message to Rack 2b where the leader is 0 and we can see the messages are produced to 0 as per the below screenshot

Producer Configuration:

Consumer :

Consumers don’t interact directly with this distribution but benefit indirectly. If the leader for a partition is on a broker in one rack and that rack experiences a failure, consumers can continue consuming from replicas in other racks.

In the rack awareness scenario, the Consumer class needs to be configured in such a way that it will read the messages from the specified rack as below:

props.put(ConsumerConfig.CLIENT_RACK_CONFIG, “us-east-2b”);

As per the below screenshot, It is observed that the Consumer is consuming the messages from the rack us-east-2b.

Major Customer Use Cases:

  1. Fault Tolerance: Rack awareness helps minimize data loss by distributing replicas of partitions across different racks. In the event of a rack failure, the data is still available on replicas located in other racks, ensuring system reliability.
  2. High Availability: By strategically placing replicas in different failure zones, rack awareness increases the availability of data and services. This is crucial for systems that require continuous operation without interruptions.
  3. Disaster Recovery: In scenarios where an entire rack or a set of brokers becomes unavailable, rack awareness ensures that data is still accessible from replicas in other racks, aiding in disaster recovery efforts.
  4. Scalability: As the cluster grows, rack awareness allows for efficient scaling by considering factors like available CPU cores and broker utilization. This helps in optimizing resource usage and maintaining performance as the system expands.

Advantages:

  1. Minimized Data Loss: Reducing the risk of data loss is a primary advantage. Rack awareness ensures that replicas are distributed across different failure zones, making the system resilient to rack failures.
  2. Improved Reliability: The distribution of replicas based on factors like CPU cores and broker utilization enhances the overall reliability of the system. Redpanda optimally utilizes resources to maintain a stable and responsive environment.
  3. Efficient Resource Allocation: By considering the number of available CPU cores and broker utilization, rack awareness allows for efficient resource allocation. This is particularly beneficial in large-scale distributed systems where optimal resource usage is crucial for performance.
  4. Scalability and Flexibility: The ability to specify preferences for replica placement based on the number of racks and replicas provides scalability and flexibility as the system evolves. Rack awareness adapts to changing cluster configurations and requirements.

Conclusion :

In the dynamic world of distributed data streaming, Redpanda Rack Awareness stands out as a crucial mechanism for building resilient and fault-tolerant systems. By intelligently distributing data across racks, Redpanda ensures that it can withstand hardware failures, maintain data redundancy, and optimize network communication.

As organizations continue to rely on Redpanda for their real-time data needs, understanding and leveraging Rack Awareness will be essential for achieving the highest levels of reliability and performance in distributed streaming architectures.

At IntVerse.io, We unlock the true potential of Redpanda and optimize its implementation for our client’s business needs. We are committed to providing ongoing guidance and support to ensure that Redpanda remains an asset for your organization in the long run.

--

--

IntVerse.io

We Solve Platform & Integration Problems in the UniVerse