Skip to content

Commit 45a4ae2

Browse files
committed
Add rack-awareness in LBP manual
1 parent f0d6c9f commit 45a4ae2

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

manual/core/load_balancing/README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,24 @@ that case, the driver will connect to 127.0.0.1:9042, and use that node's datace
139139
for a better out-of-the-box experience for users who have just downloaded the driver; beyond that
140140
initial development phase, you should provide explicit contact points and a local datacenter.
141141

142-
##### Finding the local datacenter
142+
##### Rack awareness
143+
144+
The `DefaultLoadBalancingPolicy` and implicitly the `DcInferringLoadBalancingPolicy` prioritize replicas that are in the
145+
local datacenter, however, sometimes there is a need to prioritize replicas that are in the local rack and to not send
146+
queries to other replicas in the local datacenter. This will allow to avoid high network traffic between racks/availability zones
147+
and thus will reduce data transfer costs. The rack-awareness feature is optional and to enable it the local rack should
148+
be supplied through the configuration:
149+
150+
```
151+
datastax-java-driver.basic.load-balancing-policy {
152+
local-rack = rack1
153+
}
154+
```
155+
156+
The feature is disabled by default and unlike the local datacenter it will not be implicitly fetched from the provided
157+
contact points.
158+
159+
##### Finding the local datacenter & local rack
143160

144161
To check which datacenters are defined in a given cluster, you can run [`nodetool status`]. It will
145162
print information about each node in the cluster, grouped by datacenters. Here is an example:
@@ -165,17 +182,17 @@ UN <IP5> 1.5 TB 256 ? <ID5> rack2
165182
UN <IP6> 1.5 TB 256 ? <ID6> rack3
166183
```
167184

168-
To find out which datacenter should be considered local, you need to first determine which nodes the
169-
driver is going to be co-located with, then choose their datacenter as local. In case of doubt, you
185+
To find out which datacenter and rack(availability zone) should be considered local, you need to first determine which nodes the
186+
driver is going to be co-located with, then choose their datacenter and rack as local. In case of doubt, you
170187
can also use [cqlsh]; if cqlsh is co-located too in the same datacenter, simply run the command
171188
below:
172189

173190
```
174-
cqlsh> select data_center from system.local;
191+
cqlsh> select data_center,rack from system.local;
175192
176-
data_center
177-
-------------
178-
DC1
193+
data_center | rack
194+
-------------+-------
195+
datacenter1 | rack1
179196
```
180197

181198
#### Cross-datacenter failover

0 commit comments

Comments
 (0)