当前位置:网站首页>[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

边栏推荐
- Go 語言的 Context 詳解
- 原生小程序 之 input切换 text与password类型
- MySQL-CentOS7通过YUM安装MySQL
- EMMC打印cqhci: timeout for tag 10提示分析与解决
- Distributed global ID generation scheme
- async / await
- 驱动开发中platform设备驱动架构详解
- Ten stages of becoming a Senior IC Design Engineer. What stage are you in now?
- [daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
- Web Authentication API兼容版本信息
猜你喜欢

SAP ABAP BDC(批量数据通信)-018

pytorch_ 01 automatic derivation mechanism

Message queuing: how to ensure that messages are not lost

如何提高网站权重

Question 102: sequence traversal of binary tree

What is dependency injection (DI)
![SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server](/img/05/1e4bdddce1e07f7edd2aeaa59139ab.jpg)
SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server

力扣102题:二叉树的层序遍历

爬虫练习题(三)

Add salt and pepper noise or Gaussian noise to the picture
随机推荐
async / await
Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
Message queue: how to handle repeated messages?
Things about data storage 2
404 not found service cannot be reached in SAP WebService test
Distributed global ID generation scheme
原生小程序 之 input切換 text與password類型
Five core elements of architecture design
架构设计的五个核心要素
《ClickHouse原理解析与应用实践》读书笔记(6)
力扣102题:二叉树的层序遍历
Realize GDB remote debugging function between different network segments
Randomly generate session_ id
【Shell】清理nohup.out文件
Type de texte de commutation d'entrée et de mot de passe de l'applet natif
Taobao store release API interface (New), Taobao oauth2.0 store commodity API interface, Taobao commodity release API interface, Taobao commodity launch API interface, a complete set of launch store i
谈fpga和asic的区别
Add salt and pepper noise or Gaussian noise to the picture
软件测试面试技巧
Classic questions about data storage