单体架构
微服务架构
微服务架构是一种架构思想,架构就是为了解耦,实际的开发方式是分布式系统开发。
Java单体架构:三层架构
视图层
账单模块 Controller
用户模块
业务层
账单模块 Service
用户模块
数据层
账号模块 Dao
用户模块
SOA与微服务区别
微服务基本架构
微服务要素
三大指标
高可用=服务一可用用,N个9,6个9,允许宕机时间为31秒
高性能=尽量快一点,3秒内打开
高并发=系统承载能力
垂直拓展:升级配置
水平拓展:加机器
数据库水平拆分:分库、分表
数据库中间件:Apache Sharding-sphere
https://blog.csdn.net/qq_34808893/article/details/103993659
四大问题
1、客户端如何访问?
API网关
Zuul
- Spring Cloud Gateway
2、服务与服务之间如何调用?
同步通讯
对外REST对内RPC
REST:HTTP
RPC:Dubbo、Thrift
https://dubbogo.github.io/dubbo-go-website/zh-cn/docs/user/quick-start.html
https://github.com/apache/dubbo-go/blob/master/README_CN.md
异步通讯
Kafka CP
https://baijiahao.baidu.com/s?id=1655359291726496245&wfr=spider&for=pc
3、服务如何治理?
注册中心:
Nacos(https://studygolang.com/articles/26329?fr=sidebar)、
Etcd、(https://blog.csdn.net/c_circle/article/details/98473421)
Zookeeper、
Consul(https://www.jianshu.com/p/ce7c7b9dcf14)
链路追踪:
ZipKin、
SkyWalking(https://blog.csdn.net/zhounixing/article/details/105815910)
限流
4、服务挂了怎么办?
熔断机制:Sentinel、Hystrix
负载均衡
CAP理论
1、Redis中间件 —-> AP
2、RocketMQ中间件 —–> AP
3、分布式事务-2pc —-> CP
4、分布式事务-最大努力尝试 —> AP
5、Eureka —> AP
6、ES ---> AP
7、Kafka ---> CP
两地三活
Java的微服务架构生态
Spring Cloud 是一种编程模型,微服务的开发标准,一系列的接口。
Spring Cloud Netflix
https://github.com/spring-cloud/spring-cloud-netflix
https://www.funtl.com/zh/guide/Spring-Cloud-Netflix.html
Spring Cloud Alibaba
https://github.com/alibaba/spring-cloud-alibaba/blob/master/README-zh.md
https://www.funtl.com/zh/guide/Spring-Cloud-Alibaba.html
GO的微服务架构生态
Dubbo-go
https://github.com/apache/dubbo-go/blob/master/README_CN.md
go-micro
https://github.com/micro/go-micro
janus
https://github.com/hellofresh/janus
gatekeeper
https://github.com/didi/gatekeeper
K8S优势
阿里云ECS架构
k8s服务接入