Module resty.dns.balancer.least_connections
Least-connections balancer.
This balancer implements a least-connections algorithm. The balancer will honour the weights. See the base-balancer for details on how the weights are set.
NOTE: This documentation only described the altered user methods/properties
from the base-balancer. See the user properties
from the balancer_base
for a
complete overview.
Info:
- Copyright: 2016-2020 Kong Inc. All rights reserved.
- License: Apache 2.0
- Author: Thijs Schreijer
Functions
new (opts) | Creates a new balancer. |
Functions
- new (opts)
-
Creates a new balancer. The balancer is based on a binary heap tracking the number of active connections. The number of connections assigned will be relative to the weight.
The options table has the following fields, additional to the ones from the
balancer_base
;hosts
(optional) containing hostnames, ports and weights. If omitted, ports and weights default respectively to 80 and 10.
Parameters:
- opts table with options
Returns:
-
new balancer object or nil+error
Usage:
-- hosts example local hosts = { "konghq.com", -- name only, as string { name = "github.com" }, -- name only, as table { name = "getkong.org", port = 80, weight = 25 }, -- fully specified, as table }