Ribbon Loadbalance核心接口是什么

发布时间:2021-10-21 13:44:28 作者:柒染
来源:亿速云 阅读:128

Ribbon Loadbalance核心接口是什么,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

Ribbon Loadbalance核心接口

接口列表

功能介绍

配置入口:RibbonClientConfiguration

合适的方式选择合适的节点

ILoadBalancer

接口定义:com.netflix.loadbalancer.ILoadBalancer

核心方法:

	/**
	 * Choose a server from load balancer.
	 * 
	 * @param key An object that the load balancer may use to determine which server to return. null if 
	 *         the load balancer does not use this parameter.
	 * @return server chosen
	 */
	public Server chooseServer(Object key);
/**
 * @return Only the servers that are up and reachable.
    */
   public List<Server> getReachableServers();

   /**
    * @return All known servers, both reachable and unreachable.
    */
public List<Server> getAllServers();

核心作用:维护全量服务列表及可用列表,依赖IPing接口标记失效节点,标识失效依赖IPing实现

默认实现:ZoneAwareLoadBalancer

IRule

接口定义:com.netflix.loadbalancer.IRule

核心方法:

/*
 * choose one alive server from lb.allServers or
 * lb.upServers according to key
 * 
 * @return choosen Server object. NULL is returned if none
 *  server is available 
 */

public Server choose(Object key);

核心作用:从loadbalance里面选取一个server;提供多种选择策略

默认实现:ZoneAvoidanceRule

ServerList

接口定义:com.netflix.loadbalancer.ServerList

核心方法:

/**
 * Return updated list of servers. This is called say every 30 secs
 * (configurable) by the Loadbalancer's Ping cycle
 * 
 */
public List<T> getUpdatedListOfServers();

核心作用:获取更新服务列表

默认实现:ConfigurationBasedServerList

ServerListFilter

接口定义:com.netflix.loadbalancer.ServerListFilter

核心方法:

public List<T> getFilteredListOfServers(List<T> servers);

核心作用:

默认实现:ZonePreferenceServerListFilter

IPing

接口定义:com.netflix.loadbalancer.IPing

核心方法:

/**
 * Checks whether the given <code>Server</code> is "alive" i.e. should be
 * considered a candidate while loadbalancing
 * 
 */
public boolean isAlive(Server server);

核心作用:检测特定服务是否活着,在ILoadBalance中做失效服务检测作用

默认实现:DummyPing

扩展思考

Ribbon最大的有点就是允许用户定制化各种规则,很好的管理了节点状态及访问规则,基于规则扩展做一些好用的产品,比如灰度管理、目标节点能力不对等下的权重控制

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

推荐阅读:
  1. 如何实现Springcloud ribbon负载均衡算法
  2. Ribbon如何在spring cloud 中使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

loadbalance ribbon

上一篇:partprobe命令怎么用

下一篇:如何理解前缀,后缀,中缀表达式转化求值问题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》