kun-song / dubbo-notes Goto Github PK
View Code? Open in Web Editor NEWDubbo 使用、学习笔记
Dubbo 使用、学习笔记
Dubbo 有多重注册机制,例如广播、Zookeeper 和 Redis,其中广播注册是通过 MulticastSocket
实现的。
几乎所有分布式系统中,都有类似注册中心的概念( or 组件),注册中心解决了 服务发现 的问题。
服务发现是指 consumer 查找 provider 地址(IP + port)的过程。
服务是什么?
服务发现中的服务含义非常广泛,数据库实例、缓存实例、RPC provider、微服务、网络设备等等,都可被视为服务。
在云计算之前,服务部署在物理机器上,IP 地址不变,因此即使没有服务发现,通过 硬编码 服务的地址,也能满足需求。
云计算时代,尤其是 Docker 的快速发展,使得 硬编码 几乎无用武之地,因为服务不再部署在物理机上,每次新创建的实例,其 IP 很可能与上次不同,因此需要更加灵活的服务发现机制。
服务发现是 SOA 架构(service oriented architecture)、微服务架构的核心组件,必须提供以下 3 个功能:
复杂系统中,服务的元数据非常复杂,因此 lookup 非常重要,这里的查找不仅仅指查找到服务的元数据(地址、配置等),还包括服务的部署状态,并提供集中管理服务实例的能力。
参考:
Dubbo 是 SOA 框架,自然也需要支持服务发现,Dubbo 有 5 中服务发现机制,其中常用的有 3 种:
阿里内部通过数据库实现注册中心,而外部一般使用 Zookeeper 实现。
publish/subscribe 模式是一种常见的消息模式,该模式下,publisher 不直接向 subscriber 发送消息,而是将消息发送到 channel/topic,subscriber 订阅自己感兴趣的 channel/topic,不需要了解 publisher 即可获取消息。
pub/sub 模式解耦了 publisher 和 subscriber,可扩展性更强,允许更动态的网络拓扑。
Redis 通过 PUBLISH
, SUBSCRIBE
和 UNSUBSCRIBE
3 个命令实现了 pub/sub 模式。
Redis 客户端通过 SUBSCRIBE
指令订阅 channel:
SUBSCRIBE c1 c2
Redis 服务器会将其他客户端 publish 到 c1 c2 的消息 推送 到订阅 c1 c2 的客户端。
注意:
Dubbo 使用 hash 保存注册信息,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.