Targets and balancing
Target groups, server weights, backups and balancing strategies.
A route forwards to a target group: one or more servers that can answer the request.
Balancing strategies
| Strategy | How a server is chosen |
|---|---|
| Round robin | Each server in turn. The default. |
| Weighted round robin | In turn, in proportion to each server's weight. |
| Least connections | The server with the fewest active connections. |
| IP hash | Consistent hashing on the client IP, so a client keeps reaching the same server. |
| Random | A random server. |
Weights and backups
- Weight: a server with a higher weight receives more traffic. Default
1. - Backup: a backup server receives traffic only when the primary servers are unavailable.
Encrypted connections to targets
Gateway can connect to targets over TLS. It verifies the target's certificate and hostname by default.
Connection reuse
Gateway keeps a pool of connections to each target group and reuses idle connections. See Defaults.
Example
In the current Gateway configuration format, a target group with weighted servers and a balancing strategy looks like this. Strategy values are round_robin, weighted_round_robin, least_conn, ip_hash and random.
{
"upstreams": [
{
"name": "api",
"load_balancer": "weighted_round_robin",
"servers": [
{ "address": "10.0.0.1", "port": 8080, "weight": 1 },
{ "address": "10.0.0.2", "port": 8080, "weight": 2 }
]
}
],
"routes": [{ "path_prefix": "/api/", "upstream": "api" }]
}Available at release
Which targets you can route to through id0n, and how you apply configuration, are published with the Gateway interface reference. Field names may change before release.