hnlq715 commented on a change in pull request #3300:
URL: https://github.com/apache/apisix/pull/3300#discussion_r565800827



##########
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:
       Sorry, filter logic is added, I'm focusing something else in these days.




----------------------------------------------------------------
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]


Reply via email to