当前位置:网站首页>[learn microservice from 0] [01] what is microservice
[learn microservice from 0] [01] what is microservice
2022-07-07 12:46:00 【lpruoyu】
Continuous learning & Ongoing update …
Keep breaking away
【 from 0 Start learning about microservices 】【01】 What is microservice
Microservices :
- A software architecture style based on business functions
- Each module is developed independently 、 test 、 Deploy , Have your own process ; It has nothing to do with language ; Opening to the outside world API Interface (RPC/HTTP)
Single application
Before talking about micro services , Let me introduce you to the single application first . If you don't know the pain of monomer application , That doesn't really understand the value of microservices .
Earlier years , The application technology stacks of major Internet companies can be roughly divided into LAMP(Linux + Apache + MySQL + PHP) and MVC(Spring + iBatis/Hibernate + Tomcat) Two schools . Whether it's LAMP still MVC, They are all designed for single application architecture , Its advantage is low learning cost , Develop quickly , test 、 Deploy 、 Operation and maintenance are also more convenient , Even one person can complete the development and deployment of a website .
With the continuous expansion of business scale , The continuous expansion of team developers , The single application architecture will start to have problems . There will be some problems in the following aspects :
Inefficient deployment . Take the project I actually participated in as an example , When the code of single application is more and more , When we rely on more and more resources , Application compilation package 、 Deploy the test once , Even need to 10 Minutes or more . This is often said by new students roast , Time to deploy the test once , You can go downstairs for a cup of coffee .
The cost of teamwork is high . In my experience , In the early days when there were only two or three team developers , Collaborative code modification , Finally merge into the same master Branch , And then package and deploy , Controllable . But once the team expands , exceed 5 People modify the code , And then package and deploy together , In the test phase, only one piece of function has problems , You have to recompile, package, deploy , Then preview the test again , All the relevant developers have to be involved , inefficiency , High development cost .
The high availability of the system is poor . Because all the functional development is finally deployed to the same WAR In the bag , Run in the same Tomcat In progress , Once there is a problem with the code or resources involved in a function , That will affect the whole WAR Features deployed in the package . For example, a problem I often encounter : A piece of code keeps creating large objects in memory , And not recycled , After deploying to online operation for a period of time , Will cause JVM Memory leak , Abnormal exit , Then deploy in the same JVM All services in the process are unavailable , The consequences are very serious .
Online publishing slows down . Especially for Java applications , Once the code expands , The service will take longer to start , Some even surpass 10 Minutes or more , If the size of the machine exceeds 100 Table above , Assume that the step size for each release is 10%, A single release requires 100 minutes . therefore , There is an urgent need for a way to decouple the different modules of the application , Reduce development and deployment costs .
Microservice benefits :
- Modular deployment , Avoid a module downtime , Make the whole system unavailable
- It can be used separately for high concurrency scenarios ( seckill 、 Order 、…) Capacity expansion , Add machines
- It is convenient for developers to develop independently 、 Mutual interference
As a service
In popular terms , Service is the traditional stand-alone application through JAR Package dependency generates local method calls , Transform to pass RPC Interface generated remote method calls .
Generally, when writing business code , For some common business logic , I will try my best to abstract it and make it a special module , Because it is of great benefit to code reuse and business understanding .
Take Weibo system for example , Microblog includes content module , It also includes message module and user module . The message module depends on the content module , Both the message module and the content module depend on the user module . When the code of these three modules is coupled , When app starts , You need to load the code of each module and connect the corresponding resources at the same time . Once the code for any module appears bug, Or there is a problem with the dependent resources , The whole monomer application will be affected .
So , First of all, the user module can be separated from the single application , Independent into a service deployment , With RPC Provide external services in the form of interface . The content and message module calls the user interface , From in-process calls to remote RPC call .
such , User modules can be developed independently 、 test 、 Go live and operate , It can be done by a special team , Not coupled with other modules . Further, the message module can be divided into independent modules , Leave it to a dedicated team to develop and maintain .
It can be seen through service , It can solve the expansion of monomer application 、 Team development is highly coupled 、 The problem of inefficient collaboration .
What is microservice
from 2014 Year begins , Thanks to Docker Represented by the maturity of containerization technology and DevOps The rise of culture , The idea of servitization has further evolved , It has evolved into what we know today as micro services .
So what's the difference between microservices and service-oriented ?
in my opinion , It can be summarized as the following four points :
Service splitting is more granular . Micro service can be said to be a finer dimension of servitization , Down to a submodule , As long as the resource on which the module depends is not related to any other module , Then it can be broken down into a microservice .
Service independent deployment . Each microservice strictly follows the guidelines for independent packaging and deployment , They don't influence each other . For example, multiple units can be deployed on a single physical machine Docker example , Every Docker An instance can deploy code for a microservice .
Service independent maintenance . Each microservice can be developed by a small team or even an individual 、 test 、 Release and operations , And responsible for the entire life cycle .
Service governance capabilities are demanding . Because when you split it up into microservices , The number of services has increased , Therefore, a unified service governance platform is needed , To manage the services .
Continue to take the microblog system as an example , The function of the content module can be further divided , For example, the content module contains feed modular 、 Comment module and personal page module . Through microservicing , Turn these three modules into three separate services , Each service depends on its own resources , And independently deployed in different service pools , It can be maintained by different developers . When commenting on changes in service requirements , Just modify the comment business related code , And launch independently ; and feed Services and personal page services do not need to be changed , And it will not be affected by the changes that the release may bring .
thus it can be seen , Microservice is used to publish and deploy services , And the guarantee of service brings many benefits .
summary
The origin of the development of microservices , It evolved from a single application to a service-oriented split deployment , Later, with the continuous expansion of the scale of mobile Internet , agile development 、 Continuous delivery 、DevOps The development and practice of theory , And based on Docker Maturity of containerization Technology , Microservice architecture is becoming popular , It has gradually become the future evolution direction of application architecture .
In conclusion , Microservice architecture is the fine-grained service splitting of complex and bloated single application , Each separated service is packaged and deployed independently , And let the small team develop and operate , Thus greatly improving the efficiency of application delivery , And is widely used by major Internet companies .
Be careful
True knowledge comes from practice
It is better not to involve cross database table interaction in service splitting
Extracurricular development : What is microservice ( Wikipedia )
https://zh.wikipedia.org/wiki/%E5%BE%AE%E6%9C%8D%E5%8B%99
Microservices (Microservices) Is a software architecture style , It is With Small functional blocks that focus on a single responsibility and function Based on , With modularization The way Combine Out of complex large-scale applications , Functional blocks Use It has nothing to do with language Of API Interface sets communicate with each other .
2014 year ,Martin Fowler And James Lewis We put forward the concept of microservice , Microservices are defined as small services made up of a single application , Own your own process and lightweight processing , Services are designed according to business functions , Deploy in a fully automated manner , Use with other services HTTP API signal communication . At the same time, services will use the smallest centralized management ( for example Docker) Ability , Services can be implemented in different programming languages, databases and other components .
Microservice is a kind of Focus on business functions Service design concept , Each service has its own business functions , Opening to the outside world is not restricted by language API ( The most common is HTTP), Applications are composed of one or more microservices .
Another comparison of microservices is monolithic applications . A single application means that an application contains all the required business functions , And use an architecture like master-slave (Client/Server) Or multi-level architecture (N-tier) Realization , Although it can also be implemented as a distributed application , however In single application , Every business function is inseparable . If you want to extend a monolithic application, you must put the entire application into new computing resources ( Such as : virtual machine ) Inside , but In fact, the most resource consuming applications 、 There is only one business part that needs computing resources ( For example, run analysis report or mathematical algorithm analysis ), But this part cannot be divided because of the single application , Therefore, there will be a lot of waste of resources .
Microservices use the design concept based on business functions , When designing an application, it can be divided first by business function or process design , Each business function is independently implemented as an individual service that can be executed independently , Then use the same protocol to combine all the services required by the application , Form an application . If you need to expand specific business functions , As long as the service of this business function is extended , You don't need to extend the entire application , meanwhile , Because microservices are business function oriented implementation , Therefore, it will not be disturbed by the application , The administrator of microservices can configure microservices to different computing resources according to the needs of computing resources , Or build new computing resources and configure them .
Although general server virtualization technology can be applied to the management of microservices , But container technology (Container Technology) Such as Docker It will be more suitable for the development of computing resource management technology of microservices .
Reference resources
Wikipedia : Microservices
Geek time : from 0 Start learning about microservices -- First line practical experience of microblog service experts
The end of this paper , Thank you for your attention and support !
边栏推荐
- What if does not match your user account appears when submitting the code?
- Static routing assignment of network reachable and telent connections
- Visual stdio 2017 about the environment configuration of opencv4.1
- visual stdio 2017关于opencv4.1的环境配置
- Utiliser la pile pour convertir le binaire en décimal
- Minimalist movie website
- 2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
- Simple implementation of call, bind and apply
- Niuke website
- (to be deleted later) yyds, paid academic resources, please keep a low profile!
猜你喜欢
【PyTorch实战】用RNN写诗
BGP third experiment report
SQL Lab (32~35) contains the principle understanding and precautions of wide byte injection (continuously updated later)
How to apply @transactional transaction annotation to perfection?
About sqli lab less-15 using or instead of and parsing
Charles: four ways to modify the input parameters or return results of the interface
Master公式。(用于计算递归的时间复杂度。)
2022聚合工艺考试题模拟考试题库及在线模拟考试
Attack and defense world - PWN learning notes
Day-14 common APIs
随机推荐
The IDM server response shows that you do not have permission to download the solution tutorial
Master公式。(用于计算递归的时间复杂度。)
Day-16 set
Cryptography series: detailed explanation of online certificate status protocol OCSP
On valuation model (II): PE index II - PE band
About sqli lab less-15 using or instead of and parsing
[statistical learning methods] learning notes - improvement methods
Inverted index of ES underlying principle
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
【深度学习】图像多标签分类任务,百度PaddleClas
【从 0 开始学微服务】【00】课程概述
NPM instal reports agent or network problems
【从 0 开始学微服务】【01】什么是微服务
【统计学习方法】学习笔记——第五章:决策树
Is it safe to open an account in Ping An Securities mobile bank?
【PyTorch实战】图像描述——让神经网络看图讲故事
Common knowledge of one-dimensional array and two-dimensional array
【统计学习方法】学习笔记——提升方法
OSPF exercise Report