15.5、Dubbo RPC框架
分类: 其他Spring Cloud Alibaba组件
Dubbo RPC 框架
Dubbo 是高性能的 RPC 框架。本节将学习 Dubbo RPC 框架。
本节将学习:Dubbo 简介、与 Spring Cloud 集成、服务提供者、服务消费者,以及负载均衡。
Dubbo 简介
定义
Dubbo 是阿里巴巴开源的分布式 RPC 框架,提供高性能、透明化的远程服务调用方案。
核心特性
Dubbo 核心特性:
- 高性能
- 服务治理
- 负载均衡
- 服务监控
与 Spring Cloud 集成
集成方式
与 Spring Cloud 集成:
- 使用 Spring Cloud Alibaba Dubbo
- 兼容 Spring Cloud 生态
- 支持 Nacos 注册中心
服务提供者
提供者配置
@Service @DubboService public class UserServiceImpl implements UserService { // 服务实现 }
服务消费者
消费者配置
@Reference private UserService userService; public User getUser(Long id) { return userService.getById(id); }
负载均衡
负载均衡策略
负载均衡策略:
- Random(随机)
- RoundRobin(轮询)
- LeastActive(最少活跃)
- ConsistentHash(一致性哈希)
官方资源
- Dubbo 官方文档:https://dubbo.apache.org/
- Dubbo GitHub:https://github.com/apache/dubbo
本节小结
在本节中,我们学习了:
第一个是 Dubbo 简介。 Dubbo 是高性能 RPC 框架。
第二个是与 Spring Cloud 集成。 如何集成 Dubbo 和 Spring Cloud。
第三个是服务提供者。 如何实现服务提供者。
第四个是服务消费者。 如何实现服务消费者。
第五个是负载均衡。 Dubbo 的负载均衡策略。
这就是 Dubbo RPC 框架。使用 Dubbo,可以实现高性能的服务调用。
在下一节,我们将学习 SkyWalking 链路追踪。