840963657 opened a new issue, #7088:
URL: https://github.com/apache/apisix/issues/7088
### Current Behavior
When I test least-connection,I found the result has nothing to do with
active connection;**client always visit the node with the largest weight**。
Then I read source code,found apisix use 1/weight to choose node,Not used
active connection;
apisix-apisix-balancer-least_conn.lua
`
function _M.new(up_nodes, upstream)
local servers_heap = binaryHeap.minUnique(least_score)
for server, weight in pairs(up_nodes) do
local score = 1 / weight
-- Note: the argument order of insert is different from others
servers_heap:insert({
server = server,
effect_weight = 1 / weight,
score = score,
}, server)
end
`
### Expected Behavior
least-connection should picks the node with the lowest value of
`(active_conn + 1) / weight`
### Error Logs
_No response_
### Steps to Reproduce
1.run apisix;
2.create route,add two nodes,The weights of nodes are different;
3.Client initiated request
### Environment
- APISIX version (run `apisix version`):2.13.1
- Operating system (run `uname -a`):Linux localhost.localdomain
3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64
x86_64 GNU/Linux
- OpenResty / Nginx version (run `openresty -V` or `nginx
-V`):openresty/1.19.9.1
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):etcd_version":"3.4.0
- APISIX Dashboard version, if relevant:2.10
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks
--version`):luarocks 3.8.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]