当前位置:网站首页>Architecture decryption from distributed to microservice: several common microservice architecture schemes

Architecture decryption from distributed to microservice: several common microservice architecture schemes

2022-06-24 18:22:00 mb61de96e0d1987


Several common microservice architecture solutions

Here are some common microservice architecture solutions .

ZeroC IceGrid Microservice architecture

ZeroC IceGrid Is a microservice architecture , from RPC Architecture evolved , Good performance and distributed capability , The following is its overall schematic diagram .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ big data

IceGrid It has the following obvious characteristics of the microservice architecture .

First , Microservice architecture needs - A centralized service registry , And some kind of service discovery mechanism .IceGrid Service registration uses XML File to define , Its service registry is Ice Registry, It's a separate process , And it provides HA High Availability Mechanism : The corresponding service discovery mechanism is named query service , namely LocatorService Provided API, You can query the availability of the corresponding service instance according to the service name Address .

secondly , Each microservice in a microservice architecture is usually deployed as an independent process , In stateless service , It is usually served by multiple independent processes . Corresponding to IeeGrid in , One IceBox Is a separate process , When one IceBox Just encapsulate - One Servant when , It is a typical microservice process .

then , A load balancing mechanism is usually embedded in a microservice architecture . stay IceGrid It's through the client API Embedded load balancing algorithm to achieve , Compared with middleware Proxy The way traffic is forwarded ,IceGrid Is more efficient , But it increases the workload and difficulty of platform development , Because the client using various languages needs to implement the algorithm logic of load balancing .

Last , A good microservice architecture platform should simplify and facilitate application deployment . We see IceGrid Provides grid.xml To describe and define a micro service architecture based on Aplication, This is a command line tool Application, It also provides an auxiliary tool for publishing binary programs icepatch2. The image below shows icepatch2 How it works ,icepatch2server Be similar to FTP Sever, Used to store to be published to each Node On the binary code and configuration file , Located in each Node Upper icepatch2client From icepatch2server. Pull up the file , In this process, advanced features such as compressed transmission and differential transmission are used , To reduce unnecessary file transfers . To be fair , stay Docker Before technology ,icepatch2 This method is still very advanced and complete , It also greatly reduces the operation and maintenance workload of microservice system under distributed cluster .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ big data _02

If based on le Grid development system There are usually three typical technical solutions , The following figure shows the three technical solutions .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _java_03

Scheme 1 It is more in line with tradition Java Web A gradual transformation scheme of the project , stay Spring Boot Only in Li Contoller Component without data visit Layer and Service object , these Controller Components through Ice RPC Method calls are deployed in IceGrid Remote in Ice Microservices , Front end oriented packaging is REST service . The overall idea of this scheme is clear , A clear division of responsibilities .

Scheme 2 and scheme 3 are more suitable for the front end JavaScript A competent team , For example, he is good at Node.js Our team can consider scheme 2 , The box JavaScript Instead of Spring Boot Realization REST service . Mainly engaged in Internet App Scheme 3 can be considered for the system , Browser side JavaScript With HTML5 Of WebSocket Technology and Ice Glacier2 Direct communication , Overall efficiency and agility .

IceGrid stay 3.6 The containerized operation mode has been added after version , namely Ice Node And Ice Registry Can pass Docker Start in container mode , This simplifies IceGrid stay Linux. Deployment on . For using Java Compiling Ice Microservice architecture system , We can also use Java Remote class loading mechanism , Let each Node From a remote location HTTPServer Download the specified JAR File and load the relevant Servant class , To achieve something similar to Docker Hub The mechanism of .

SpringCloud Microservice architecture

Spring Cloud Is based on Spring Boot One . A complete framework for implementing microservices , So it can only use Java, This is the obvious difference between it and several other microservice architectures .Spring Cloud yes - An overall plan with many subprojects , Among them is by Netlix The development was later incorporated into Spring Cloud Of Spring Cloud Netlix yes Spring Cloud The core project of microservice Architecture , That is, we can simply think of Spring Cloud Microservice architecture is Spring Cloud Netlix, We use Spring Cloud If you do not specifically state , Is refers to Spring Cloud Netflix.

First ,Spring Cloud The service registry in is Eureka modular , It provides - A service registry 、 The client of service discovery , There is also a simple management interface , All services use Eureka Service discovery client to register itself with Eureka in , The relevant schematic diagram is shown below , You will find that it is very similar to the first 4 A figure in Chapter .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ Distributed _04

that Spring Cloud How to solve the problem of service load balancing ? because Spring Cloud The microservice interface of is mainly based on REST Protocol implemented , So it uses the traditional HTTP Proxy Mechanism . As shown in the figure below ,Zuul Similar to a Nginx The service gateway , All client requests are sent through this gateway visit Backstage service .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ programing language _05

