|  | 
|  | 1 | += Configure Topic Properties | 
|  | 2 | +:description: Learn how to configure topic properties to control Redpanda's behavior for individual topics, including retention, cleanup policies, and Tiered Storage settings. | 
|  | 3 | +:page-categories: Management | 
|  | 4 | + | 
|  | 5 | +Topic properties control Redpanda's behavior for individual topics, including data retention, cleanup policies, compression settings, and Tiered Storage configurations. These properties let you customize how Redpanda stores, processes, and manages data for each topic, overriding cluster-wide defaults when needed. | 
|  | 6 | + | 
|  | 7 | +Redpanda stores topic properties as metadata associated with each topic and replicates them across the cluster to ensure consistency. Many topic properties correspond to xref:manage:cluster-maintenance/cluster-property-configuration.adoc[cluster properties] that establish default values for all topics. When you set a topic property, it overrides the corresponding cluster default for that specific topic. | 
|  | 8 | + | 
|  | 9 | +include::develop:partial$topic-properties-warning.adoc[] | 
|  | 10 | + | 
|  | 11 | +For a complete reference of available topic properties and their corresponding cluster properties, see xref:reference:properties/topic-properties.adoc[Topic Configuration Properties]. | 
|  | 12 | + | 
|  | 13 | +== Configuration methods | 
|  | 14 | + | 
|  | 15 | +You can configure topic properties through multiple interfaces: | 
|  | 16 | + | 
|  | 17 | +* **rpk commands** - Use xref:reference:rpk/rpk-topic/rpk-topic-create.adoc[`rpk topic create`] with the `-c` flag to set properties during topic creation, or xref:reference:rpk/rpk-topic/rpk-topic-alter-config.adoc[`rpk topic alter-config`] to modify existing topics. | 
|  | 18 | +* **Kafka Admin API** - Any Kafka-compatible client can use the standard Admin API to configure topic properties. | 
|  | 19 | +* **Kubernetes Topic resources** - In Kubernetes deployments, configure topic properties using the `additionalConfig` field in Topic resources. See xref:manage:kubernetes/k-manage-topics.adoc[Manage Topics in Kubernetes]. | 
|  | 20 | +* **Redpanda Console** - Use the web interface to xref:console:ui/edit-topic-configuration.adoc[edit topic configuration] through a graphical interface. | 
|  | 21 | + | 
|  | 22 | +== Verify topic property configuration | 
|  | 23 | + | 
|  | 24 | +Use `rpk topic describe <topic>` to view topic properties and their configuration sources: | 
|  | 25 | + | 
|  | 26 | +``` | 
|  | 27 | +rpk topic describe my-topic | 
|  | 28 | +``` | 
|  | 29 | + | 
|  | 30 | +The output shows two sections: | 
|  | 31 | + | 
|  | 32 | +``` | 
|  | 33 | +SUMMARY | 
|  | 34 | +======= | 
|  | 35 | +NAME        my-topic | 
|  | 36 | +PARTITIONS  3 | 
|  | 37 | +REPLICAS    3 | 
|  | 38 | +
 | 
|  | 39 | +CONFIGS | 
|  | 40 | +======= | 
|  | 41 | +KEY                     VALUE          SOURCE | 
|  | 42 | +cleanup.policy          delete         DEFAULT_CONFIG | 
|  | 43 | +compression.type        producer       DEFAULT_CONFIG | 
|  | 44 | +retention.ms            604800000      DEFAULT_CONFIG | 
|  | 45 | +write.caching           true           DYNAMIC_TOPIC_CONFIG | 
|  | 46 | +``` | 
|  | 47 | + | 
|  | 48 | +The `SOURCE` column indicates how each property is configured: | 
|  | 49 | + | 
|  | 50 | +* `DEFAULT_CONFIG` - Redpanda's default value | 
|  | 51 | +* `DYNAMIC_TOPIC_CONFIG` - User-configured value | 
|  | 52 | + | 
|  | 53 | +The replication factor appears as REPLICAS in the SUMMARY section, not as replication.factor in the CONFIGS list. However, you need to use the `replication.factor` key when modifying the value with `rpk topic alter-config`. | 
|  | 54 | + | 
|  | 55 | +For partition-level details, add the `-p` flag: | 
|  | 56 | + | 
|  | 57 | +``` | 
|  | 58 | +rpk topic describe my-topic -p | 
|  | 59 | +``` | 
|  | 60 | + | 
|  | 61 | +This shows a different output focused on partition information: | 
|  | 62 | + | 
|  | 63 | +``` | 
|  | 64 | +PARTITION  LEADER  EPOCH  REPLICAS  LOG-START-OFFSET  HIGH-WATERMARK | 
|  | 65 | +0          1       2     [1 2 3]   0                 6 | 
|  | 66 | +1          2       4     [1 2 3]   0                 10 | 
|  | 67 | +2          3       1     [1 2 3]   0                 8 | 
|  | 68 | +``` | 
|  | 69 | + | 
|  | 70 | +== Examples | 
|  | 71 | + | 
|  | 72 | +The following examples show how to configure topic-level properties. Set a topic-level property for a topic to override the value of corresponding cluster property. | 
|  | 73 | + | 
|  | 74 | +=== Create topic with topic properties | 
|  | 75 | + | 
|  | 76 | +To set topic properties when creating a topic, use the xref:reference:rpk/rpk-topic/rpk-topic-create.adoc[rpk topic create] command with the `-c` option. | 
|  | 77 | + | 
|  | 78 | +For example, to create a topic with the `cleanup.policy` property set to `compact`: | 
|  | 79 | + | 
|  | 80 | +[tabs] | 
|  | 81 | +==== | 
|  | 82 | +Local:: | 
|  | 83 | ++ | 
|  | 84 | +-- | 
|  | 85 | +
 | 
