diff --git a/docs/configuration/pgdog.toml/databases.md b/docs/configuration/pgdog.toml/databases.md index 331a6f8b..de3f0817 100644 --- a/docs/configuration/pgdog.toml/databases.md +++ b/docs/configuration/pgdog.toml/databases.md @@ -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`** diff --git a/docs/configuration/pgdog.toml/general.md b/docs/configuration/pgdog.toml/general.md index 07bd4e10..c942381f 100644 --- a/docs/configuration/pgdog.toml/general.md +++ b/docs/configuration/pgdog.toml/general.md @@ -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`** diff --git a/docs/features/load-balancer/index.md b/docs/features/load-balancer/index.md index 9aaedc7f..63aa841a 100644 --- a/docs/features/load-balancer/index.md +++ b/docs/features/load-balancer/index.md @@ -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. @@ -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