In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to understand micro-service architecture technology". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to understand micro-service architecture technology".
The development of architecture
Today's science and technology can be said to be changing with each passing day and developing rapidly. Compared with our software design industry, great changes are taking place. The business is becoming more and more complex, the requirements are becoming larger and larger, and the scale of software architecture and deployment is also undergoing earth-shaking changes.
As one of the ideas of software architecture, "micro-service architecture" is also evolving according to its own law, and then we will briefly understand the three periods of the development of "micro-service architecture". These are just personal understandings.
Monolithic architecture (Monolithic)
The era of single application: no matter how layered the application is, it is a solution, or a project. The "solution" and "project" here are not concepts in the Visual Studio we use, and the final program code will run in the same process.
As shown in the figure:
Advantages: simple development, centralized management, no distributed wear and tear, all communication within the system process.
Disadvantages: difficult to maintain, difficult to upgrade, serious coupling, unable to cope with high concurrency and big data scenarios, unable to iterate quickly.
Vertical split
With the increasing scale of the business, the system design becomes more and more complex, and the large system begins to split the business vertically.
For example, there are departments that specialize in killing goods in seconds, departments that specialize in fresh goods, departments that specialize in supermarkets, and so on. Of course, this is naturally divided according to departments, and there is also a systematic division according to business needs.
As shown in the figure:
Advantages: vertical split, independent deployment and maintenance of the system, each system in its own process, divide and conquer.
Disadvantages: the more splits, the more complex the storage, the more repetition between systems, and the single system is still in a single mode.
Distributed service
With the increasing size of the business system, the design of the software system is becoming more and more complex. In order to avoid excessively complex business requirements, we begin to split the business system vertically to form multiple independent business systems. if multiple systems want to communicate, we can complete the communication through cross-process technology.
However, vertical splitting also leads to a large number of duplicate codes and modules, such as user module, log module, payment module, authentication and authorization module and so on. This scattered code also brings difficulties to the maintenance and upgrade of the system.
We re-divide the business, interface independent modules, service-oriented, and improve reuse. At this time, we begin to enter the era of distributed services. (the first priority of distribution is not to be distributed.)
As shown in the figure:
Advantages:
Independent process deployment, independent process operation, independent evolution. High cohesion and low coupling can be achieved between services.
Independent development and maintenance, business decoupling, both business systems and distributed services evolve independently.
Distributed management.
Increased isolation.
Assembled by a series of services into a system, there is no need to repeat construction, modules, code can be reused.
Disadvantages:
Data consistency (multi-service accomplishing a task) and system availability (clustering) become problems.
The database is also split.
The cost of maintenance, design and architecture increases, and debugging and error correction are more difficult.
Distributed loss cost of network transmission.
Not suitable for high concurrency and big data environment.
Micro-service architecture
With the emergence of micro-services, the distributed architecture has been very mature, and there have been very mature solutions to various problems in the architecture. for today's business systems, distributed architecture has become a conventional means, at this time, micro-services appeared.
Micro-service architecture is an architecture pattern (architecture style) that uses distributed services to split business logic and complete decoupling.
Micro-service must be a kind of distributed, after the distributed technology is mature, and then use distributed as a decoupling means to construct the system.
Because the split service is very meticulous, the number and scale of the service begins to become more and more, and the volume of the service begins to shrink, changing from several large services to multiple independent, atomic services.
As shown in the figure:
The most important features of microservices are:
Availability: describes the ability of a system to provide useful resources over a period of time, thereby reducing downtime while maintaining the high availability of its services.
Scalability: the ability to dynamically add and remove resources from the system according to demand, which is a specialized implementation of horizontal or vertical expansion.
Clustering (load balancing) can solve the high availability and scalability characteristics of the system.
SOA Service oriented Architecture
Service-Oriented Architecture Service-oriented Architecture: a component model that splits different functional units of an application (called services) and connects them through well-defined interfaces and protocols between these services.
As shown in the figure:
The Development of Micro-Service Architecture
If we want to solve the two problems of high availability and scalability of micro-services, we will naturally think of implementing them through clusters.
If we implement a service cluster, then two other problems will arise, which also lead to differences in the development version of the micro-service architecture.
The first: the problem of service discovery, how the caller discovers the service, how do we know that there is a service instance offline, and how do we know that it is very important to find the service? this is the basic problem, the first problem is not solved, and the second problem cannot be realized.
The second: how to invoke services and how to manage so many service instances. With so many cluster instances and so many service instances, how can we invoke these services? What about the relationship between multiple service invocations?
Because of these problems, let's take a look at how the three versions of the microservices architecture are solved.
① centralized agent: Nginx (V1.0 (service registration / service discovery-manual))
As shown above:
Service discovery, manually modify the configuration file, restart.
Load balancing, can rotate training, weight, hash and so on.
The new service cannot be found and needs to be configured manually. The service drop can be checked automatically.
The implementation of the client is very simple, no additional code is needed, simple and efficient.
② client embedding: Consul (V2.0 (Service Registration / Service Discovery-automatic-- Service Governance))
As shown above:
Service registration and discovery, dynamic increase, automatic completion.
Health check, you can check the damage service, remove the service, and complete it automatically.
Load balancer. Consul returns all active service instances, and the client implements load balancer on its own.
Powerful, automatic discovery-automatic offline, client integration is more complex, load balancing is implemented on the client side.
③ Service Grid: Service Mesh (V3.0 Murray-immature technology, Huawei + VIPSHOP, lstio)
SideCar services manage the registration and discovery of service instances, the governance and invocation of service instances. Service Mesh's Control Plan manages all SideCar.
I will not talk much about this technology, and there are a lot of information on the Internet. At present, this technology is not very mature and the scope of use is not very wide. Only some large companies have used it, such as Microsoft and so on.
Essential technology stack of micro-service architecture
Micro-service is a kind of software design, architecture idea, of course, it also contains the relevant technical points to solve the current priorities. Learning micro-services, we can not talk about empty words, must be implemented on the specific technology stack.
Today, there are more than two technology systems, one is Java, the other is Net, needless to say, I am a software architect who uses Microsoft's related technology stack, of course, the "micro-service" architecture technology stack is also Microsoft's.
Today, I will list the technology stacks used in the relevant "micro-service architecture". I would also like to explain that many technologies in the micro-service architecture are independent of the development language and can be used on both .net and Java platforms. In the future, we will do in-depth research on each technology step by step.
① service communication
WebService, WCF, WebAPI, or even ASHX,ASPX, these are Microsoft's own technology systems, and there is nothing to say:
Active trigger
Data serialization transfer
Cross platform
Cross-language
Http penetrates the firewall
② process communication
Net Remoting:Net platform supervises mail, does not support cross-platform.
GRPC: high-performance, open source and general RPC framework for server and mobile, based on HTTP/2 design, recommended.
③ API Gateway Service (Ocelot)
API gateway: it is an access portal for the system to be exposed to the outside world. This is a bit like an agent visiting guy, like a company doorman responsible for addressing, restricting access, security checks, location guidance, and so on.
Ocelot is an open source API gateway implemented in .NET Core. It has powerful functions, including: routing, request aggregation, service discovery, authentication, authentication, current limit circuit breaker.
And built-in load balancer integrated with Service Fabric and Butterfly Tracing. These functions only need a simple configuration to complete.
As shown in the figure:
Official website:
Https://ocelot.readthedocs.io/en/latest/index.html
④ Authentication & Authorization
Nowadays, there are an endless stream of application development, such as web applications based on browsers, official accounts based on Wechat, Mini Program, App based on iOS and Android, desktop applications based on Windows systems, UWP applications and so on.
So many kinds of applications bring challenges to the application development. in addition to implementing each application separately, we also need to consider the interaction between each application and the refinement of general modules. identity authentication and authorization are an indispensable part of each application.
Nowadays, the Internet is very demanding for information security, so a set of unified identity authentication and authorization is very important.
IdentityServer4 is such a framework. IdentityServer4 is an authentication and authorization middleware tailored for ASP.NET CORE that implements OpenId Connect and OAuth3.0 protocols.
Project address:
Https://github.com/IdentityServer/IdentityServer4
Transient fault treatment of ⑤
Polly is a powerful class library. Polly is a .NET resilient and transient fault handling library that allows us to implement policies such as line retry, circuit breakage, timeout, fault recovery and so on in a very smooth and thread-safe manner.
Polly is targeted at .NET 4.0 and .NET Standard 1.1 and .NET Core implementations. The author of this project is now a member of the .NET Foundation. The project is constantly iterating and updating, and you deserve it.
Project address:
Https://github.com/App-vNext/Polly
⑥ distributed tracking
With the popularity of micro-service architecture, some problems under micro-service architecture will become more and more prominent, such as a request will involve multiple services, and the service itself may also rely on other services, and the whole request path constitutes a network of call chains.
In the whole call chain, once an exception occurs in a node, the stability of the entire call chain will be affected, so you will deeply feel that the word "silver bullet" does not exist, and each architecture has its own advantages and disadvantages.
In the face of the above situation, we need some tools that can help understand the system behavior and analyze performance problems, so that when a fault occurs, we can quickly locate and solve the problem. At this time, the APM (Application performance Management) tool should make its debut.
Project address:
Https://github.com/SkyAPM/SkyAPM-dotnet
⑦ distributed log
Generally, we need to do log analysis scenarios: you can get the information you want by grep and awk directly in the log file.
However, in the large scale, that is, the large number of logs and complex scenarios, this method is inefficient, including how to archive if the log is too large, what to do if the text search is too slow, and how to query in multiple dimensions.
Centralized log management is required, with log collection summarization on all servers. The common solution is to establish a centralized log collection system to collect, manage and access the logs on all nodes.
Large-scale systems are usually a distributed deployment architecture, and different service modules are deployed on different servers. When problems occur, most cases need to locate specific servers and service modules according to the key information exposed by the problem. Building a centralized log system can improve the efficiency of locating the problem.
Exceptionless: an open source real-time log collection framework, it can be used in applications based on technology stacks such as ASP.NET,ASP.NET Core,Web Api,Web Forms,WPF,Console,MVC, and provides a Rest interface that can be used in Javascript,Node.js.
It makes log collection easy to use and does not need to know too many technical details and configuration.
In the past, we mostly used frameworks such as Log4net,Nlog to collect logs. When the application becomes complex and clustered, the traditional approach may not be very suitable, because collecting logs and analyzing them will become troublesome and a waste of time.
Now the Exceptionless team has provided us with a better framework to do this, which I think is great and meaningful, thanks to them.
Official website:
Http://exceptionless.com/
GitHub:
Https://github.com/exceptionless/Exceptionless
ELK: is the abbreviation of three open source software, namely: Elasticsearch, Logstash and Kibana, they are all open source software.
However, a new Beats has been added, which is a lightweight log collection and processing tool (Agent). Beats takes up less resources and is suitable for collecting logs on various servers and transferring them to Logstash. This tool is also officially recommended.
At present, due to the addition of the Beats tool to the original ELK Stack members, it has been renamed to Elastic Stack, which is recommended.
⑧ distributed configuration Center
Apollo (Apollo) is a configuration management platform developed by Ctrip Framework Department, which can centrally manage the configuration of different environments and different clusters, and can be pushed to the application side in real time after configuration modification, and has standardized permissions, process governance and other characteristics.
The server is developed based on Spring Boot and Spring Cloud, which can be packaged and run directly without additional installation of application containers such as Tomcat.
The Java client does not rely on any framework and can run in all Java runtime environments. It also has good support for the Spring environment. The .net client does not rely on any framework and can run in all .net runtime environments.
Project address:
Https://github.com/ctripcorp/apollo/
There are many solutions for distributed locks, and I'll list a few here:
Consul can implement distributed locks.
Redis can implement distributed locks. It is recommended to use
Zookeeper can implement distributed locks.
Database can realize distributed lock
⑩ distributed transaction
There are also many ways to implement distributed transactions:
2PC (two-phase commit protocol, strong consistency, no availability)
3PC
TCC (Try-Confirm-Cancel)
Local message table, recommended RabbitMQ
Saga mode
Local message table: MQ distributed transaction-local message table-based on message consistency.
There is a delivery message on the
Get messages downstream
Upstream delivery stability
Downstream acceptance stability
⑪ containerization
Docker is an open source application container engine that packages applications and dependencies into a portable image and publishes them to any popular Linux and Windows machine, as well as virtualization.
Docker uses the client-server architecture model and uses remote API to manage and create Docker containers.
The Docker container is created through a Docker image. The relationship between containers and mirrors is similar to objects and classes in object-oriented programming.
Docker uses the Cramp S architecture Docker daemon as the server to accept requests from customers and process these requests (create, run, distribute containers).
Client and server can not only run on the same machine, but also communicate through Socket or RESTful API.
Docker daemon typically runs in the background of the host host, waiting to receive messages from the client.
The Docker client provides the user with a series of executable commands that the user uses to interact with Docker daemon.
As shown in the figure:
⑫ container choreography
Kubernetes is an open source container orchestration engine for Google, which supports automated deployment, large-scale scalability, and application containerization management.
When deploying an application in a production environment, multiple instances of the application are usually deployed to load balance application requests.
In Kubernetes, we can create multiple containers and run an application instance in each container, and then manage, discover and access this group of application instances through the built-in load balancing policy, and these details do not need to be manually configured and processed by operation and maintenance personnel.
Kubernetes can also be understood as the orchestration container of Docker, which is a tool for managing the whole lifecycle of applications. It is very convenient from creating / deploying applications, providing services, expanding and downsizing, updating, and can achieve fault self-healing.
Chinese community:
Http://docs.kubernetes.org.cn/
Official website:
Https://kubernetes.io/docs/home/
⑬ CI/CD
Jenkins is an open source, user-friendly continuous integration (CI) tool used to continuously and automatically build / test software projects and monitor the operation of external tasks.
At this point, I believe you have a deeper understanding of "how to understand micro-service architecture technology". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.