|  | 86 | +```bash | 
|  | 87 | +rpk topic create -c cleanup.policy=compact <topic-name> | 
|  | 88 | +``` | 
|  | 89 | +
 | 
|  | 90 | +-- | 
|  | 91 | +Kubernetes:: | 
|  | 92 | ++ | 
|  | 93 | +-- | 
|  | 94 | +
 | 
|  | 95 | +```bash | 
|  | 96 | +kubectl exec <pod-name> -- rpk topic create -c cleanup.policy=compact <topic-name> | 
|  | 97 | +``` | 
|  | 98 | +
 | 
|  | 99 | +-- | 
|  | 100 | +==== | 
|  | 101 | + | 
|  | 102 | +To configure multiple properties for a topic, use the `-c` option for each property. | 
|  | 103 | + | 
|  | 104 | +For example, to create a topic with all necessary properties for Tiered Storage: | 
|  | 105 | + | 
|  | 106 | +[tabs] | 
|  | 107 | +==== | 
|  | 108 | +Local:: | 
|  | 109 | ++ | 
|  | 110 | +-- | 
|  | 111 | +
 | 
|  | 112 | +```bash | 
|  | 113 | +rpk topic create -c redpanda.remote.recovery=true -c redpanda.remote.write=true -c redpanda.remote.read=true <topic-name> | 
|  | 114 | +``` | 
|  | 115 | +
 | 
|  | 116 | +-- | 
|  | 117 | +Kubernetes:: | 
|  | 118 | ++ | 
|  | 119 | +-- | 
|  | 120 | +
 | 
|  | 121 | +```bash | 
|  | 122 | +kubectl exec <pod-name> -- rpk topic create -c redpanda.remote.recovery=true -c redpanda.remote.write=true -c redpanda.remote.read=true <topic-name> | 
|  | 123 | +``` | 
|  | 124 | +
 | 
|  | 125 | +-- | 
|  | 126 | +==== | 
|  | 127 | + | 
|  | 128 | +=== Modify topic properties | 
|  | 129 | + | 
|  | 130 | +To modify topic properties of an existing topic, use the xref:reference:rpk/rpk-topic/rpk-topic-alter-config.adoc[rpk topic alter-config] command. | 
|  | 131 | + | 
|  | 132 | +For example, to modify a topic's `retention.ms` property: | 
|  | 133 | + | 
|  | 134 | +[tabs] | 
|  | 135 | +==== | 
|  | 136 | +Local:: | 
|  | 137 | ++ | 
|  | 138 | +-- | 
|  | 139 | +
 | 
|  | 140 | +```bash | 
|  | 141 | +rpk topic alter-config <topic-name> --set retention.ms=<retention-time> | 
|  | 142 | +``` | 
|  | 143 | +
 | 
|  | 144 | +-- | 
|  | 145 | +Kubernetes:: | 
|  | 146 | ++ | 
|  | 147 | +-- | 
|  | 148 | +
 | 
|  | 149 | +```bash | 
|  | 150 | +kubectl exec <pod-name> -- rpk topic alter-config <topic-name> --set retention.ms=<retention-time> | 
|  | 151 | +``` | 
|  | 152 | +
 | 