Zuul from Eureka Where to get service information , Automatically complete the mapping of routing rules , No manual configuration is required , Like the one above URL route /customer/* Is mapped to Customer On this micro service . When Zuul When forwarding a request to a specified microservice , Will be similar to ZeroC IceGrid Client load balancing mechanism , go by the name of Ribbon Components , Here is Zzuul And Eureka And the schematic diagram of service load balancing .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ Concurrent programming _06

Here is Spring Cloud A panoramic view of the microservice architecture platform . We see that it obviously inherits SpringFramework The consistent thinking has been integrated !

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ Distributed _07

From the picture ,Spring Cloud The microservice architecture platform integrates the following technologies and functional modules commonly used in project development .

● be based on Spring Security Of OAuth modular , Solve service security problems .

● Provide composite services (Composite Services) The ability of .

● Circuit breakers Hystrix, Realize the fuse protection function for some key service interfaces , If one Services are not responding ( Such as timeout or network connection failure ), be Hytrix The request can be redirected to the fallback method in the service consumer ( flbak method). If the service fails repeatedly , be Hystrix Will fail quickly ( For example, call the internal fallback method directly , No more attempts to invoke the service ), Until the service returns to normal .

● For monitoring Dashboard, It can reduce the development workload related to operation and maintenance .

On the whole ,Spring Cloud Instead of Dubbo A good solution for ,Spring Cloud Is based on REST Micro service of communication interface : Business structure , and Dubbo With RPC Communication based . The performance requirements are not very high Java Internet business platform , use Spring Cloud yes - A relatively low threshold solution .

Message queuing based on micro architecture

Except that the standard is based on RPC signal communication ( And classes RPC For example HTTP REST、SOAP etc. ) Microservice architecture , There is also a microservice architecture based on message queue communication , Microservices in this architecture adopt sending messages (Publish Message) And listening to messages (Subscribe Message) To interact with each other . The following figure shows the interaction between various components under this micro service architecture , We see that message oriented middleware is the key , It is responsible for connecting various microservices with UI Components , It has undertaken the important task of interconnection and interworking of the whole system .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ programing language _08

Message queue based microservice architecture is a design of fully asynchronous communication mode , There is no direct coupling between the components , There is no such thing as service interface and service call , Services communicate with each other through messages and drive business processes , From this point of view , Message queue based microservice architecture is very close to Actor Model . actually , A distributed Actor The model can also be regarded as a microservice architecture , And it has existed for a long time before the concept of microservice came into being . The following is a schematic diagram of a shopping website's Micro service design , We see that it adopts a message queue based microservice architecture .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ Distributed _09

Netease's Honeycomb platform adopts the design idea of microservice architecture based on message queue , As shown in the figure below , Between microservices RabitMQ The message , Achieve communication .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ big data _10

Compared with the above microservice architectures , There are not many microservice architectures based on message queuing , There are also relatively few cases , It's more of a business-related design experience , Each family has its own way of implementation , Lack of accepted design ideas and reference architecture , And it didn't form - A well-known open source platform . If you need to implement this microservice Architecture , Basically, the project team needs to design from scratch - - A microservice infrastructure platform , The cost is high 、 It's a big risk , Architects are needed before decisions are made “ Grounding gas ” To conduct overall thinking and objective evaluation .


If you feel that you are inefficient in your studies , Lack of proper guidance , Rich resources can be added , Let's learn from the technology circle with strong learning atmosphere ! ​[Java Architecture Group ]​​ There are a lot of technical bulls from the front line in the group , There are also farmers who struggle in small factories or outsourcing companies , We are committed to building an equality , High quality JAVA Communication circle , It doesn't have to take everyone's technology by leaps and bounds in the short term , But in the long run , Vision , pattern , The direction of long-term development is the most important .


Docker Swarm Microservice architecture

Docker Swarm ( It is abbreviated to Swarm) It's actually Docker company “ High imitation ”Kubernetes A product of the microservice architecture platform product , Lack of influence in the industry .2016 Released in Docker 1.12 when , Swarm It's integrated into Docker Engine Instead of being released as a separate tool .

Swarmn The initial goal of is to bring some independent Docker The host becomes a cluster , As shown in the figure below , We go through simple Docker Command line tools can create a Swarm colony .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _ Concurrent programming _11

With Kubermetes Microservice architecture platform is more and more widely used ,Docker The company began to try to make Swarm Toward Kubernetes In the direction of , That is, to become a microservice platform based on container technology . Here you go It's out Swarm Structure diagram of the cluster .

 Architecture decryption from distributed to microservice : Several common microservice architecture solutions _java_12

We can see from the above figure , In a Swarm Nodes with two roles in the cluster .

●Swarm Manager: Responsible for cluster management 、 Cluster state maintenance and scheduling tasks (Task) To the work node (Swarm Node) First-class .

●Swarm Node: The bearer runs on Swarm Container instances in the cluster , Every Node All actively report on the tasks running on them (Task) And maintain synchronization .

Docker Compose It is an official choreography project , Provides a YAML File format , Used to describe a containerized distributed application , It also provides corresponding tools to realize the function of one click deployment . The following figure shows the two node Couchbase Clusters correspond to YAML File defines , this Couchbase The cluster was then deployed to Swarm Two in the cluster Node Node .

Last

Feifei to everyone Share An article compiled by front-line development Daniel java High concurrency core programming fairy document , The main knowledge points contained in it are : Multithreading 、 Thread pool 、 Built in lock 、JMM、CAS、JUC、 High concurrency design patterns 、Java Asynchronous callback 、CompletableFuture Class etc. .

It's not easy to code words , If you think this article is useful to you , Please give me one button three times ! Focus on author , There will be more dry goods in the future Share , Stay tuned !



原网站

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