当前位置:网站首页>Introduction to microservice architecture

Introduction to microservice architecture

2022-07-07 01:54:00 Dily_ Su

Introduction to microservice Architecture

One 、 Evolution of Technology Architecture

 Please add a picture description

1.1 Single application

​ model1 Pattern : jsp + java

​ model2 Pattern : MVC Pattern

1.2 Vertical application

1.3 RPC Distributed applications

1.4 SOA Flow computing architecture

​ Resource scheduling 、 Load balancing 、 Dynamic service creation … Service governance

1.5 Microservices

​ small 、 Single responsibility

Two 、 Introduction to microservice

​ Microservice is to divide an application with a single architecture into independently running programs as services according to business , Between them HTTP Protocol to communicate ( You can also use message queue , Such as kafaka、RabbitMq etc. ), You can use different programming languages , Using different storage technologies , Automated Deployment , Reduce human control , Reduce the probability of error . There are many services , Management is becoming more and more complex , So centralized management , Such as Eureka、Zookeeper And other common service centralized management frameworks .

​ Microservice is an architectural style , A large complex software application , Consists of one or more microservices , Various micro services of the system can be deployed separately , Loose coupling between micro Services , Each microservice only focuses on completing one task and accomplishing it well .

2.1 advantage

 Please add a picture description

  • It's easy to test
  • Scalable
  • High reliability
  • Cross language
  • Collaborative development
  • Facilitate system iteration

2.2 shortcoming

 Please add a picture description

  • The operation and maintenance cost is high , There are many deployment projects
  • Interface compatible version problem
  • Distributed system complexity
  • Distributed transactions

3、 ... and 、SOA vs Microservices

The service is SOA Developed products , It is a relatively modern fine-grained SOA Realization way

SOA( Service oriented ) Microservices
Maximize the reusability of application services Focus on decoupling
Systematic changes need to be modified as a whole The systemic change is to create new services
DevOps And continuous delivery is becoming popular , Not mainstream Strong official clan DevOps And continuous delivery
Focus on business function reuse Pay more attention to Context The border The concept of
Communication uses the enterprise service bus ESB For communication , Use less and simple messaging systems
Support multiple message protocols Use lightweight protocols , Such as HTTP、REST etc.
Use a common platform for all services deployed to it The application server is not really being used , We usually use the cloud platform
Containers (docker) Is not very popular Containers work well in microservices
SOA Services share data storage Each microservice can have a separate data store
Common governance and standards Easy governance , Pay more attention to teamwork and freedom of choice

Four 、Dubbo vs Spring Cloud

  • Spring Family bucket

    It's very comfortable to use , omnipotent

  • Dubbo

    Many domestic enterprises are still using , Support RESTful Style API, call API Like calling local API equally , At the same time, its interface based approach increases the coupling between services

Contrast item Spring CloudDubbo
Service registry Spring Cloud Netflix EurekaZooKeeper,Nacos
Service invocation mode REST APIRPC
The service gateway Sping Cloud Netflix ZuulDubbo Proxy
Break route Sping Cloud Netflix HystrixSentinet
Distributed configuration Sping Cloud Netflix ConfigNacos
Service tracking Sping Cloud Netflix Sleuth nothing
The message bus Sping Cloud Netflix Bus nothing
Data flow Sping Cloud Netflix Stream nothing
Batch task Sping Cloud Netflix Task nothing

summary

  • Dubbo Because it is binary transmission , Less bandwidth

  • Spring Cloud yes http Protocol transfer , More bandwidth , Use at the same time http, You usually use Json message , More consumption

  • Dubbo Development difficulty hit ,Dubbo Of jar Package dependency problems many large projects can't solve

  • Spring Cloud The interface protocol of is relatively free and loose , Stronger administrative actions are needed to limit the disorderly upgrading of interfaces

  • Dubbo Registration center of ZooKeeper Redis Many other kinds ,Spring Cloud Only use eureka Or self research

  • Simple procedure of system structure :

    ​ Spring Cloud The system structure is simpler : register + Spring MVC = Spring Cloud

    ​ Dubbo: All kinds of complexity Url、protocol、register etc.

  • performance :Dubbo Network consumption is less than Spring Cloud , But most domestic companies , Network consumption is not a big problem , If it becomes a problem , You can compress 、 Binary system 、 Cache 、 Step by step and so on , It's easy to solve

5、 ... and 、 Microservice design principles

5.1 AKF Resolution principle

 Please add a picture description

  • X Axis : Refers to horizontal replication , Is to run more instances of a single system , Become a cluster plus load balancing mode
  • Z Axis : It's based on similar data partitioning , For example, Internet taxi App User surge , The cluster cannot bear , Partition data according to user area , Beijing 、 Shanghai 、 Guangzhou and others will build more clusters
  • Y Axis : The splitting mode of microservices , Split based on different businesses

5.2 Separation principle of front and rear end

 Please add a picture description

  • Front and rear technology separation , Each field can be optimized by its own experts , Improve the front-end user experience
  • Front and rear end separation mode , The front and back interactive pages are clearer , And then there's the interface model , The back-end interface is more concise , Easier to maintain
  • The front-end multi-channel integration scenario is easier , Back end services don't need to change , Use unified data and models , It can support multiple front ends , for example : WeChat H5 front end 、PC front end 、 Android front end 、IOS front end

5.3 Stateless service

 Please add a picture description

5.4 Restful Communication style

 Please add a picture description

  • Stateless protocol HTTP, It has a natural advantage , The ability to expand is very strong
  • JSON Message serialization , Light and simple , People and machines can read , The cost of learning is low , Search engine friendly
  • Language has nothing to do , Every popular language offers mature Restful API frame , Than RPC The framework ecology is more perfect !
原网站

版权声明
本文为[Dily_ Su]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061816108239.html