All Products
Search
Document Center

ApsaraMQ for Kafka:Partition rebalancing and traffic redirection

Last Updated:Jul 25, 2024

This topic describes how to rebalance partitions and redirect traffic in a topic in a cluster in the ApsaraMQ for Kafka console.

Background information

Partition rebalancing

If partitions are unevenly distributed in the topics of a cluster, partition skew may occur. This may result in insufficient utilization of disk performance and capacity. To resolve this issue, you can increase the number of partitions in the topics to a value that is a multiple of the number that is recommended by the system. In production environments, the number of partitions for some workloads cannot be changed in a timely manner. In this case, you can use the partition rebalancing feature provided by Message Queue for Apache Kafka. The partition rebalancing feature redistributes partitions of topics that use cloud storage to help ensure that the number of partitions in each topic can be as average as possible.

Traffic redirection

If partitions are unevenly distributed in the topics that use cloud storage in a cluster and the traffic on a specific topic is excessively high, you can use the traffic redirection feature to redirect the traffic on the topic to a topic with low disk usage. This way, the number of partitions in each topic of the cluster can be as average as possible.

Risk description

To ensure that a cluster runs as expected, only traffic in one topic is redirected at a time. Traffic of a topic that uses cloud storage can be redirected within seconds. During traffic redirection, metadata on the client is updated, and the client is reconnected. Before traffic redirection, make sure that your client can update metadata and can be reconnected. Data migration of a topic that uses local storage takes a long period of time to complete. We recommend that you take necessary precautions when you redirect the traffic of a topic that uses local storage.

Procedure

  1. Log on to the ApsaraMQ for Kafka console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides.

  3. Configure partition rebalancing or traffic redirection

    • Partition rebalancing

      1. On the Instances page, find the instance that you want to manage and choose More > Partition Rebalancing in the Actions column.

      2. Read the message that appears and click OK.

    • Traffic redirection

      1. On the Instances page, click the name of the instance that you want to manage.

      2. In the left-side navigation pane, click Topics. On the Topics page, find the topic that you want to manage and choose More > Traffic Redirection in the Actions column.

      3. Read the message that appears and click OK.