Skip to content

Commit 2acc2f7

Browse files
kbatuigasasimms41Feediver1Deflaimun
authored
Leader pinning (#809)
Co-authored-by: Angela Simms <[email protected]> Co-authored-by: Joyce Fee <[email protected]> Co-authored-by: Paulo Borges <[email protected]>
1 parent dd77c24 commit 2acc2f7

File tree

4 files changed

+83
-1
lines changed

4 files changed

+83
-1
lines changed

modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
** xref:develop:produce-data/index.adoc[Produce Data]
2727
*** xref:develop:produce-data/configure-producers.adoc[]
2828
*** xref:develop:produce-data/idempotent-producers.adoc[Idempotent Producers]
29+
*** xref:develop:produce-data/leader-pinning.adoc[]
2930
** xref:develop:consume-data/index.adoc[Consume Data]
3031
*** xref:develop:consume-data/consumer-offsets.adoc[Consumer Offsets]
3132
*** xref:develop:consume-data/follower-fetching.adoc[Follower Fetching]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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[]

modules/reference/pages/properties/cluster-properties.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,14 +820,22 @@ The recursion depth after which debug logging is enabled automatically for the l
820820

821821
=== default_leaders_preference
822822

823-
Default settings for preferred location of topic partition leaders. It can be either "none" (no preference), or "racks:<rack1>,<rack2>,..." (prefer brokers with rack id from the list).
823+
Default settings for preferred location of topic partition leaders. It can be either "none" (no preference), or "racks:<rack1>,<rack2>,..." (prefer brokers with rack ID from the list).
824+
825+
The list can contain one or more rack IDs. If you specify multiple IDs, Redpanda tries to distribute the partition leader locations equally across brokers in these racks.
826+
827+
If config_ref:enable_rack_awareness,true,properties/cluster-properties[] is set to `false`, leader pinning is disabled across the cluster.
824828

825829
*Requires restart:* No
826830

827831
*Visibility:* `user`
828832

829833
*Default:* `none`
830834

835+
*Related topics*:
836+
837+
- xref:develop:produce-data/leader-pinning.adoc[Leader pinning]
838+
831839
---
832840

833841
=== default_num_windows

modules/reference/pages/properties/topic-properties.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,28 @@ CAUTION: Setting `redpanda.remote.readreplica` together with either `redpanda.re
508508

509509
Configure Redpanda-specific topic properties.
510510

511+
[[redpandaleaderspreference]]
512+
==== redpanda.leaders.preference
513+
514+
The preferred location (rack) for partition leaders of a topic.
515+
516+
This property inherits the value from the config_ref:default_leaders_preference,true,properties/cluster-properties[] cluster configuration property. You may override the cluster-wide setting by specifying the value for individual topics.
517+
518+
If the cluster configuration property config_ref:enable_rack_awareness,true,properties/cluster-properties[] is set to `false`, leader pinning is disabled across the cluster.
519+
520+
**Default**: `none`
521+
522+
**Values**:
523+
524+
- `none`: Opt out the topic from leader pinning.
525+
- `racks:<rack1>[,<rack2>,...]`: Specify the preferred location (rack) of all topic partition leaders. The list can contain one or more rack IDs. If you specify multiple IDs, Redpanda tries to distribute the partition leader locations equally across brokers in these racks.
526+
527+
**Related topics**:
528+
529+
- xref:develop:produce-data/leader-pinning.adoc[Leader pinning]
530+
531+
---
532+
511533
==== replication.factor
512534

513535
The number of replicas of a topic to save in different nodes (brokers) of a cluster.

0 commit comments

Comments
 (0)