Skip to content

Commit 86c03dd

Browse files
committed
Docs: Informations about shard-aware LBPs
1 parent 48aa642 commit 86c03dd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/source/load-balancing/load-balancing.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Introduction
44

5-
The driver uses a load balancing policy to determine which node(s) to contact
5+
The driver uses a load balancing policy to determine which node(s) and shard(s) to contact
66
when executing a query. Load balancing policies implement the
77
`LoadBalancingPolicy` trait, which contains methods to generate a load
88
balancing plan based on the query information and the state of the cluster.
@@ -15,11 +15,13 @@ using `SessionBuilder::host_filter` method.
1515
## Plan
1616

1717
When a query is prepared to be sent to the database, the load balancing policy
18-
constructs a load balancing plan. This plan is essentially a list of nodes to
18+
constructs a load balancing plan. This plan is essentially a list of pairs of node and optional shard to
1919
which the driver will try to send the query. The first elements of the plan are
20-
the nodes which are the best to contact (e.g. they might be replicas for the
20+
the nodes+shards which are the best to contact (e.g. they might be replicas for the
2121
requested data or have the best latency).
2222

23+
In this chapter, "element" will refer to a pair of node and optional shard.
24+
2325
## Policy
2426

2527
The Scylla/Cassandra driver provides a default load balancing policy (see
@@ -84,15 +86,15 @@ first element of the load balancing plan is needed, so it's usually unnecessary
8486
to compute entire load balancing plan. To optimize this common case, the
8587
`LoadBalancingPolicy` trait provides two methods: `pick` and `fallback`.
8688

87-
`pick` returns the first node to contact for a given query, which is usually
89+
`pick` returns the first element to contact for a given query, which is usually
8890
the best based on a particular load balancing policy. If `pick` returns `None`,
8991
then `fallback` will not be called.
9092

91-
`fallback`, returns an iterator that provides the rest of the nodes in the load
92-
balancing plan. `fallback` is called only when using the initial picked node
93+
`fallback`, returns an iterator that provides the rest of the elements in the load
94+
balancing plan. `fallback` is called only when using the initial picked element
9395
fails (or when executing speculatively).
9496

95-
It's possible for the `fallback` method to include the same node that was
97+
It's possible for the `fallback` method to include the same element that was
9698
returned by the `pick` method. In such cases, the query execution layer filters
9799
out the picked node from the iterator returned by `fallback`.
98100

0 commit comments

Comments
 (0)