Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration/pgdog.toml/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Relative weight used when [`load_balancing_strategy`](general.md#load_balancing_

For example, weights of `200` and `100` give the first server approximately twice as much traffic as the second.

Setting this to `0` will effectively disable the server for load balancing, but it will still be used for failover if all other servers are unavailable.

Accepts integers from `0` to `255`. This setting has no effect with other load balancing strategies.

Default: **`255`**
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/pgdog.toml/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Which strategy to use for load balancing read queries. See [load balancer](../..
- `random`
- `least_active_connections`
- `round_robin`
- `weighted_round_robin`

Default: **`random`**

Expand Down
38 changes: 38 additions & 0 deletions docs/features/load-balancer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The load balancer is configurable and can distribute read queries between replic
* [Round robin](#round-robin) (default)
* [Random](#random)
* [Least active connections](#least-active-connections)
* [Weighted round robin](#weighted-round-robin)

Choosing the best strategy depends on your query workload and the size of the databases. Each strategy has its pros and cons. If you're not sure, using the **round robin** strategy usually works well for most deployments.

Expand Down Expand Up @@ -94,6 +95,43 @@ This algorithm is useful when you want to "bin pack" the replica cluster. It ass
loadBalancingStrategy: least_active_connections
```

### Weighted round robin

Weighted round-robin, distributing requests proportionally to configured weights. To configure weight per database use [`lb_weight`](../../configuration/pgdog.toml/databases.md#lb_weight) configuration.

##### Configuration

=== "pgdog.toml"
```toml
[general]
load_balancing_strategy = "weighted_round_robin"

[[databases]]
name = "prod"
role = "replica"
host = "10.0.0.2"
lb_weight = 200

[[databases]]
name = "prod"
role = "replica"
host = "10.0.0.3"
lb_weight = 55
```
=== "Helm chart"
```yaml
loadBalancingStrategy: weighted_round_robin
databases:
- name: prod
role: replica
host: 10.0.0.2
lbWeight: 200
- name: prod
role: replica
host: 10.0.0.3
lbWeight: 55
```


## Single endpoint

Expand Down
Loading