|  | 153 | +-- | 
|  | 154 | +==== | 
|  | 155 | + | 
|  | 156 | +=== Configure topic properties with Kubernetes | 
|  | 157 | + | 
|  | 158 | +In Kubernetes deployments, configure topic properties using the `additionalConfig` field in Topic resources: | 
|  | 159 | + | 
|  | 160 | +```yaml | 
|  | 161 | +apiVersion: cluster.redpanda.com/v1alpha2 | 
|  | 162 | +kind: Topic | 
|  | 163 | +metadata: | 
|  | 164 | +  name: example-topic | 
|  | 165 | +spec: | 
|  | 166 | +  partitions: 3 | 
|  | 167 | +  replicationFactor: 3 | 
|  | 168 | +  additionalConfig: | 
|  | 169 | +    cleanup.policy: "compact" | 
|  | 170 | +    retention.ms: "604800000" | 
|  | 171 | +    segment.ms: "86400000" | 
|  | 172 | +``` | 
|  | 173 | + | 
|  | 174 | +Apply the configuration: | 
|  | 175 | + | 
|  | 176 | +```bash | 
|  | 177 | +kubectl apply -f topic-config.yaml | 
|  | 178 | +``` | 
|  | 179 | + | 
|  | 180 | +== Common topic property categories | 
|  | 181 | + | 
|  | 182 | +The most commonly configured topic properties fall into these main categories: | 
|  | 183 | + | 
|  | 184 | +=== Disk space management | 
|  | 185 | + | 
|  | 186 | +Redpanda manages disk space through two main mechanisms: **compaction** (removing duplicate keys) and **retention** (removing old data).  | 
|  | 187 | + | 
|  | 188 | +Choose your cleanup strategy with xref:reference:properties/topic-properties.adoc#cleanuppolicy[`cleanup.policy`]: | 
|  | 189 | +- `delete` - Remove old data based on time or size limits | 
|  | 190 | +- `compact` - Keep only the latest value for each key | 
|  | 191 | +- `compact,delete` - Combine both strategies | 
|  | 192 | + | 
|  | 193 | +=== Compaction | 
|  | 194 | + | 
|  | 195 | +When using `cleanup.policy=compact` or `cleanup.policy=compact,delete`, configure: | 
|  | 196 | + | 
|  | 197 | +- xref:reference:properties/topic-properties.adoc#mincleanabledirtyratio[`min.cleanable.dirty.ratio`] - Control when compaction triggers based on dirty data ratio | 
|  | 198 | +- xref:reference:properties/topic-properties.adoc#maxcompactionlagms[`max.compaction.lag.ms`] - Set maximum time before compaction is forced | 
|  | 199 | +- xref:reference:properties/topic-properties.adoc#mincompactionlagms[`min.compaction.lag.ms`] - Set minimum time before compaction can occur | 
|  | 200 | + | 
|  | 201 | +=== Retention | 
|  | 202 | + | 
|  | 203 | +When using `cleanup.policy=delete` or `cleanup.policy=compact,delete`, configure: | 
|  | 204 | + | 
|  | 205 | +- xref:reference:properties/topic-properties.adoc#retentionbytes[`retention.bytes`] - Maximum size before cleanup (size-based retention) | 
|  | 206 | +- xref:reference:properties/topic-properties.adoc#retentionms[`retention.ms`] - Maximum age before cleanup (time-based retention) | 
|  | 207 | +- xref:reference:properties/topic-properties.adoc#segmentbytes[`segment.bytes`] - Control how frequently cleanup can occur by setting segment size | 
|  | 208 | + | 
|  | 209 | +=== Performance | 
|  | 210 | + | 
|  | 211 | +Essential performance tuning properties: | 
|  | 212 | + | 
|  | 213 | +- xref:reference:properties/topic-properties.adoc#writecaching[`write.caching`] - Cache writes for lower latency with `acks=all` | 
|  | 214 | +- xref:reference:properties/topic-properties.adoc#maxmessagebytes[`max.message.bytes`] - Set maximum message size | 
|  | 215 | +- xref:reference:properties/topic-properties.adoc#replicationfactor[`replication.factor`] - Number of replicas for durability vs. performance | 
|  | 216 | + | 
|  | 217 | +For complete details about all available topic properties, see xref:reference:properties/topic-properties.adoc[Topic Configuration Properties]. | 
|  | 218 | + | 
|  | 219 | +== Related topics | 
|  | 220 | + | 
|  | 221 | +* xref:reference:properties/topic-properties.adoc[Topic Configuration Properties] - Complete reference of all available topic properties | 
|  | 222 | +* xref:manage:cluster-maintenance/cluster-property-configuration.adoc[Configure Cluster Properties] - Configure cluster-wide defaults | 
|  | 223 | +* xref:develop:config-topics.adoc[Manage Topics] - Create and manage topics | 
|  | 224 | +* xref:manage:kubernetes/k-manage-topics.adoc[Manage Topics in Kubernetes] - Topic management in Kubernetes deployments | 
|  | 225 | +* xref:console:ui/edit-topic-configuration.adoc[Edit Topic Configuration in Redpanda Console] - Graphical topic configuration | 
0 commit comments