当前位置:网站首页>[cloud native] what is the microservice architecture?
[cloud native] what is the microservice architecture?
2022-07-07 05:52:00 【Philosophy7】
Author's brief introduction : Hello everyone , I am a Philosophy7? Let's make progress together ! Personal home page :Philosophy7 Of csdn Blog
Series column : Data structure and algorithm
Philosophical quotations : Admit your ignorance , Is to open the door to wisdom
If you think the blogger's article is good , Please thumb up + Collection ️+ Leave a message to support bo > Lord
Microservice architecture
One 、 Why do you need a microservice Architecture
The emergence of new things will inevitably conflict with the sending of old things , And the vitality of a new thing , It depends on whether there is room for development , So micro service architecture is no exception . With the development of Internet technology , The traditional application architecture has been unable to meet the actual needs , Microservice architecture comes into being . So what are the problems with traditional application architecture ? How to solve it ?
① Problems of traditional single application architecture
Usually, the traditional single application architecture we use is modular design , After the program is written, it will be packaged and deployed as a specific application , The format of the application depends on the corresponding application language and framework . for example : An e-commerce project ,Web The project will be hit WAR Packages are deployed in the form of Web Server , And ordinary. Java The program is marked as a Jar The form of package is contained in WAR in .
Pictured , This is our common development style , The benefits of this are conducive to development and debugging , And easy to deploy . In the case of a small number of customers , This kind of Architecture ( Single application architecture ) Fully meet the needs , But as the number of users increases , One server cannot satisfy , At this point, we will consider the horizontal expansion of the system , Usually our solution is to increase the number of servers , And copy the packaged application to different servers ( for example :Tomcat), Through the load balancer (Apache、Nginx) Easy horizontal expansion .
The problems of this architecture are as follows :
- Application complexity increases , to update 、 Difficult to maintain
- Simple applications are updated many times 、 Maintenance will become huge , Applications will become more complex , The development team faces many problems , The main problem is that the application is too complex , So that it is difficult for a single developer to carry out secondary development or maintenance
- It is easy to waste system resources
- Although load balancing is used to expand the service capacity of the project horizontally across domains , However, there is only one code in the single application architecture that contains all functions WAR package , So while expanding the service capacity , You can only choose to deploy this repeatedly WAR Package to expand service capabilities , Instead of just expanding the services you need .
- Impact on development efficiency
- When an application is bigger , The starting speed will be greatly reduced . In development and debugging , If you spend most of your time on startup , It will greatly affect the development efficiency .
- Low application reliability
- The reliability of single application architecture is low , When a module generates BUG when , It is likely to cause the whole process to collapse , Thus affecting the whole application .
- It is not conducive to the renewal of Technology
- Once certain technologies are selected for the traditional single application architecture , The later development and expansion will be realized on the basis of these technologies . If you need to change a technology , Then it is likely to redevelop the whole application .
② Solve the problems of traditional application architecture
Aiming at the problems of traditional monomer Architecture , Most enterprises pass SOA(Service-Oritend Architecture)
Service oriented architecture solves the above problems .SOA The idea is to aggregate similar functions of applications , In the form of service , therefore SOA The application of architecture is simply understood as the combination of a number of services across domains .
- A whole project is divided into several sub projects , Different development teams are responsible for different sub projects , Improve development efficiency
- Split the module , Use interface communication , Reduce the coupling between modules
- Protect customers or service consumers from the impact of changes in service implementation
Although the use of SOA It solves the problems in the traditional monomer architecture , But most of the time ,SOA Independent services in will still be deployed to the same Tomcat For example , Similar to the single application architecture , With the increase of business functions ,SOA Services will also become complex . See the essence through the phenomenon , The problem of monomer architecture has not been solved .
In response to this problem , The architecture idea of microservice architecture also came into being , That is to decompose the application into small 、 Interconnected microservices .
Two 、 What is the microservice architecture ?
Microservice architecture is an architecture style and architecture idea , It advocates us to build on the traditional software application architecture , Split the system business more finely according to functions , Each service split is an independent application , These applications provide public API, Undertake external service responsibilities independently across domains , The software service entity developed through this idea is Microservices
, And a series of architectures built around the idea of microservice ( Development 、 test 、 Deployment, etc. ) Let's call this Microservice architecture
① The advantages of microservice Architecture
- Controllable complexity
- Finer grained application splitting , It will not become complicated with the evolution of time , Each service focuses on only one small function .
- Independently deployable
- Because microservices have independent running processes , So each microservice can be deployed independently .
- Flexible technology selection
- Microservices architecture , The selection of technology is diversified . Each team chooses the most suitable technology according to different needs .
- Easy fault tolerance
- When a component sends a fault , It will only affect a small service , You can go online again by retrying .
- extensible
- A single service application can also achieve horizontal expansion , This extension can completely complex the entire application to different nodes .
- Stable function
- Each microservice has its own business logic and adapter , And only complete a specific function , For example, goods and services only manage goods .
② The shortcomings of microservice Architecture
- Developers have to deal with the complexity of creating distributed systems
- Development tools are geared towards building traditional monolithic applications , Does not provide full functional support for developing distributed applications ( Typical development tools :Eclipse)
- Testing is more difficult . In the microservices architecture , There are many services , Each service is an independent business unit , Services need to interact through interfaces .
- Implement across multiple service use cases , Requires careful coordination between teams .
- The complexity of deployment will greatly increase , This means developing 、 test 、 Operation and maintenance personnel need more solid accounting technology
- Increase memory consumption , The microservice architecture is replaced by multiple service instances 1 A single application instance , If every service is running at an increased JVM in , How many service instances are there , How many instances will have memory overhead at runtime .
③ Microservice architecture and SOA The difference between
Microservice architecture | SOA |
---|---|
A system is split into multiple services , fine-grained | The service consists of several subsystems , coarse-grained |
Team level , Implement from bottom to top | Enterprise class , Carry out implementation from top to bottom |
No centralized bus , Loose service architecture | Enterprise service bus , Centralized service architecture |
Integrated way egg | The integration mode is complex |
Services can be deployed independently | Services are interdependent , Can't deploy independently |
3、 ... and 、 How to build a microservice Architecture
①、 Development of microservice instance
The development of micro services can choose Spring Boot
②、 Service registration and discovery
The registration and discovery of services in the architecture , Optional Spring Cloud Eureka、Apache Zookeeper、Consul( Domestic deactivation )、Dubbo etc.
③、 Load balancing
Load balancing can be used Spring Cloud Ribbon and Dubbo etc.
④、 Service fault tolerance
The technology of service fault tolerance can use brother Hao (Hystrix) stay SpringCloud The subproject of contains
⑤、API gateway
In the architecture API Gateway service , Use Spring Cloud Zuul、Spring Reactor、Netty etc.
⑥、 Distributed configuration center
have access to Spring Cloud Config
⑦ debugging
The testing of microservice applications generally uses Swagger.Swagger It's the most popular REST API One of the document generation tools , Provides powerful page testing capabilities to debug each RESTful API
⑧ Deploy
Microservices are officially recommended Docker To package and deploy microservices .Docker Is an open source application container engine , Strong portability 、 It's fast to start , Suitable for lightweight applications
边栏推荐
- 《ClickHouse原理解析与应用实践》读书笔记(6)
- Pytorch builds neural network to predict temperature
- Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
- Message queuing: how to ensure that messages are not lost
- Randomly generate session_ id
- 分布式事务解决方案之TCC
- 驱动开发中platform设备驱动架构详解
- Explication contextuelle du langage Go
- Web authentication API compatible version information
- 原生小程序 之 input切换 text与password类型
猜你喜欢
随机推荐
ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略
WEB架构设计过程
"Multimodal" concept
产业金融3.0:“疏通血管”的金融科技
[reading of the paper] a multi branch hybrid transformer network for channel terminal cell segmentation
SAP ABAP BDC(批量数据通信)-018
消息队列:消息积压如何处理?
分布式事务介绍
Digital IC interview summary (interview experience sharing of large manufacturers)
《2022中国低/无代码市场研究及选型评估报告》发布
async / await
消息队列:重复消息如何处理?
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
上海字节面试问题及薪资福利
STM32按键状态机2——状态简化与增加长按功能
[daily training -- Tencent selected 50] 292 Nim games
The 2022 China low / no code Market Research and model selection evaluation report was released
集群、分布式、微服务的区别和介绍
Reading notes of Clickhouse principle analysis and Application Practice (6)
SAP ABAP BDC (batch data communication) -018