Add HighestRandomWeight Loadbalancing Algorithm
This commit is contained in:
parent
9b42b5b930
commit
02443545e7
10 changed files with 936 additions and 112 deletions
|
|
@ -175,6 +175,7 @@ Two load balancing algorithms are supported:
|
|||
|
||||
- Weighed round-robin (wrr)
|
||||
- Power of two choices (p2c)
|
||||
- Highest Random Weight (hrw)
|
||||
|
||||
##### WRR
|
||||
|
||||
|
|
@ -242,6 +243,34 @@ Power of two choices algorithm is a load balancing strategy that selects two ser
|
|||
url = "http://private-ip-server-3/"
|
||||
```
|
||||
|
||||
##### HRW
|
||||
|
||||
HighestRandomWeight, also called RendezVous hashing allows to loadbalance clients in a pool of services or servers.
|
||||
|
||||
??? example "Load Balancing HRW with-- Using the [File Provider](../../providers/file.md)"
|
||||
|
||||
```yaml tab="YAML"
|
||||
## Dynamic configuration
|
||||
http:
|
||||
services:
|
||||
my-service:
|
||||
loadBalancer:
|
||||
type: hrw
|
||||
servers:
|
||||
- url: "http://private-ip-server-1/"
|
||||
- url: "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
```toml tab="TOML"
|
||||
## Dynamic configuration
|
||||
[http.services]
|
||||
[http.services.my-service.loadBalancer]
|
||||
[[http.services.my-service.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
[[http.services.my-service.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
#### Sticky sessions
|
||||
|
||||
When sticky sessions are enabled, a `Set-Cookie` header is set on the initial response to let the client know which server handles the first response.
|
||||
|
|
@ -1253,6 +1282,147 @@ http:
|
|||
url = "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
### Highest Random Weight (service)
|
||||
|
||||
The HRW is able to load balance the requests between multiple services based on weights.
|
||||
|
||||
This strategy is only available to load balance between [services](./index.md) and not between [servers](./index.md#servers).
|
||||
|
||||
!!! info "Supported Providers"
|
||||
|
||||
This strategy can be defined currently with the [File](../../providers/file.md) or [IngressRoute](../../providers/kubernetes-crd.md) providers.
|
||||
|
||||
```yaml tab="YAML"
|
||||
## Dynamic configuration
|
||||
http:
|
||||
services:
|
||||
app:
|
||||
highestRandomWeight:
|
||||
services:
|
||||
- name: appv1
|
||||
weight: 3
|
||||
- name: appv2
|
||||
weight: 1
|
||||
|
||||
appv1:
|
||||
loadBalancer:
|
||||
type: hrw
|
||||
servers:
|
||||
- url: "http://private-ip-server-1/"
|
||||
|
||||
appv2:
|
||||
loadBalancer:
|
||||
type: hrw
|
||||
servers:
|
||||
- url: "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
```toml tab="TOML"
|
||||
## Dynamic configuration
|
||||
[http.services]
|
||||
[http.services.app]
|
||||
[[http.services.app.highestRandomWeight.services]]
|
||||
name = "appv1"
|
||||
weight = 3
|
||||
[[http.services.app.highestRandomWeight.services]]
|
||||
name = "appv2"
|
||||
weight = 1
|
||||
|
||||
[http.services.appv1]
|
||||
[http.services.appv1.loadBalancer]
|
||||
type = "hrw"
|
||||
[[http.services.appv1.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
|
||||
[http.services.appv2]
|
||||
[http.services.appv2.loadBalancer]
|
||||
type = "hrw"
|
||||
[[http.services.appv2.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
#### Health Check
|
||||
|
||||
HealthCheck enables automatic self-healthcheck for this service, i.e. whenever
|
||||
one of its children is reported as down, this service becomes aware of it, and
|
||||
takes it into account (i.e. it ignores the down child) when running the
|
||||
load-balancing algorithm. In addition, if the parent of this service also has
|
||||
HealthCheck enabled, this service reports to its parent any status change.
|
||||
|
||||
!!! info "All or nothing"
|
||||
|
||||
If HealthCheck is enabled for a given service, but any of its descendants does
|
||||
not have it enabled, the creation of the service will fail.
|
||||
|
||||
HealthCheck on Weighted services can be defined currently only with the [File](../../providers/file.md) provider.
|
||||
|
||||
```yaml tab="YAML"
|
||||
## Dynamic configuration
|
||||
http:
|
||||
services:
|
||||
app:
|
||||
highestRandomWeight:
|
||||
healthCheck: {}
|
||||
services:
|
||||
- name: appv1
|
||||
weight: 3
|
||||
- name: appv2
|
||||
weight: 1
|
||||
|
||||
appv1:
|
||||
loadBalancer:
|
||||
type: hrw
|
||||
healthCheck:
|
||||
path: /status
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
servers:
|
||||
- url: "http://private-ip-server-1/"
|
||||
|
||||
appv2:
|
||||
loadBalancer:
|
||||
type: hrw
|
||||
healthCheck:
|
||||
path: /status
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
servers:
|
||||
- url: "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
```toml tab="TOML"
|
||||
## Dynamic configuration
|
||||
[http.services]
|
||||
[http.services.app]
|
||||
[http.services.app.highestRandomWeight.healthCheck]
|
||||
[[http.services.app.highestRandomWeight.services]]
|
||||
name = "appv1"
|
||||
weight = 3
|
||||
[[http.services.app.highestRandomWeight.services]]
|
||||
name = "appv2"
|
||||
weight = 1
|
||||
|
||||
[http.services.appv1]
|
||||
[http.services.appv1.loadBalancer]
|
||||
type="hrw"
|
||||
[http.services.appv1.loadBalancer.healthCheck]
|
||||
path = "/health"
|
||||
interval = "10s"
|
||||
timeout = "3s"
|
||||
[[http.services.appv1.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
|
||||
[http.services.appv2]
|
||||
[http.services.appv2.loadBalancer]
|
||||
type="hrw"
|
||||
[http.services.appv2.loadBalancer.healthCheck]
|
||||
path = "/health"
|
||||
interval = "10s"
|
||||
timeout = "3s"
|
||||
[[http.services.appv2.loadBalancer.servers]]
|
||||
url = "http://private-ip-server-2/"
|
||||
```
|
||||
|
||||
### Mirroring (service)
|
||||
|
||||
The mirroring is able to mirror requests sent to a service to other services.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue