netflix ribbon概述
LB方案分類
目前主流的LB方案可分成兩類:一種是集中式LB, 即在服務的消費方和提供方之間使用獨立的LB設施(可以是硬件,如F5, 也可以是軟件,如nginx), 由該設施負責把訪問請求通過某種策略轉發(fā)至服務的提供方;另一種是進程內(nèi)LB,將LB邏輯集成到消費方,消費方從服務注冊中心獲知有哪些地址可用,然后自己再從這些地址中選擇出一個合適的服務器。Ribbon就屬于后者,它只是一個類庫,集成于消費方進程,消費方通過它來獲取到服務提供方的地址。
1. Ribbon是什么?它解決了什么問題?
Ribbon is a client side IPC library that is battle-tested in cloud. It provides the following features
- Load balancing
- Fault tolerance
- Multiple protocol (HTTP, TCP, UDP) support in an asynchronous and reactive model
- Caching and batching
2.它的模塊有哪些?功能分別是什么?
- ribbon: APIs that integrate load balancing, fault tolerance, caching/batching on top of other ribbon modules and?Hystrix
- ribbon-loadbalancer: Load balancer APIs that can be used independently or with other modules
- ribbon-eureka: APIs using?Eureka client?to provide dynamic server list for cloud
- ribbon-transport: Transport clients that support HTTP, TCP and UDP protocols using?RxNetty?with load balancing capability
- ribbon-httpclient: REST client built on top of Apache HttpClient integrated with load balancers (deprecated and being replaced by ribbon module)
- ribbon-example: Examples
- ribbon-core: Client configuration APIs and other shared APIs
3.哪些模塊應用到生產(chǎn)了?
- ribbon-core:?deployed at scale in production
- ribbon-eureka:?deployed at scale in production
- ribbon-evcache:?not used
- ribbon-guice:?not used
- ribbon-httpclient:?we use everything not under com.netflix.http4.ssl. Instead, we use an internal solution developed by our cloud security team
- ribbon-loadbalancer:?deployed at scale in production
- ribbon-test:?this is just an internal integration test suite
- ribbon-transport:?not used
- ribbon:?not used
4.主要類及其層次結構
說明:
DynamicServerListLoadBalancer:A LoadBalancer that has the capabilities to obtain the candidate list of?servers using a dynamic source. i.e. The list of servers can potentially be?changed at Runtime. It also contains facilities wherein the list of servers?can be passed through a Filter criteria to filter out servers that do not?meet the desired criteria.
IClientConfig:Defines the client configuration used by various APIs to initialize clients or load balancers?and for method execution. The default implementation is {@link DefaultClientConfigImpl}
IRule:Interface that defines a "Rule" for a LoadBalancer. A Rule can be thought of?as a Strategy for loadbalacing. Well known loadbalancing strategies include?Round Robin, Response Time based etc.
IPing:Interface that defines how we "ping" a server to check if its alive
ServerList:Interface that defines the methods sed to obtain the List of Servers
ServerListFilter:This interface allows for filtering the configured or dynamically obtained?List of candidate servers with desirable characteristics.
ServerListUpdater:strategy for {@link com.netflix.loadbalancer.DynamicServerListLoadBalancer} to use for different ways?of doing dynamic server list updates
與Eureka結合使用
當與Eureka組合使用Ribbon時,
server使用DiscoveryEnabledServer實現(xiàn),Servers that were obtained via Discovery and hence contain meta data in the form of InstanceInfo。
ServerList接口會使用DiscoveryEnabledNIWSServerList實現(xiàn),The server list class that fetches the server information from Eureka client. ServerList is used by?{@link DynamicServerListLoadBalancer} to get server list dynamically.
ServerListFilter使用DefaultNIWSServerListFilter實現(xiàn),The Default NIWS Filter - deals with filtering out servers based on the Zone affinity and other related properties。
ServerListUpdater使用EurekaNotificationServerListUpdater,A server list updater for the {@link com.netflix.loadbalancer.DynamicServerListLoadBalancer} that?utilizes eureka's event listener to trigger LB cache updates。封裝了LegacyEurekaClientProvider:A legacy class to provide eurekaclient via static singletons。
IPing使用NIWSDiscoveryPing實現(xiàn),"Ping" Discovery Client,i.e. we dont do a real "ping". We just assume that the server is up if Discovery Client says so。
參考文章
【1】https://github.com/Netflix/ribbon
【2】http://blog.csdn.net/neosmith/article/details/53967330
?
轉載于:https://www.cnblogs.com/davidwang456/p/6433200.html
總結
以上是生活随笔為你收集整理的netflix ribbon概述的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用CORS实现跨域请求--转
- 下一篇: spring-cloud导入eclips