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



##########
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:
       Maybe this is another topic we could improve the stability, like 
passive/active healthcheck, tried record & tries count?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to