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
|
|
@ -5,6 +5,7 @@ local dns_util = require("util.dns")
|
|||
local configuration = require("configuration")
|
||||
local round_robin = require("balancer.round_robin")
|
||||
local chash = require("balancer.chash")
|
||||
local chashsubset = require("balancer.chashsubset")
|
||||
local sticky = require("balancer.sticky")
|
||||
local ewma = require("balancer.ewma")
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ local DEFAULT_LB_ALG = "round_robin"
|
|||
local IMPLEMENTATIONS = {
|
||||
round_robin = round_robin,
|
||||
chash = chash,
|
||||
chashsubset = chashsubset,
|
||||
sticky = sticky,
|
||||
ewma = ewma,
|
||||
}
|
||||
|
|
@ -29,8 +31,12 @@ local function get_implementation(backend)
|
|||
|
||||
if backend["sessionAffinityConfig"] and backend["sessionAffinityConfig"]["name"] == "cookie" then
|
||||
name = "sticky"
|
||||
elseif backend["upstream-hash-by"] then
|
||||
name = "chash"
|
||||
elseif backend["upstreamHashByConfig"] and backend["upstreamHashByConfig"]["upstream-hash-by"] then
|
||||
if backend["upstreamHashByConfig"]["upstream-hash-by-subset"] then
|
||||
name = "chashsubset"
|
||||
else
|
||||
name = "chash"
|
||||
end
|
||||
end
|
||||
|
||||
local implementation = IMPLEMENTATIONS[name]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue