Kafka
Server Maintenance
System Administration
Troubleshooting
IT Support

How to restart kafka server properly?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Restarting Kafka brokers safely is an operations task where sequence matters more than speed. A poorly timed restart can reduce in-sync replicas, trigger client timeouts, or cause leader churn. The reliable approach is a rolling restart with pre-checks, one broker at a time, and post-restart validation before moving on.

Understand the Restart Goal

Typical reasons for restart include:

  • Applying configuration changes.
  • Upgrading Kafka version.
  • Restarting after host patching.
  • Recovering from resource pressure.

Different goals require different caution levels, but the core rule stays the same: keep partition availability healthy during every step.

Pre-Restart Checks

Before touching a broker, verify cluster condition and replication safety.

bash
1# list topics and partition state
2kafka-topics.sh --bootstrap-server broker1:9092 --describe
3
4# optional, check consumer lag if you monitor critical groups
5kafka-consumer-groups.sh --bootstrap-server broker1:9092 --all-groups --describe

Check these indicators:

  • No under-replicated partitions.
  • No offline partitions.
  • Controllers and brokers reachable.
  • Disk and memory pressure acceptable.

If under-replicated partitions already exist, resolve that first.

Run a Rolling Restart

Never restart all brokers at once in production unless you intentionally accept downtime.

For each broker:

  1. Drain planned traffic if your architecture uses broker-aware routing.
  2. Stop broker gracefully.
  3. Apply config changes if needed.
  4. Start broker.
  5. Wait for full cluster recovery.
  6. Move to next broker.

Stop and start commands:

bash
1# stop broker gracefully
2bin/kafka-server-stop.sh
3
4# start broker with configured properties
5bin/kafka-server-start.sh -daemon config/server.properties

If your deployment uses systemd, prefer service units:

bash
sudo systemctl stop kafka
sudo systemctl start kafka
sudo systemctl status kafka

Use one method consistently per environment.

Validate After Each Broker Restart

After each broker comes back, verify cluster health before continuing.

bash
kafka-topics.sh --bootstrap-server broker1:9092 --describe | grep -E "UnderReplicated|Offline"

Also inspect broker logs for startup issues:

bash
tail -n 200 /var/log/kafka/server.log

Look for these signals:

  • Broker registered successfully.
  • No repeated metadata or controller errors.
  • Replica fetchers running normally.
  • No authentication or ACL failures.

Only proceed when the cluster returns to normal state.

Configuration Change Safety

Some settings can be changed dynamically, others require restart. For restart-required settings, stage changes in config management and apply them consistently to each broker. Avoid mixing multiple risky changes in one maintenance window. If you are upgrading Kafka, follow the version compatibility matrix and upgrade path for inter-broker protocol settings.

KRaft and ZooKeeper Notes

Operational commands differ slightly depending on cluster mode.

  • Older clusters may still rely on ZooKeeper tooling.
  • Modern Kafka deployments use KRaft controllers.

Your restart checklist should be mode-aware, especially for controller quorum health checks in KRaft environments.

Rollback Strategy

Define rollback before starting:

  • Previous working config snapshot available.
  • Known-good Kafka package version available.
  • Clear stop condition, for example repeated startup failures or growing under-replicated partition count.

If rollback is needed, restore previous config and restart affected broker, then re-check cluster state.

Suggested Maintenance Checklist

Before closing the change window, capture broker restart timestamps, error log snippets, partition health snapshot, and client latency trend. Keeping this small checklist with your ticket history makes future maintenance windows faster and helps compare behavior across upgrades.

Common Pitfalls

  • Restarting multiple brokers simultaneously and reducing availability.
  • Ignoring existing under-replicated partitions before maintenance.
  • Applying config changes without validating whether restart is required.
  • Proceeding to next broker before full partition recovery.
  • Skipping log checks and missing early authentication or protocol errors.

Summary

  • Use rolling restarts, one broker at a time, for production safety.
  • Run health checks before and after each broker restart.
  • Wait for partition replication to recover before continuing.
  • Keep config snapshots and rollback steps ready.
  • Treat KRaft and ZooKeeper clusters with mode-specific checks.

Course illustration
Course illustration

All Rights Reserved.