Home / Data Platform / Streaming & CDC

Data PlatformRunbookAdvanced

Kafka tiered storage runbook: enable it on a live cluster, size local retention, watch uploads and back out safely

Turn on KIP-405 tiered storage for existing Kafka topics without filling disks or losing data - broker config, per-topic rollout, upload monitoring and the safe way to disable it again.

Deepak Bhardwaj7 min read

Applies toApache Kafka 3.9 and 4.x (KRaft) with a RemoteStorageManager plugin for S3, Azure Blob or GCS; earlier 3.6–3.8 releases had tiered storage as early access

Goal

You want to keep long retention on a topic, or cut broker disk, by moving closed log segments to object storage and keeping only recent data on local disk. Tiered storage (KIP-405) does this inside the broker. Consumers read old offsets transparently.

This runbook covers a production rollout on a cluster that already has data, and the steps to undo it. Read the limits first, because some of them are one-way.

Before you start

Check Why
Brokers run Kafka 3.9 or later Tiered storage is production-ready from 3.9; the disable path (remote.log.copy.disable, remote.log.delete.on.disable) is also documented from there
You have a RemoteStorageManager plugin Apache Kafka ships the framework and a metadata manager, but no production S3/Azure/GCS implementation. Most teams use an open-source plugin or their vendor's
Target topics use cleanup.policy=delete Compacted topics are not supported for tiered storage
Object storage bucket/container, credentials and lifecycle rules are agreed Broker-side deletion handles retention; a bucket lifecycle rule that deletes objects early will corrupt the remote log
You know each topic's segment.bytes and segment.ms Only closed segments are uploaded. A quiet topic with 1 GB segments may not upload anything for days
Check your version's limitations list Support for JBOD and some other features differs between releases

Warning

Never point two clusters at the same bucket prefix, and never set a storage lifecycle rule that expires or moves objects to an archive tier the plugin can't read. Kafka's remote metadata will still reference those segments, and consumers fetching old offsets will fail.

Step 1: Configure the brokers

Add this to every broker's server.properties. The plugin class and the rsm.config.* keys depend on the plugin you chose; take them from its documentation.

# Turn on the tiered storage subsystem
remote.log.storage.system.enable=true

# Remote storage plugin (values are plugin specific)
remote.log.storage.manager.class.name=<plugin RemoteStorageManager class>
remote.log.storage.manager.class.path=/opt/kafka-tiered-storage/*

# Built-in metadata manager stores segment metadata in an internal topic
remote.log.metadata.manager.listener.name=INTERNAL
rlmm.config.remote.log.metadata.topic.replication.factor=3

# Plugin settings use the rsm.config. prefix, for example bucket and region
# rsm.config.<plugin key>=<value>

remote.log.storage.system.enable is a static broker setting, so roll it out with a normal rolling restart: one broker at a time, waiting for UnderReplicatedPartitions to return to zero between brokers.

# After each broker restart
bin/kafka-topics.sh --bootstrap-server broker1:9092 --describe --under-replicated-partitions

Nothing is uploaded yet. Enabling the system on brokers only starts the remote log manager.

Step 2: Enable one low-risk topic first

Pick a topic with moderate volume where a fetch failure on old data would hurt nobody. Keep total retention as it is, and set local retention to how much you want on disk:

bin/kafka-configs.sh --bootstrap-server broker1:9092 \
  --entity-type topics --entity-name clickstream \
  --alter --add-config remote.storage.enable=true,local.retention.ms=86400000

How the retention settings interact:

Setting Meaning
retention.ms / retention.bytes Total retention, local plus remote
local.retention.ms / local.retention.bytes How long data stays on broker disk. -2 (default) means "same as total retention"
Local value must be ≤ total value The broker rejects a local retention longer than total retention

Local segments are deleted only after they have been uploaded. If uploads fail, local data stays and disk keeps growing. This is safe, but you need to watch for it.

Tip

If a topic has a long segment.ms and low traffic, set segment.ms to something like a few hours on that topic. Otherwise the active segment holds most of the data, and the active segment is never tiered.

Step 3: Confirm segments are uploading

Check the broker metrics. Names follow KIP-930 in recent releases; older dashboards may use the pre-rename names.

MBean (kafka.server:type=BrokerTopicMetrics,name=...,topic=<t>) Healthy
RemoteCopyBytesPerSec Non-zero after segments roll
RemoteCopyErrorsPerSec Zero
RemoteCopyLagBytes Small and not growing
RemoteFetchBytesPerSec Non-zero only when consumers read old offsets
RemoteFetchErrorsPerSec Zero

Don't treat a zero RemoteCopyLagBytes as proof of health. There are known cases where it stays at zero or goes stale while copies are failing, so always pair it with the error rate and with local disk size.

Local disk size per partition should drop to roughly the local retention window:

bin/kafka-log-dirs.sh --bootstrap-server broker1:9092 --describe --topic-list clickstream \
  | grep -o '"partition":"[^"]*","size":[0-9]*'

Finally, prove the read path. Consume from the earliest offset, which forces a remote fetch:

bin/kafka-get-offsets.sh --bootstrap-server broker1:9092 --topic clickstream --time -2
bin/kafka-console-consumer.sh --bootstrap-server broker1:9092 --topic clickstream \
  --partition 0 --offset earliest --max-messages 5

Broker logs will show upload or fetch errors from the remote log manager and the plugin. Credential, endpoint and permission problems almost always show up there first.

Step 4: Roll out to more topics

Enable topics in batches, largest last. The first upload of an existing topic backfills every closed segment, which can saturate broker network and object-storage request limits. Watch:

  • Broker network out and CPU during the backfill.
  • Object storage throttling errors in the plugin logs.
  • Produce latency on the same brokers. Uploads share disk reads with replication.

Recent Kafka releases add broker-level copy and fetch rate quotas, and the plugin may have its own upload throttles. Check your version's broker configuration reference for the exact names before relying on them.

Consumers reading from remote storage see higher latency than page-cache reads. Backfills and replays of old data will be slower, which is expected. Size the remote reader thread pool in the broker config if many consumers replay at once.

Step 5: Backing out

There are two different operations. Choose deliberately.

Stop uploading, keep remote data readable

bin/kafka-configs.sh --bootstrap-server broker1:9092 \
  --entity-type topics --entity-name clickstream \
  --alter --add-config local.retention.ms=-2,local.retention.bytes=-2,remote.log.copy.disable=true

Once copy is disabled, local retention settings no longer apply, and all expiry follows retention.ms / retention.bytes. Set local retention to -2 (or equal to total retention) in the same change. Then make sure brokers have disk for the full retention window, because data that used to move off-broker now stays local.

Caution

Disabling copy on a topic with 30 days of total retention and 1 day of local retention means brokers must now hold up to 30 days locally. Check free disk on every broker that hosts the topic before you run the change, or lower retention.ms first.

Turn tiered storage off and delete remote data

bin/kafka-configs.sh --bootstrap-server broker1:9092 \
  --entity-type topics --entity-name clickstream \
  --alter --add-config remote.storage.enable=false,remote.log.delete.on.disable=true

This deletes the topic's remote segments. Any offsets that existed only in remote storage are gone, and consumers positioned there will reset according to auto.offset.reset. Only do this after confirming nobody needs the old data, or after copying it elsewhere.

Disable remote.log.storage.system.enable on brokers only when no topic still has tiered storage enabled.

Common failure modes

Symptom Cause Fix
Disk still full after enabling Active segments not rolling, or uploads failing Lower segment.ms; check RemoteCopyErrorsPerSec and plugin logs
Consumers fail on old offsets Objects removed by bucket lifecycle, or wrong credentials on some brokers Remove lifecycle rule; make credentials identical on all brokers
Disk spikes after disabling copy Local retention no longer applies Set local retention -2 and size disks, or reduce total retention
Produce latency rises during rollout Backfill competing for disk and network Enable fewer topics at once; throttle uploads

Prevent it next time

  • Put tiered storage settings, including local.retention.* and segment.ms, in your topic-as-code definitions so a new topic doesn't silently keep everything local.
  • Alert on RemoteCopyErrorsPerSec above zero and on local log size growing beyond the expected local window.
  • Protect the bucket: deny deletes from anything except the broker identity, and document that lifecycle rules are off-limits.
  • Rehearse the back-out steps on a staging topic so on-call knows the disk impact before they need it.