当前位置:网站首页>Ribbon 服务调用与负载均衡
Ribbon 服务调用与负载均衡
2022-06-29 06:32:00 【喵先森爱吃鱼】
前面的内容学习,已经实现了服务的注册和服务发现。当启动某个服务的时候,可以通过 HTTP 的形式将信息注册到注册中心,并且可以通过 SpringCloud 提供的工具获取注册中心的服务列表。但是服务之间的调用还存在很多的问题,如何更加方便的调用微服务,多个微服务的提供者如何选择,如何负载均衡等。
一、Ribbon 概述
1.1 什么是 Ribbon
Ribbon 是 Netflix 发布的一个负载均衡器,有助于控制 HTTP 和 TCP 客户端行为。在 SpringCloud 中,Eureka 一般配合 Ribbon 进行使用,Ribbon 提供了客户端负载均衡的功能,Ribbon 利用从 Eureka 中读取到的服务信息,在调用服务节点提供的服务时,会合理的进行负载。
在 SpringCloud 中可以将注册中心和 Ribbon 配合使用,Ribbon 自动地从注册中心获取服务提供者的列表信息,并基于内置的负载均衡算法,请求服务。
1.2 Ribbon 的主要作用
(1)服务调用
基于 Ribbon 实现服务调用,是通过拉取到的所有服务列表组成(服务名-请求路径的)映射关系。借助 RestTemplate 最终进行调用。
(2)负载均衡
当多个服务提供者时,Ribbon 可以根据负载均衡的算法(如简单轮询、随机连接等)自动地选择需要调用的服务地址。
1.3 Ribbon 负载均衡和 Nginx 负载均衡的区别
LB 负载均衡(Load Balance)是什么?简单的说就是将用户的请求平摊的分配到多个服务上,从而达到系统的 HA(高可用)。常见的负载均衡有软件 Nginx,LVS,硬件 F5 等。
Nginx 是服务器负载均衡,客户端所有请求都会交给 Nginx,然后由 Nginx 实现转发请求,即负载均衡是由,服务端实现的。
Ribbon 本地负载均衡,在调用微服务接口的时候,会在注册中心上获取到注册信息服务列表之后,缓存到 JVM 本地,从而在 本地实现 RPC 远程服务调用技术。
集中式LB:即在服务的消费方和提供方之间使用独立的 LB 设施(可以是硬件,如 F5,也可以是软件,如 Nginx),由该设施负载把访问请求通过某种策略转发至服务的提供方。
进程内LB:将 LB 逻辑集成到消费方,消费方从服务注册中心获知有哪些地址可用,然后自己再从这些地址中选择出一个合适的服务器。Ribbon 就属于进程内 LB,它只是一个类库,集成于消费方进程,消费方通过它来获取到服务提供方的地址。
边栏推荐
- String and variable are spliced into variable name
- Maximum ascending subarray sum of leetcode simple problem
- VLAN experiment
- Segment in Lucene
- Failure: unable to log in to "taxpayer equity platform"
- Easy to understand TCP four waves (multi picture explanation)
- Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
- [high concurrency] deeply analyze the callable interface
- Week 10 - task 0- execution process instance resolution of constructors and destructors
- What should I learn before learning programming?
猜你喜欢

5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply

Will the order of where conditions in MySQL affect the union index? Will where 1 =1 affect the use of the index? Does where 1 =1 affect the use of indexes?

5,10-di (4-aminophenyl) - 15,20-diphenylporphyrin (cis-dadph2) /5,15-di (4-aminophenyl) - 10,20-diphenylporphyrin (trans-dadph2) / (tri-apph2) supplied by Qiyue

2022.02.14 - 239. A single element in an ordered array

Conditional test, if and case conditional test statements of shell script

2,5-di (3,4-dicarboxyphenoxy) - 4 '- phenylethynylbiphenyldianhydride (pephqda) / Qiyue custom supply porphyrin modified amphiphilic block copolymer peg113-pcl46-porphyrin

Introduction to Ceres Quartet

Design and practice of kubernetes cluster and application monitoring scheme

What are the uses of wireless pressure collectors?

ICLR is going to have a big discussion on the deep generation model. Max welling and the winner of the AAAI million dollar award are here. Bengio is one of the organizers
随机推荐
What is 'EC2-Other' filter in 'Cost Explorer' dashboard mean? [closed]
Stack -- 739 Daily temperature
2022.02.14 - 239. A single element in an ordered array
[C language series] - initial C language (4)
Delete tag
2022.02.15
Conditional test, if and case conditional test statements of shell script
ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
Rich material libraries make modeling easy and efficient for developers
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
层次分析法
力扣每日一题-第30天-1281.整数的各位积和之差
Hustoj SPJ example
The most complete machine learning model training process
P5 DS - component and document Association
Devops development, operation and maintenance Basics: using Jenkins to automatically build projects and notify by email
Skills of writing test cases efficiently
String and variable are spliced into variable name
SCM engineering experience - time slice
Call the computer calculator and use it to convert several base numbers