Skip to content

Balancing

Yaroslav Pogrebnyak edited this page Jun 29, 2016 · 8 revisions

Balancing strategy is a way gobetween select backends (from discovery backends pool) for new client connection. It's defined in balance property within [servers.<name>], and is weight by default.

weight

Select backend from discovery pool with probability based on backends weights. For example, for backends pool:

[
    "host1 weight=1"
    "host2 weight=2"
]

host1 will be selected with probability 75%, and host2 will be selected in 25% cases.

If weight for all backends are the same, backend will be selected randomly.

iphash

Target backend will be calculated using hash function of client ip address mod backends count. Note if backends pool changes (for example, due discovery), client may be proxied to a different backend.

leastconn

gobetween will select backends with least connections to it.

roundrobin

It's most simple balancing strategy, and each new connection will be proxies to next backend in the backends pool successively.