# Manage Topics

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [streaming-full.txt](https://docs.redpanda.com/streaming-full.txt)

---
title: Manage Topics
latest-redpanda-tag: v25.3.11
latest-console-tag: v3.7.3
latest-operator-version: v26.1.4
# EOL = End-of-Life (support lifecycle status)
page-is-nearing-eol: "false"
page-is-past-eol: "false"
page-eol-date: November 19, 2026
latest-connect-version: 4.93.0
docname: config-topics
page-component-name: streaming
page-version: "25.3"
page-component-version: "25.3"
page-component-title: Streaming
page-relative-src-path: config-topics.adoc
page-edit-url: https://github.com/redpanda-data/docs/edit/v/25.3/modules/develop/pages/config-topics.adoc
description: Learn how to create topics, update topic configurations, and delete topics or records.
page-git-created-date: "2023-07-24"
page-git-modified-date: "2026-01-07"
support-status: supported
---

<!-- Source: https://docs.redpanda.com/streaming/25.3/develop/config-topics.md -->

Topics provide a way to organize events in a data streaming platform.

When you create a topic, the default cluster-level topic configurations are applied using the cluster configuration file, unless you specify different configurations. The following table shows the default cluster-level properties and their equivalent topic-level properties:

| Cluster property | Default | Topic property |
| --- | --- | --- |
| log_cleanup_policy | delete | cleanup.policy |
| retention_bytes | null (no limit) | retention.bytes |
| log_retention_ms | 604800000 ms (1 week) | retention.ms |
| log_segment_ms | null (no limit) | segment.ms |
| log_segment_size | 134217728 bytes (128 MiB) | segment.bytes |
| log_compression_type | producer | compression.type |
| log_message_timestamp_type | CreateTime | message.timestamp.type |
| kafka_batch_max_bytes | 1048576 bytes (1 MiB) | max.message.bytes |
| write_caching_default | false | write.caching |

These default settings are best suited to a one-broker cluster in a development environment. To learn how to modify the default cluster-wide configurations, see [Configure Cluster Properties](https://docs.redpanda.com/streaming/25.3/manage/cluster-maintenance/cluster-property-configuration/). Even if you set default values that work for most topics, you may still want to change some properties for a specific topic.

> 📝 **NOTE**
>
> For details about topic properties, see [Topic Configuration Properties](https://docs.redpanda.com/streaming/25.3/reference/properties/topic-properties/).

## [](#create-a-topic)Create a topic

Creating a topic can be as simple as specifying a name for your topic on the command line. For example, to create a topic named `xyz`, run:

```bash
rpk topic create xyz
```

This command creates a topic named `xyz` with one partition and one replica, because these are the default values set in the cluster configuration file. Replicas are copies of partitions that are distributed across different brokers, so if one broker goes down, other brokers still have a copy of the data.

### [](#choose-the-number-of-partitions)Choose the number of partitions

A partition acts as a log file where topic data is written. Dividing topics into partitions allows producers to write messages in parallel and consumers to read messages in parallel. The higher the number of partitions, the greater the throughput.

> 💡 **TIP**
>
> As a general rule, select a number of partitions that corresponds to the maximum number of consumers in any consumer group that will consume the data.

For example, suppose you plan to create a consumer group with 10 consumers. To create topic `xyz` with 10 partitions, run:

```bash
rpk topic create xyz -p 10
```

### [](#choose-the-replication-factor)Choose the replication factor

The default replication factor in the cluster configuration is set to 1. By choosing a replication factor greater than 1, you ensure that each partition has a copy of its data on at least one other broker. One replica acts as the leader, and the other replicas are followers.

To specify a replication factor of 3 for topic `xyz`, run:

```bash
rpk topic create xyz -r 3
```

> 📝 **NOTE**
>
> The replication factor must be an odd number. Redpanda Data recommends a replication factor of 3 for most use cases. Administrators may set a minimum required replication factor for any new topic in the cluster through the cluster-level [`minimum_topic_replications`](https://docs.redpanda.com/streaming/25.3/reference/properties/cluster-properties/#minimum_topic_replications) property.

> 💡 **TIP**
>
> If you enable [Tiered Storage](https://docs.redpanda.com/streaming/25.3/manage/tiered-storage/) on a topic, you can then use [topic recovery](https://docs.redpanda.com/streaming/25.3/manage/disaster-recovery/topic-recovery/) to restore data for a deleted topic.

## [](#update-topic-configurations)Update topic configurations

After you create a topic, you can update the topic property settings for all new data written to it. For example, you can add partitions or change the cleanup policy.

### [](#add-partitions)Add partitions

You can assign a certain number of partitions when you create a topic, and add partitions later. For example, suppose you add brokers to your cluster, and you want to take advantage of the additional processing power. To increase the number of partitions for existing topics, run:

```bash
rpk topic add-partitions [TOPICS...] --num [#]
```

Note that `--num <#>` is the number of partitions to _add_, not the total number of partitions.

> 📝 **NOTE**
>
> If a topic already has messages and you add partitions, the existing messages won’t be redistributed to the new partitions. If you require messages to be redistributed, then you must create a new topic with the new partition count, then stream the messages from the old topic to the new topic so they are appropriately distributed according to the new partition hashing.

### [](#change-the-replication-factor)Change the replication factor

Suppose you create a topic with the default replication factor of 1 (which is specified in the cluster properties configuration file). Now you want to change the replication factor to 3, so you can have two backups of topic data in case a broker goes down. To set the replication factor to 3, run:

```bash
rpk topic alter-config [TOPICS...] --set replication.factor=3
```

> 📝 **NOTE**
>
> The replication factor can’t exceed the number of Redpanda brokers. If you try to set a replication factor greater than the number of brokers, the request is rejected.

### [](#change-the-cleanup-policy)Change the cleanup policy

The cleanup policy determines how to clean up the partition log files when they reach a certain size:

-   `delete` deletes data based on age or log size. Topics retain all records until then.

-   `compact` compacts the data by only keeping the latest values for each KEY.

-   `compact,delete` combines both methods.


Unlike compacted topics, which keep only the most recent message for a given key, topics configured with a `delete` cleanup policy provide a running history of all changes for those topics.

> 📝 **NOTE**
>
> Starting in Redpanda v25.3, several topic properties support enhanced tristate behavior. Properties like `retention.ms`, `retention.bytes`, `segment.ms`, and others now distinguish between zero values (immediate eligibility for cleanup/compaction) and negative values (disable the feature entirely). Previously, zero and negative values were treated the same way. For the complete list of affected properties and detailed information, see [Redpanda v25.3 behavior changes](https://docs.redpanda.com/streaming/25.3/get-started/release-notes/redpanda/#behavior-changes). Review your topic configurations if you currently use zero values for these properties.

> ⚠️ **WARNING**
>
> All topic properties take effect immediately after being set. Do not modify properties on internal Redpanda topics (such as `__consumer_offsets`, `_schemas`, or other system topics) as this can cause cluster instability.

For example, to change a topic’s policy to `compact`, run:

```bash
rpk topic alter-config [TOPICS…] —-set cleanup.policy=compact
```

For details on compaction in Redpanda, see [Compaction settings](https://docs.redpanda.com/streaming/25.3/manage/cluster-maintenance/compaction-settings/).

### [](#configure-write-caching)Configure write caching

Write caching is a relaxed mode of [`acks=all`](https://docs.redpanda.com/streaming/25.3/develop/produce-data/configure-producers/#acksall) that provides better performance at the expense of durability. It acknowledges a message as soon as it is received and acknowledged on a majority of brokers, without waiting for it to be written to disk. This provides lower latency while still ensuring that a majority of brokers acknowledge the write.

Write caching applies to user topics. It does not apply to transactions or consumer offsets: data written in the context of a transaction and consumer offset commits is always written to disk and fsynced before being acknowledged to the client.

> 📝 **NOTE**
>
> For clusters in [development mode](https://docs.redpanda.com/streaming/25.3/reference/rpk/rpk-redpanda/rpk-redpanda-mode/#development-mode), write caching is enabled by default. For clusters in production mode, it is disabled by default.

Only enable write caching on workloads that can tolerate some data loss in the case of multiple, simultaneous broker failures. Leaving write caching disabled safeguards your data against complete data center or availability zone failures.

#### [](#configure-at-cluster-level)Configure at cluster level

To enable write caching by default in all user topics, set the cluster-level property [`write_caching_default`](https://docs.redpanda.com/streaming/25.3/reference/properties/cluster-properties/#write_caching_default):

`rpk cluster config set write_caching_default=true`

With `write_caching_default` set to true at the cluster level, Redpanda fsyncs to disk according to [`raft_replica_max_pending_flush_bytes`](https://docs.redpanda.com/streaming/25.3/reference/properties/cluster-properties/#raft_replica_max_pending_flush_bytes) and [`raft_replica_max_flush_delay_ms`](https://docs.redpanda.com/streaming/25.3/reference/properties/cluster-properties/#raft_replica_max_flush_delay_ms), whichever is reached first.

#### [](#configure-at-topic-level)Configure at topic level

To override the cluster-level setting at the topic level, set the topic-level property `write.caching`:

`rpk topic alter-config my_topic --set write.caching=true`

With `write.caching` enabled at the topic level, Redpanda fsyncs to disk according to `flush.ms` and `flush.bytes`, whichever is reached first.

### [](#remove-a-configuration-setting)Remove a configuration setting

You can remove a configuration that overrides the default setting, and the setting will use the default value again. For example, suppose you altered the cleanup policy to use `compact` instead of the default, `delete`. Now you want to return the policy setting to the default. To remove the configuration setting `cleanup.policy=compact`, run `rpk topic alter-config` with the `--delete` flag:

```bash
rpk topic alter-config [TOPICS...] --delete cleanup.policy
```

## [](#list-topic-configuration-settings)List topic configuration settings

To display all the configuration settings for a topic, run:

```bash
rpk topic describe <topic-name> -c
```

The `-c` flag limits the command output to just the topic configurations. This command is useful for checking the default configuration settings before you make any changes and for verifying changes after you make them.

The following command output displays after running `rpk topic describe test-topic`, where `test-topic` was created with default settings:

```bash
rpk topic describe test_topic
SUMMARY
=======
NAME        test_topic
PARTITIONS  1
REPLICAS    1

CONFIGS
=======
KEY                           VALUE                          SOURCE
cleanup.policy                delete                         DYNAMIC_TOPIC_CONFIG
compression.type              producer                       DEFAULT_CONFIG
max.message.bytes             1048576                        DEFAULT_CONFIG
message.timestamp.type        CreateTime                     DEFAULT_CONFIG
redpanda.datapolicy           function_name:  script_name:   DEFAULT_CONFIG
redpanda.remote.delete        true                           DEFAULT_CONFIG
redpanda.remote.read          false                          DEFAULT_CONFIG
redpanda.remote.write         false                          DEFAULT_CONFIG
retention.bytes               -1                             DEFAULT_CONFIG
retention.local.target.bytes  -1                             DEFAULT_CONFIG
retention.local.target.ms     86400000                       DEFAULT_CONFIG
retention.ms                  604800000                      DEFAULT_CONFIG
segment.bytes                 1073741824                     DEFAULT_CONFIG
```

Suppose you add two partitions, and increase the number of replicas to 3. The new command output confirms the changes in the `SUMMARY` section:

SUMMARY
=======
NAME        test\_topic
PARTITIONS  3
REPLICAS    3

## [](#delete-a-topic)Delete a topic

To delete a topic, run:

```bash
rpk topic delete <topic-name>
```

When a topic is deleted, its underlying data is deleted, too.

To delete multiple topics at a time, provide a space-separated list. For example, to delete two topics named `topic1` and `topic2`, run:

```bash
rpk topic delete topic1 topic2
```

You can also use the `-r` flag to specify one or more regular expressions; then, any topic names that match the pattern you specify are deleted. For example, to delete topics with names that start with “f” and end with “r”, run:

```bash
rpk topic  delete -r '^f.*' '.*r$'
```

Note that the first regular expression must start with the `^` symbol, and the last expression must end with the `$` symbol. This requirement helps prevent accidental deletions.

## [](#delete-records-from-a-topic)Delete records from a topic

Redpanda allows you to delete data from the beginning of a partition up to a specific offset (a monotonically increasing sequence number for records in a partition). Deleting records frees up disk space, which is especially helpful if your producers are pushing more data than anticipated in your retention plan. Delete records when you know that all consumers have read up to that given offset, and the data is no longer needed.

There are different ways to delete records from a topic, including using the [`rpk topic trim-prefix`](https://docs.redpanda.com/streaming/25.3/reference/rpk/rpk-topic/rpk-topic-trim-prefix/) command, using the `DeleteRecords` Kafka API with Kafka clients, or using Redpanda Console.

> 📝 **NOTE**
>
> -   To delete records, `cleanup.policy` must be set to `delete` or `compact,delete`.
>
> -   Object storage is deleted asynchronously. After messages are deleted, the partition’s start offset will have advanced, but garbage collection of deleted segments may not be complete.
>
> -   Similar to Kafka, after deleting records, local storage and object storage may still contain data for deleted offsets. (Redpanda does not truncate segments. Instead, it bumps the start offset, then it attempts to delete as many whole segments as possible.) Data before the new start offset is not visible to clients but could be read by someone with access to the local disk of a Redpanda node.

> ⚠️ **WARNING**
>
> When you delete records from a topic with a timestamp, Redpanda advances the partition start offset to the first record whose timestamp is after the threshold. If record timestamps are not in order with respect to offsets, this may result in unintended deletion of data. Before using a timestamp, verify that timestamps increase in the same order as offsets in the topic to avoid accidental data loss. For example:
>
> ```bash
> rpk topic consume <topic> -n 50 --format '%o %d{go[2006-01-02T15:04:05Z07:00]} %k %v'
> ```

## [](#next-steps)Next steps

[Configure Producers](https://docs.redpanda.com/streaming/25.3/develop/produce-data/configure-producers/)

## Suggested labs

-   [Stream Stock Market Data from a CSV file Using Node.js](https://docs.redpanda.com/labs/clients/stock-market-activity-nodejs/)
-   [Stream Stock Market Data from a CSV file Using Python](https://docs.redpanda.com/labs/clients/stock-market-activity-python/)
-   [Build a Chat Room Application with Redpanda and Golang](https://docs.redpanda.com/labs/clients/docker-go/)
-   [Build a Chat Room Application with Redpanda and Java](https://docs.redpanda.com/labs/clients/docker-java/)
-   [Build a Chat Room Application with Redpanda and Node.js](https://docs.redpanda.com/labs/clients/docker-nodejs/)
-   [Build a Chat Room Application with Redpanda and Python](https://docs.redpanda.com/labs/clients/docker-python/)
-   [Build a Chat Room Application with Redpanda and Rust](https://docs.redpanda.com/labs/clients/docker-rust/)

See more

[Search all labs](https://docs.redpanda.com/labs)