Spring Cloud 技术解析:从网关到服务发现
1. Spring Cloud Gateway 与 Netflix Zuul v1 的对比
Spring Cloud Gateway 基于非阻塞 API,采用 Spring 6、Project Reactor 和 Spring Boot 3,而 Netflix Zuul v1 基于阻塞 API。这使得 Spring Cloud Gateway 能处理更多并发请求,对于所有外部流量都要经过的边缘服务器非常重要。
外部客户端的请求通过 Spring Cloud Gateway 作为边缘服务器,根据 URL 路径将请求路由到目标微服务。例如,以 /product-composite/ 开头的外部请求会被发送到 Product Composite 微服务,而核心服务 Product、Recommendation 和 Review 无法从外部客户端访问。
2. Spring Cloud Config 实现集中配置
Spring Cloud 中的 Spring Cloud Config 可对微服务系统的配置文件进行集中管理,支持将配置文件存储在多种后端:
- Git 仓库(如 GitHub 或 Bitbucket)
- 本地文件系统
- HashiCorp Vault
- JDBC 数据库
Spring Cloud Config 允许以分层结构处理配置,可将通用配置放在公共文件中,特定微服务的设置放在单独的配置文件中。它还支持检测配置更改并向受影响的微服务推送通知,通过 Spring Cloud Bus 传输通知,该总线基于
超级会员免费看
订阅专栏 解锁全文
168万+

被折叠的 条评论
为什么被折叠?



