Perform a Rolling Restart
A rolling restart involves restarting one broker at a time while the remaining brokers in your cluster continue running. This is to minimize downtime during a full cluster restart. You should perform a rolling restart during operations such as configuration updates that require a restart, version upgrades, or cluster maintenance.
A rolling restart involves putting a broker into and out of maintenance mode, and then repeating the process on the next broker in the cluster. Placing brokers into maintenance mode ensures a smooth restart of your cluster while reducing the risk of interruption or degradation in service.
When a broker is placed into maintenance mode, it reassigns its partition leadership to other brokers for all topics that have a replication factor greater than one. Reassigning partition leadership involves draining leadership from the broker and transferring that leadership to another broker.
-
Check for topics that have a replication factor greater than one.
If you have topics with
replication.factor=1, and if you have sufficient disk space, Redpanda Data recommends temporarily increasing the replication factor. This can help limit outages for these topics during the rolling restart. Do this before the restart to make sure there’s time for the data to replicate to other brokers. For more information, see Change topic replication factor. -
Ensure that all brokers are active before restarting:
rpk cluster info -b --detailedAll brokers should show
activeforMEMBERSHIPandtrueforIS-ALIVE:Example output
ID HOST PORT RACK CORES MEMBERSHIP IS-ALIVE VERSION UUID 0 redpanda-0.testcluster.local 32180 A 8 active true 25.2.13 24c08934-94f6-478c-b57d-45239f452488 1 redpanda-1.testcluster.local 32180 B 8 active true 25.2.13 7f3c1c6e-2f4d-4c8a-9c6e-0a8a6d8b2b61 2 redpanda-2.testcluster.local 32180 C 8 active true 25.2.13 b2e8d4a9-91c1-4b55-9f6a-3f7a2d3c5e44
Perform a rolling restart
Enable maintenance mode
-
Check that all brokers are healthy:
rpk cluster healthExample output:
CLUSTER HEALTH OVERVIEW ======================= Healthy: true (1) Controller ID: 0 All nodes: [0 1 2] (2) Nodes down: [] (3) Leaderless partitions: [] (3) Under-replicated partitions: [1] (3)1 The cluster is either healthy ( true) or unhealthy (false).2 The node IDs of all brokers in the cluster. 3 If the cluster is unhealthy, these fields will contain data. -
Optional: You can use the Admin API (default port: 9644) to perform additional checks for potential risks with restarting a specific broker.
curl -X GET "http://<broker-address>:<admin-api-port>/v1/broker/pre_restart_probe" | jq .Example output:// Returns tuples of partitions (in the format {namespace}/{topic_name}/{partition_id}) affected by the broker restart. { "risks": { "rf1_offline": [ "kafka/topic_a/0" ], "full_acks_produce_unavailable": [], "unavailable": [], "acks1_data_loss": [] } }In this example, the restart probe indicates that there is an under-replicated partition
kafka/topic_a/0(with a replication factor of 1) at risk of going offline if the broker is restarted.See the Admin API reference for more details on the restart probe endpoint.
-
Select a broker and place it into maintenance mode:
rpk cluster maintenance enable <node-id> --waitThe
--waitoption tells the command to wait until a given broker, 0 in this example, finishes draining all partitions it originally served. After the partition draining completes, the command completes.Expected output:Successfully enabled maintenance mode for node 0 Waiting for node to drain...
-
Verify that the broker is in maintenance mode:
rpk cluster maintenance statusExpected output:
NODE-ID DRAINING FINISHED ERRORS PARTITIONS ELIGIBLE TRANSFERRING FAILED 0 true true false 3 0 2 0 1 false false false 0 0 0 0 2 false false false 0 0 0 0
The
Finishedcolumn should readtruefor the broker that you put into maintenance mode. -
Validate the health of the cluster again:
rpk cluster health --watch --exit-when-healthyThe combination of the
--watchand--exit-when-healthyflags tell rpk to monitor the cluster health and exit only when the cluster is back in a healthy state.You can also evaluate metrics to determine cluster health. If the cluster has any issues, take the broker out of maintenance mode by running the following command before retrying the rolling restart:
rpk cluster maintenance disable <node-id>
Check metrics
Before continuing with the restart, check these important metrics to make sure the cluster is healthy and working as expected.
| Metric Name | Description | Recommendations |
|---|---|---|
Measures the number of under-replicated Kafka replicas. Non-zero: Replication lagging. Zero: All replicas replicated. |
Pause restart if non-zero. |
|
Represents the number of partitions that are currently unavailable. Value of zero indicates all partitions are available. Non-zero indicates the respective count of unavailable partitions. |
Ensure metric shows zero unavailable partitions before restart. |
|
Total bytes processed for Kafka requests. |
Ensure produce and consume rate for each broker recovers to its pre-restart value. |
|
Latency for processing Kafka requests. Indicates the delay between a Kafka request being initiated and completed. |
Ensure the p99 histogram value recovers to its pre-restart level. |
|
Latency for processing RPC requests. Shows the delay between an RPC request initiation and completion. |
Ensure the p99 histogram value recovers to its pre-restart level. |
|
CPU utilization for a given second. The value is a decimal between 0.0 and 1.0. A value of 1.0 means that the CPU was busy for the entire second, operating at 100% capacity. A value of 0.5 implies the CPU was busy for half the time (or 500 milliseconds) in the given second. A value of 0.0 indicates that the CPU was idle and not busy during the entire second. |
If you’re seeing high values consistently, investigate the reasons. It could be due to high traffic or other system bottlenecks. |
Restart the broker
To ensure proper ownership and permissions, restart the broker’s Redpanda service using systemctl:
sudo systemctl restart redpanda
Disable maintenance mode
-
Take the broker out of maintenance mode:
rpk cluster maintenance disable <node-id>Expected output:
Successfully disabled maintenance mode for node 0
-
Ensure that the broker is no longer in maintenance mode:
rpk cluster maintenance statusExpected output:
NODE-ID DRAINING FINISHED ERRORS PARTITIONS ELIGIBLE TRANSFERRING FAILED 0 false false false 0 0 0 0 1 false false false 0 0 0 0 2 false false false 0 0 0 0
Post-restart tasks
To verify that the cluster is running properly, run:
rpk cluster health
To view additional information about your brokers, run:
rpk cluster info -b --detailed
You can also use the Admin API to check how much each broker has progressed in recovering its workloads:
curl -X GET "http://<broker-address>:<admin-api-port>/v1/broker/post_restart_probe"
// Returns the load already reclaimed by broker, as a percentage of in-sync replicas
{
"load_reclaimed_pc": 66
}
Impact of broker restarts
When brokers restart, clients may experience higher latency, nodes may experience CPU spikes when the broker becomes available again, and you may receive alerts about under-replicated partitions. Topics that weren’t using replication (that is, topics that had replication.factor=1) will be unavailable.
Temporary increase in latency on clients (producers and consumers)
When you restart one or more brokers in a cluster, clients (consumers and producers) may experience higher latency due to partition leadership reassignment. Clients must communicate with the leader of a partition, so a client may send a request to a broker whose leadership has moved. The broker then returns a NOT_LEADER_OR_FOLLOWER error (formerly NOT_LEADER_FOR_PARTITION).
Redpanda shortens this interruption in two ways:
-
The error response names the new leader (KIP-951). A client that supports KIP-951 retries against the new leader without first requesting metadata.
-
Brokers briefly hold requests during the leadership change instead of failing them immediately. A broker that is becoming the leader holds produce, fetch, and OffsetForLeaderEpoch requests until it can serve them. A broker that is handing off leadership holds a produce request it refuses until it knows the new leader, so the error names that leader. While the former leader doesn’t yet know its successor, a fetch of that partition returns no data instead of an error. Fetch requests from consumers that set
client.rackare not held.
Each hold lasts at most the time set by the kafka_leader_hint_wait_ms cluster property (default: 100 milliseconds). Set it to 0 to turn off these behaviors, so that requests fail immediately and name the leader known at that time.
For example, when broker A hands off leadership of a partition to broker B:
-
Client sends a produce request to broker A.
-
Broker A holds the request until it knows that broker B is the new leader, then returns
NOT_LEADER_OR_FOLLOWERnaming broker B. -
Client sends the request to broker B, which serves it.
A client still requests metadata from the cluster to find the new leader when:
-
It doesn’t support KIP-951.
-
The error doesn’t name a leader that can serve the request.
-
It receives other retryable errors that indicate that its metadata may be stale.
Clients based on librdkafka, including the confluent-kafka-* clients, receive no leader in produce error responses, so they refresh metadata instead. Fetch error responses still name the leader for these clients.
To see how often brokers hold requests, and whether the leadership change finished before the hold expired, monitor the vectorized_kafka_leader_waits_total internal metric. Its request label is produce or fetch (fetch and OffsetForLeaderEpoch requests), and its outcome label is resolved or expired.
CPU spikes upon broker restart
When a restarted broker becomes available again, you may see your nodes' CPU usage increase temporarily. This temporary increase in CPU usage is due to the cluster rebalancing the partition replicas.
Under-replicated partitions
When a broker is in maintenance mode, Redpanda continues to replicate updates to that broker. When a broker is taken offline during a restart, partitions with replicas on the broker could become out of sync until it is brought back online. Once the broker is available again, data is copied to its under-replicated replicas until all affected partitions are in sync with the partition leader.