Spring Cloud microservice architecture diagram

Spring Cloud microservice overall architecture diagram


Write picture description here

Understanding of technical terms in the above figure:

1. Sleuth-link tracking

Provide link tracking for calls between services. Through Sleuth, you can clearly understand which services a service request has passed through, and how long it took to process each service. So that we can easily sort out the calling relationship between the microservices.

2. Circuit breaker (Hystrix)

In the microservice architecture, the services are divided into individual services according to the business. Services and services can call each other (RPC). In Spring Cloud, you can use RestTemplate+Ribbon and Feign to call. In order to ensure its high availability, a single service is usually deployed in clusters. Due to network reasons or its own reasons, the service is not guaranteed to be 100% available. If a single service has a problem, thread blocking will occur when calling this service. If a large number of requests flow in at this time, the thread resources of the Servlet container will be consumed. , Resulting in service paralysis. The dependency between service and service, failure will propagate, and will cause catastrophic and serious consequences to the entire microservice system. This is the "avalanche" effect of service failure. Netflix open sourced the Hystrix component and implemented the circuit breaker mode, and SpringCloud integrated this component

3. Turbine cluster monitoring
Turbine is a tool for aggregation servers to send event stream data to monitor the metrics of hystrix under the cluster.
Through turbine, you can monitor the request volume of the cluster and know the peak period of the system's request, so as to better know where the shortcomings of the system are.

4. Consul service governance and Eureka service governance

Since Spring Cloud has an abstract interface for service governance, a variety of different service governance frameworks can be supported in Spring Cloud applications, such as Netflix Eureka, Consul, and Zookeeper.
The Spring Cloud Consul project is a service governance implementation for Consul. Consul is a distributed and highly available system that contains multiple components, but as a whole, it provides tools for service discovery and service configuration for our infrastructure in the microservice architecture. It includes the following features: service discovery, health check, key/value storage, and multiple data centers. Since Consul itself provides a server, we don't need to create a service registry as we did when implementing Eureka before. It can be used directly by downloading the server program of Consul. Consul supports more registration than Eureka.

5. config configuration management

After the introduction of spring cloud config, our external configuration files can be centrally placed in a git repository, and then a new config server is created to manage all configuration files. When the configuration needs to be changed during maintenance, it only needs to be changed locally. Push to the remote warehouse, all service instances can obtain configuration files through the config server. At this time, each service instance is equivalent to the client config client of the configuration service. In order to ensure the stability of the system, the configuration server config server can be clustered deploy

6、Nginx

Used as a reverse proxy and load balancing. When there is a request, it returns the corresponding server IP to the requester according to the configured scheduling strategy (weighted round-robin, IP hash, minimum number of connections, consistent hash).

7, Zuul service gateway
Zuul's core is a series of filters, its role can be analogous to the Servlet framework Filter
Zuul's main function is routing and filters. It is a unified entrance for various services, and it will also be used to provide monitoring, authorization, security, scheduling, etc.; you can extend ZuulFilter to do various checks before executing the method.

One: What is a microservice (Microservice)

 The English name of the microservice is Microservice. The Microservice architecture pattern is to organize the entire Web application into a series of small Web services. These small Web services can be independently compiled and deployed, and communicate with each other through their exposed API interfaces. They cooperate with each other to provide users with functions as a whole, but they can be expanded independently.

Functions or usage scenarios required by microservice architecture

1: We split the entire system into several subsystems based on business.

2: Each subsystem can deploy multiple applications, and load balancing is used between multiple applications.

3: A service registry is required, all services are registered in the registry, and load balancing is also achieved by using certain strategies for the services registered in the registry.

4: All clients access the background services through the same gateway address. Through routing configuration, the gateway determines which service handles a URL request. Load balancing is also used when the request is forwarded to the service.

5: Sometimes services need to visit each other. For example, there is a user module. When other services process some business, they need to obtain user data of the user service.

6: A circuit breaker is needed to handle timeouts and errors in service invocation in a timely manner to prevent the overall system from being paralyzed due to a problem with one of the services.

7: A monitoring function is also needed to monitor the time spent in each service call.

The current mainstream microservice frameworks: Dubbo, SpringCloud, thrift, Hessian, etc. At present, most domestic small and medium-sized enterprises use Dubbo and SpringCloud.

Two: Introduction to the SpringCloud project

 springCloud is a set of frameworks for implementing microservices based on SpringBoot. He provides the configuration management, service discovery, circuit breaker, intelligent routing, micro agent, control bus, global lock, decision campaign, distributed session and cluster state management required for microservice development. the most important is,

If used with the spring boot framework, it will make you develop a micro-service architecture cloud service very convenient.

SpringBoot aims to simplify the creation of product-level Spring applications and services, simplify configuration files, use embedded web servers, and contain many out-of-the-box microservice functions

The spring cloud sub-projects include:

Spring Cloud Config: The configuration management development kit allows you to put the configuration on a remote server. Currently, it supports local storage, Git and Subversion.

Spring Cloud Bus: Event, message bus, used to propagate state changes in the cluster (for example, configuration change events), and can be combined with Spring Cloud Config to implement hot deployment.

Spring Cloud Netflix: A development kit for a variety of Netflix components, including Eureka, Hystrix, Zuul, Archaius, etc.

Netflix Eureka: Cloud Load Balancing, a REST-based service used to locate services to achieve cloud load balancing and failover of middle-tier servers.

Netflix Hystrix: A fault-tolerant management tool designed to provide more robust fault tolerance to delays and failures by controlling the nodes of services and third-party libraries.

Netflix Zuul: Edge service tool is an edge service that provides dynamic routing, monitoring, resiliency, security, etc.

Netflix Archaius: Configuration management API, including a series of configuration management APIs, providing functions such as dynamic typing attributes, thread-safe configuration operations, polling frameworks, and callback mechanisms.

Spring Cloud for Cloud Foundry: Binding services to CloudFoundry through the Oauth2 protocol, CloudFoundry is an open source PaaS cloud platform launched by VMware.

Spring Cloud Sleuth: Log collection toolkit, encapsulates Dapper, Zipkin and HTrace operations.

Spring Cloud Data Flow: Big data operation tool, which operates data flow through command line.

Spring Cloud Security: Security toolkit, add security control to your application, mainly refers to OAuth2.

Spring Cloud Consul: encapsulates Consul operations. Consul is a service discovery and configuration tool that can be seamlessly integrated with Docker containers.

Spring Cloud Zookeeper: A toolkit for operating Zookeeper, used for service registration and discovery using zookeeper.

Spring Cloud Stream: Data stream operation development kit, which encapsulates the sending and receiving of messages with Redis, Rabbit, Kafka, etc.

Spring Cloud CLI: Based on Spring Boot CLI, you can quickly build cloud components from the command line.

Three: SpringCloud feature
1: Convention is better than configuration

2: Out of the box, quick start

3: Suitable for various environments

4: Lightweight components

5: Rich component support and complete functions

Guess you like

Origin blog.csdn.net/wujian_csdn_csdn/article/details/81701320