spacewander commented on a change in pull request #3300:
URL: https://github.com/apache/apisix/pull/3300#discussion_r558015816
##########
File path: apisix/balancer/ewma.lua
##########
@@ -135,16 +153,23 @@ local function _ewma_find(ctx, up_nodes)
return nil, 'up_nodes trans error'
end
+ local endpoint, backendpoint = peers[1], nil
+
if #peers > 1 then
- endpoint = pick_and_score(peers)
- else
- endpoint = peers[1]
+ local a, b = math.random(1, #peers), math.random(1, #peers - 1)
+ if b >= a then
+ b = b + 1
+ end
+
+ endpoint, backendpoint = peers[a], peers[b]
+ if score(endpoint) > score(backendpoint) then
+ endpoint, backendpoint = backendpoint, endpoint
+ end
Review comment:
We need to sync the `tried_endpoint` check from
https://github.com/kubernetes/ingress-nginx/blob/a2e77185cc2e91278962f4f1267246c8fefc6e73/rootfs/etc/nginx/lua/balancer/ewma.lua#L180
to our new implementation.
You can take a look at:
https://github.com/apache/apisix/blob/bbbdf58d555ee89144b6923e751deabf7e0bbf15/apisix/balancer/roundrobin.lua#L54-L74
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]