当前位置:网站首页>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,它只是一个类库,集成于消费方进程,消费方通过它来获取到服务提供方的地址。
边栏推荐
- Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?
- It turns out that the joys and sorrows of programmers are not interlinked
- 2022.02.15 - 240. Lucky number in matrix
- [deep learning] - maze task learning I (to realize the random movement of agents)
- Week 12 - task 2- shoulder to shoulder cadres
- 5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply
- Overlay histogram with density curve
- Difference between URI and URL
- Ctrip launched the "3+2" office mode. Are you sour?
- ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
猜你喜欢

Single application and microservice application

Teach you how to develop your own NPM package (publish to the NPM official website)

It turns out that the joys and sorrows of programmers are not interlinked

National Defense University project summary

Fault: ntfrs warning log for id13562

Sourcetree remote red exclamation point

MySQL add / delete / modify query SQL statement exercise yyds dry goods inventory

Testing grpc service with grpcui

2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin copper (no2tmpp) Cu) /2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin (no2tmpp) H2) Qiyue porphyrin supply

Monitor employee turnover dynamics. This system makes employees tremble!
随机推荐
JDBC | Chapter 6: simple use of database connection pool
Establishing the development environment of esp8266
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?
What are the uses of wireless pressure collectors?
Aging design guide for applets
Two houses with different colors and the farthest distance
Difference between static and final
Hyperledger Fabric 2. X custom smart contract
Servlet version conflict causes page 404
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
Skills of writing test cases efficiently
Delete tag
Jenkins operation Chapter 6 mail server sending build results
51 lines of code, self-made TX to MySQL software!
Devops development, operation and maintenance Basics: using Jenkins to automatically build projects and notify by email
力扣每日一题-第30天-594.最长和谐子序列
Honeypot based on MySQL load data local INFILE
Chapter V online logic analyzer signaltap
What are the uses of static?
Fault: display Storport driver out of date in component health