openresty / lua-resty-balancer

A generic consistent hash implementation for OpenResty/Lua
322 stars 77 forks source link

Round Robin is always peeking the largest weight even using random node id #47

Closed jizhuozhi closed 1 year ago

jizhuozhi commented 1 year ago

When the node with the largest weight is unique, no matter how the initial last_id is selected, the first peeked node will always be the node with the largest weight, which will cause this node to overheat.

For example, we have nodes with weights 5, 1, 1, 1, 1, the distribution is always

1
1
1
1
1
2
3
4
5

because when cw = max_weight, only the node with the largest weight satisfies condition weight >= cw