Scaling brokers
Learn how to upscale or downscale the number of brokers in your Kafka cluster.
To scale Kafka brokers in Cloudera Streams Messaging - Kubernetes Operator you:
- Scale the number of broker replicas in your KafkaNodePool resources.
- Move your data by rebalancing with Cruise Control.
The order in which you scale and rebalance is different for upscale and downscale operations. In case of an upscale, you scale brokers first and then rebalance. In case of a downscale, you rebalance first and scale brokers afterward.
By default, rebalancing with Cruise Control is initiated manually. You must create a KafkaRebalance resource and then review and approve the rebalance proposal that is generated to move data.
Alternatively, you can enable auto-rebalancing in the Kafka resource. In this case, the Strimzi Cluster Operator automatically rebalances your cluster with Cruise Control. The Strimzi Cluster Operator initiates the rebalance operation using the rebalancing templates (KafkaRebalance resources) that you create and configure.
When you scale a KafkaNodePool resource, the Strimzi Cluster Operator automatically adds or deletes broker nodes. Initiating a rebalance process with Cruise Control automatically moves data between brokers based on a proposal generated by Cruise Control.
Enabling auto-rebalancing
Complete these steps to enable auto-rebalancing for Kafka brokers. Enabling auto-rebalancing automates the rebalancing step of a scaling operation.
You enable auto-rebalancing for Kafka by creating one or more Kafka rebalancing
templates. Additionally, you add the
spec.cruiseControl.autoRebalance
property to your
Kafka resource. This property enables auto-rebalancing and
specifies which rebalancing templates should be used.
A rebalancing template is a KafkaRebalance resource that includes
the strimzi.io/rebalance-template: "true"
annotation. This
annotation designates the resource as a rebalancing template. When you create a
KafkaRebalance resource that includes the annotation, an
optimization proposal is not generated. In other words, the resource is created, but
is not executed immediately by the Strimzi Cluster Operator. Rebalancing templates
do not need to include the mode
or brokers
properties.
You can create any number of templates, however, typically you would create two, one for upscale and one for downscale operations. You can also create a single template and use it for both upscale and downscale operations.
Upscaling Kafka brokers
Complete these steps to upscale the number of brokers in your Kafka cluster
- Ensure that Cruise Control is deployed in your cluster. See Deploying Cruise Control.
- You can control the IDs of newly added brokers with the
strimzi.io/next-node-ids
annotation. See Configuring Kafka broker node IDs.
Downscaling Kafka brokers
Complete these steps to downscale the number of brokers in your Kafka cluster.