Skip to content

Extension of LoadBalance (a small suggestion for loadbalance policy when there's less than 2 providers) #934

Closed

Description

@Sirius-LiXiaoQi

暴露1个或者2个服务时,无法扩展到SPI->LoadBalance....能否将逻辑抽象到abstractLoadBalance,毕竟1个的默认选择,和2个的退化轮询也属于选择负载的方向,也能方便重写性扩展,有助于筛选参数和自定义筛选invokers。这样C端扩展点也将会更灵活

Activity

  1. changed the title [-]Extension of LoadBalance (超过2个provider才进行扩展select)[/-] [+]Extension of LoadBalance (超过2个provider才进行扩展select的小建议)[/+] on Nov 27, 2017
  2. added this to the some day milestone on Dec 4, 2017
  3. chickenlj commented on Dec 4, 2017

    @chickenlj
    Contributor

    That's a good point, we'll discuss the feasibility

  4. changed the title [-]Extension of LoadBalance (超过2个provider才进行扩展select的小建议)[/-] [+]Extension of LoadBalance (a small suggestion for loadbalance policy when there's less than 2 providers)[/+] on Dec 4, 2017
  5. hebo1982 commented on Feb 28, 2018

    @hebo1982

    确实碰到了这样的问题。
    在通过loadbalance做会话保持,当两个节点时,会话保持不了。

  6. Sirius-LiXiaoQi commented on Mar 5, 2018

    @Sirius-LiXiaoQi
    Author

    是的,因为没到扩展逻辑就返回了,是为替大众用户思考的呢,少一次代理负载的逻辑,但是对于freeStyle的小伙伴们受限了,让我们奔放吧

  7. diecui1202 commented on May 4, 2018

    @diecui1202

    Get it. I will do it in a few days.

  8. diecui1202 commented on May 7, 2018

    @diecui1202

    After discussing with @chickenlj , we decide to remove 140-142 lines, as the following shows:

    private Invoker<T> doSelect(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
            if (invokers == null || invokers.isEmpty())
                return null;
            if (invokers.size() == 1)
                return invokers.get(0);
            // If we only have two invokers, use round-robin instead.
    140        //if (invokers.size() == 2 && selected != null && !selected.isEmpty()) {
    141        //    return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
    142        //}
            if (loadbalance == null) {
                loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(Constants.DEFAULT_LOADBALANCE);
            }
            Invoker<T> invoker = loadbalance.select(invokers, getUrl(), invocation);
    
            //If the `invoker` is in the  `selected` or invoker is unavailable && availablecheck is true, reselect.
            if ((selected != null && selected.contains(invoker))

    Because the selected param is not null only when retry or in ForkingClusterInvoker. And the reselect function will finally select a available invoker.

    So these 3 lines code seems unnecessary.

  9. added a commit that references this issue on May 7, 2018
    573c0ca
  10. Sirius-LiXiaoQi commented on May 29, 2018

    @Sirius-LiXiaoQi
    Author

    @diecui1202 @chickenlj Pretty Good,But the only one invoker exists ,and we also can't expand our intentions.

  11. diecui1202 commented on May 29, 2018

    @diecui1202

    Could you tell us the scenario that need to expand when only 1 invoker exists.

  12. Sirius-LiXiaoQi commented on May 29, 2018

    @Sirius-LiXiaoQi
    Author

    Assuming that the three normal services can maintain the business, notify the container platform to rebuild the service or notify the alarm platform when the payload encounters only one or no invoker alive

  13. added a commit that references this issue on Sep 9, 2019
    e5102b9
  14. added a commit that references this issue on Sep 10, 2019
    116c9c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions