【微服务架构在二手交易平台(转转)中实践】 - imooc
知识要点
- 微服务架构特点
- 微服务架构使用原因
- 微服务架构演进
- 微服务架构通信协议、服务注册/发现
- 微服务架构柔性可用实践
- 微服务架构服务治理
什么是微服务
In short, the microservice architectural style is an approach to developing a single application as a suit of small services, each running in its own process and communitcating with lightweight mechanisms, ofthen an HTTP resource API. These services are built around business capabilities and independentlyl deployable by fully automated development machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies. --- James Lewis and Martin Fowler

二手交易平台功能
- 发布商品
- 分类搜索
- 关键词搜索
- 推荐商品
- 消息中心(私信、留言)
- 个人中心
...
使用微服务原因
- 业务功能多
- 业务复杂性高
- 业务高速发展
- 用户体验要求
微服务架构特点&二手交易平台特点
- 系统高可用
- 系统可扩展性
- 小规模开始快速迭代
- 持续交付
演进-如何设计

演进-总体架构设计

演进-存在问题
- 业务迭代
- 开发人员相互间协作
- 开发瓶颈集中(微服务聚合层)
微服务聚合层
- 仅有一个Process
- 扩展性差
- 多人开发冲突
- 业务耦合性高
- 性能瓶颈
通信协议-轻量级通信协议

REST API
✅ HTTP
✅ JSON
cmd : xx.com/xx/userquery
method: GET
request: {"uid" : 2323}
response: {"respCode" : 0}
respData: {"nickname" : xxx}
服务注册/发现-微服务发现

柔性可用实践
常见问题:
- 服务能力有限
- 性能下降
- 服务宕机
- 系统雪崩
解决:
目标: 保证核心服务可用;非核心服务弱可用,甚至不可用
- 系统降级 : 拒绝部分请求、关闭部分服务
- 数据层降级: 更新请求(持久到消息队列、只更新缓存)、读请求(读缓存)、数据补齐(消息队列->数据库)
- 柔性可用策略
柔性策略-系统降级

服务治理
- 监控对象
- 机器资源
- 进程状态
监控策略


浙公网安备 33010602011771号