Distributed Microservices:
1. Microservices: service split + remote call + service cluster
定义:一种经过良好架构设计的分布式架构方案
目的:高内聚、低耦合
缺点:复杂
名词:心跳、粒度
(1) Service: 1 business = 1 project = 1 service
服务拆分粒度:应用程序的不同功能单元(服务)进行拆分????????????
(2) Features: high cohesion, low coupling
1. Single responsibility:
1个服务对应1个业务能力
2. Service-oriented:
微服务对外暴露业务接口
3. Autonomy:
团队独立、技术独立、数据独立、部署独立
4. Strong isolation:
服务调用做好隔离、容错、降级,避免出现级联问题
(3) Components:
1. Registration center (maintain monitoring node information): service registration discovery framework
Eureka 、Zookeeper、Consul、Nacos、Redis
2. Load balancing: In-process load balancer
Ribbon、Nignx、LoadBalancer
3. Service remote call mapping:
Feign(http协议) 、Open Feign、Dubbo协议
4. Flow control/degradation/protection: fuse (circuit breaker): service degradation fuse
Alibaba Sentinel、Hystrix、Resilience4j
服务监控和保护
5. Unified service gateway routing (entry):
Zuul、SpringCloudGateway
服务监控和保护
6. Unified configuration center:
Nacos、 SpringcloudConfig、
7. Message bus:
Nacos、Bus
服务监控和保护
8. Service link monitoring
Zipkin、Sleuth
(IV) Service splitting: avoid duplication, database independence
定义:功能模块拆分、一个功能模块一个服务、每个服务独立的数据库
1. Avoid repetitive development:
不同微服务、不要重复开发相同业务
2. Database independence:
微服务数据独立、不要访问其它微服务的数据库
3. Business exposure interface: realize remote call
微服务可以将自己的业务暴露为接口、供其它微服务调用
(5) Remote invocation: business exposure interface, request invocation
1. Business exposure interface: remote call
微服务可以将自己的业务暴露为接口、供其它微服务调用
2. Microservice implementation: SpringCloud
组件:SpringCloudAlibaba
实现:SpringBoot自动装配
3. Microservice implementation: SpringCloudAlibaba
实质:实现部分SpringCloud——SpringCloud的组件
组件:SpringCloudAlibaba
4. Microservice implementation: Dubbo