当前位置:网站首页>微服务及相关组件概念
微服务及相关组件概念
2022-07-25 05:19:00 【从零开始的JAVA世界】
1. 参考资料
2. 微服务相关概念
1. 单体架构

将业务的所有功能集中在一个项目中开发,打成一个包部署。
优势: 架构简单、部署成本低、适合小型项目。
劣势: 耦合度高、扩展性差。
2. 分布式架构

根据业务功能对系统做拆分,每个业务功能模块作为独立项目开发,称为一个服务。
优点: 松耦合、扩展性好、适合大型互联网项目。
缺点: 架构复杂、难度大。
3. 微服务架构

微服务是一种设计良好的分布式架构。
特点:
- 单一职责:微服务拆分粒度更小,每一个服务都对应唯一的业务能力,做到单一职责。
- 自治:团队独立、技术独立、数据独立,独立部署和交付。
- 面向服务:服务提供统一标准的接口,与语言和技术无关。
- 隔离性强:服务调用做好隔离、容错、降级,避免出现级联问题。
优点: 拆分粒度更小、服务更独立、耦合度更低。
缺点: 架构非常复杂、运维、监控、部署难度提高。
服务拆分原则
- 不同微服务,不要重复开发相同业务
- 微服务数据独立,不要访问其它微服务的数据库
- 微服务可以将自己的业务暴露为接口,供其它微服务调用
服务间调用
服务A可以通过Http请求调用服务B。

3. 微服务框架及技术组件

2.1 注册中心
问题:
- 服务A在发起远程调用的时候,该如何得知服务B实例的ip地址和端口?(到服务中心注册、拉取服务列表)
- 有多个服务B实例地址,服务A调用时该如何选择?(负载均衡算法)
- 服务A如何得知某个服务B实例是否依然健康,是不是已经宕机?(心跳检测)
注册中心的作用就是,保存服务列表、通过心跳检测服务状态、通过负载均衡算法分配服务实例。
2.2 远程调用
实现服务间的调用 (HTTP协议)
2.3 配置中心
当微服务部署的实例越来越多,达到数十、数百时,逐个修改微服务配置就会让人抓狂,而且很容易出错。我们需要一种统一配置管理方案,可以集中管理所有实例的配置。

2.4 网关
前端请求不允许直接访问微服务,必须先经过网关。
网关具有路由和过滤的功能,路由就是将请求分发给某个微服务,过滤将不符合条件的请求直接拦截。

2.5 服务监控、保护
保护服务调用者,保护服务调用时不要出现级联失败,竟可能快速返回服务失败,不让用户长时间等待。
保护服务提供方,接口限流。
边栏推荐
- rhcsa暑假第二天
- When we talk about immutable infrastructure, what are we talking about
- Forwarding and sharing function of wechat applet
- The third question of force deduction -- the longest substring without repeated characters
- rhce第一天
- [untitled]
- four hundred and forty-four thousand one hundred and forty-one
- Which side of Nacos has the SQL script of this column?
- 搭建私有CA服务器
- Which website is suitable for physical server
猜你喜欢

Small case of data analysis: visualize recruitment data and view the most needed technologies in the field~

Forwarding and sharing function of wechat applet

Special analysis of data security construction in banking industry

Three must know and know problems of redis

Preliminary understanding of Panda3D particle system

小红书携手HMS Core,畅玩高清视界,种草美好生活

Teach you how to locate unreasonable SQL? And optimize it

STL notes (I): knowledge system

Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life

JS common code questions array de duplication - Custom New throttling and anti shake - deep copy - instanceof URL parameter extraction - thousand separator - array to tree structure - array flattening
随机推荐
Json.tojsonstring cannot pass Boolean
Unity LOD
一篇文章带你读懂Redis的哨兵模式
搭建私有CA服务器
38 lines of PHP code free import database analysis Linux access log
[untitled]
epoll的实现原理
LCP插件创建对等802.1ad接口
An article takes you to understand the sentinel mode of redis
Matter's Unified Smart Home connection standard enables local automatic interaction between smart devices
LCP插件创建对等VLAN接口
Performance Optimization: lazy loading of pictures
STM32 Development Notes 118: using CMSIS DSP Library in stm32cube IDE
Harbor installation
Implement is by yourself_ base_ of
How to publish your own NPM package
教你三招从让性能从20s优化到500ms
Browser cache HTTP cache CDN cache localstorage / sessionstorage / cookies
Sword finger offer II 012. the sum of the left and right subarrays is equal
Project management tool - Introduction and practice of Alibaba cloud projex