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.
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:
- Drain planned traffic if your architecture uses broker-aware routing.
- Stop broker gracefully.
- Apply config changes if needed.
- Start broker.
- Wait for full cluster recovery.
- Move to next broker.
Stop and start commands:
If your deployment uses systemd, prefer service units:
Use one method consistently per environment.
Validate After Each Broker Restart
After each broker comes back, verify cluster health before continuing.
Also inspect broker logs for startup issues:
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.

