|
| 1 | += Leader Pinning |
| 2 | +// tag::single-source[] |
| 3 | +:description: Learn about leader pinning and how to configure a preferred partition leader location based on cloud availability zones or regions. |
| 4 | + |
| 5 | +Produce requests that write data to Redpanda topics go through the topic partition leader, which syncs messages across its follower replicas. For a Redpanda cluster deployed across multiple availability zones (AZs), leader pinning ensures that a topic's partition leaders are geographically closer to clients, which helps decrease networking costs and guarantees lower latency. |
| 6 | + |
| 7 | +If consumers are located in the same preferred region or AZ for leader pinning, and you have not set up xref:develop:consume-data/follower-fetching.adoc[follower fetching], leader pinning can also help reduce networking costs on consume requests. |
| 8 | + |
| 9 | +== Prerequisites |
| 10 | + |
| 11 | +[NOTE] |
| 12 | +==== |
| 13 | +include::shared:partial$enterprise-license.adoc[] |
| 14 | +==== |
| 15 | + |
| 16 | +Before you can enable leader pinning, you must xref:manage:rack-awareness.adoc#configure-rack-awareness[configure rack awareness] on the cluster. If the config_ref:enable_rack_awareness,true,properties/cluster-properties[] cluster configuration property is set to `false`, leader pinning is disabled across the cluster. |
| 17 | + |
| 18 | +== Configure leader pinning |
| 19 | + |
| 20 | +You can use both a topic configuration property and a cluster configuration property to configure leader pinning. |
| 21 | + |
| 22 | +You can set the topic configuration property for individual topics only, or set the cluster-wide configuration property that will enable leader pinning by default for all topics. You can also use a combination in which a default setting applies across the cluster, and you toggle the setting on or off for specific topics. |
| 23 | + |
| 24 | +This configuration is based on the following scenario: you have Redpanda deployed in a multi-AZ or multi-region cluster, and you have configured each broker so that the config_ref:rack,true,properties/broker-properties[] configuration property contains rack IDs corresponding to the AZ IDs: |
| 25 | + |
| 26 | +* Set the topic configuration property xref:reference:properties/topic-properties.adoc#redpandaleaderspreference[`redpanda.leaders.preference`]. The property accepts the following string values: |
| 27 | ++ |
| 28 | +-- |
| 29 | +** `none`: Opt out the topic from leader pinning. |
| 30 | +** `racks:<rack1>[,<rack2>,...]`: Specify the preferred location (rack) of all topic partition leaders. The list can contain one or more rack IDs, and you can list the IDs in any order. Spaces in the list are ignored, for example: `racks:rack1,rack2` and `racks: rack1, rack2` are equivalent. You cannot specify empty rack IDs, for example: `racks: rack1,,rack2`. If you specify multiple IDs, Redpanda tries to distribute the partition leader locations equally across brokers in these racks. |
| 31 | +-- |
| 32 | ++ |
| 33 | +This property inherits the default value from the cluster property `default_leaders_preference`. |
| 34 | + |
| 35 | +* Set the cluster configuration property config_ref:default_leaders_preference,true,properties/cluster-properties[], which specifies the default leader pinning configuration for all topics that don’t have `redpanda.leaders.preference` explicitly set. It accepts values in the same format as `redpanda.leaders.preference`. Default: `none` |
| 36 | ++ |
| 37 | +This property also affects internal topics, such as `__consumer_offsets` and transaction coordinators. All offset tracking and transaction coordination requests get placed within the preferred regions or AZs for all clients, so you see end-to-end latency and networking cost benefits. |
| 38 | + |
| 39 | +If there is more than one broker in the preferred AZ (or AZs), leader pinning distributes partition leaders uniformly across brokers in the AZ. |
| 40 | + |
| 41 | +== Leader pinning failover across availability zones |
| 42 | + |
| 43 | +If there are three AZs: A, B, and C, and A becomes unavailable, the failover behavior is as follows: |
| 44 | + |
| 45 | +* A topic with "A" as the preferred leader AZ will have its partition leaders uniformly distributed across B and C. |
| 46 | +* A topic with "A,B" as the preferred leader AZs will have its partition leaders in B. |
| 47 | +* A topic with “B” as the preferred leader AZ will have its partition leaders in B as well. |
| 48 | + |
| 49 | +== Suggested reading |
| 50 | + |
| 51 | +* xref:develop:consume-data/follower-fetching.adoc[] |
0 commit comments