SpringCloud introduction and 5 common components

pringcloud

springcloud is the master of microservice architecture, combining a series of Excellent components are integrated. Based on springboot, it is easier for programmers who are familiar with spring to get started.

Through some simple annotations, we can quickly configure common modules in the application and build a huge distributed system.

SpringCloud’s components are quite complicated and have many sub-projects. Focus on Netflix

share picturesImage source @王璐-Louise. I can’t paint It comes out with such a beautiful picture…

springcloud version description:

< p>The springcloud project is a collection of multiple independent projects. Each project is independent and carries out its own iteration and version release. Therefore, it is not convenient for springcloud to use the version number to Management, but use the version name. To avoid conflicts with the version number of the sub-project.

The source of the version name is London subway station names are sorted alphabetically. For example, the earliest Release version is Angel, and the second Release version is Brixton…

When When a version of update accumulates more or solves a serious bug, a ServiceRelease version, referred to as SR, will be released. The number behind is the first release under the major version.

Share picturesFrom the official website, the F version of springcloud is based on springboot 2.0. x build, the previous one is based on springboot 1.5.x build

The following only Briefly introduce 5 frequently used services

services Discovery-Netflix EurekaCustomer-side load balancing-Netflix RibbonCircuit Breaker-Netflix HystrixService Gateway-Netflix ZuulDistributed configuration-Spring Cloud Config< /span>

Eureka

share picture Function: Realize service governance (service registration and discovery)

Introduction: Spring Cloud Eureka is Spring Cloud Service governance module under the Netflix project.

consists of two components: Eureka server and Eureka client.

The Eureka server is used as a service registry. Support cluster deployment.

Eureka client is a java client used to handle service registration and discovery.

When the application starts, the Eureka client registers its own service information with the server, and at the same time caches the service information of the server locally. The client and the server periodically exchange heartbeats to update the service lease and service information.

Ribbon

Share picturesFunction: Ribbon, mainly provides client-side software load balancing algorithms.

Introduction : Spring Cloud Ribbon is a client-side load balancing tool based on HTTP and TCP. It is implemented based on Netflix Ribbon. Through the encapsulation of Spring Cloud, we can easily convert service-oriented REST template requests into client-side load balancing services. Call.

Pay attention to the figure above. The key point is to convert external rest calls into microservice calls according to the load balancing strategy. Ribbon has comparisons Many load balancing strategies will be explained later.

Hystrix

share pictureFunction: Circuit breaker, protection system, control fault range.

Introduction: In order to ensure its high availability, a single service is usually deployed in a cluster. Due to network reasons or its own reasons, the service is not guaranteed to be 100% available. If a single service has a problem, the thread will be blocked 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.

Zuul

share picturesFunction: api gateway, routing, load balancing and other functions

< p>Introduction: Similar to nginx, reverse proxy function, but netflix has added some features to cooperate with other components.

In the microservice architecture, the back-end service is often not directly open to the caller, but is routed to the corresponding service through an API gateway according to the requested url. When the API gateway is added, the third party calls A wall is created between the client and the service provider. This wall directly communicates with the caller for permission control, and then distributes the requests to the back-end server in a balanced manner.

Config

share picturesFunction: configuration management

Introduction: SpringCloud Config provides server-side and client-side. The default implementation of the server storage backend uses git, so it easily supports the configuration environment of the tag version and can access various tools for managing content.

This is still static, so it needs to cooperate with Spring Cloud Bus to implement dynamic configuration updates.

share picture

Leave a Comment

Your email address will not be published.