Consistent hashing to a subset of nodes. It works like consistent hash,
but instead of mapping to a single node, we map to a subset of nodes.
This commit is contained in:
parent
29118750be
commit
60b983503b
17 changed files with 434 additions and 17 deletions
|
|
@ -186,10 +186,16 @@ nginx.ingress.kubernetes.io/auth-realm: "realm string"
|
|||
|
||||
NGINX supports load balancing by client-server mapping based on [consistent hashing](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash) for a given key. The key can contain text, variables or any combination thereof. This feature allows for request stickiness other than client IP or cookies. The [ketama](http://www.last.fm/user/RJ/journal/2007/04/10/392555/) consistent hashing method will be used which ensures only a few keys would be remapped to different servers on upstream group changes.
|
||||
|
||||
There is a special mode of upstream hashing called subset. In this mode, upstream servers are grouped into subsets, and stickiness works by mapping keys to a subset instead of individual upstream servers. Specific server is chosen uniformly at random from the selected sticky subset. It provides a balance between stickiness and load distribution.
|
||||
|
||||
To enable consistent hashing for a backend:
|
||||
|
||||
`nginx.ingress.kubernetes.io/upstream-hash-by`: the nginx variable, text value or any combination thereof to use for consistent hashing. For example `nginx.ingress.kubernetes.io/upstream-hash-by: "$request_uri"` to consistently hash upstream requests by the current request URI.
|
||||
|
||||
"subset" hashing can be enabled setting `nginx.ingress.kubernetes.io/upstream-hash-by-subset`: "true". This maps requests to subset of nodes instead of a single one. `upstream-hash-by-subset-size` determines the size of each subset (default 3).
|
||||
|
||||
Please check the [chashsubset](../../examples/chashsubset/deployment.yaml) example.
|
||||
|
||||
### Custom NGINX load balancing
|
||||
|
||||
This is similar to [`load-balance` in ConfigMap](./configmap.md#load-balance), but configures load balancing algorithm per ingress.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue