3. What common components does Spring integrate?

Since the release of version 1.0 in 2004, Spring has now evolved to version 5.x, providing strong support for application development in different eras. Now that we are facing new challenges like microservices, DevOps, and Cloud computing, what kind of support will Spring Cloud provide us? To sum up, I think there are four main categories:

  • On the construction of a single microservice, it provides a set of application development Framework, the main body is based on the Spring Framework, the ecological open source products.
  • In terms of horizontal dimension service integration, it integrates a large number of common components and microservice buckets in the way of Starter, which can be used out of the box to reduce the difficulty of developing microservices, improve efficiency and avoid repeated investment.
  • In terms of vertical dimension resource scheduling, it can be smoothly integrated with Cloud Foundry, Kubernetes, Docker, etc., making Cloud application simpler, resource scheduling more intelligent and efficient, and making application more flexible.
  • In terms of overall connectivity of the R&D process, it can coordinate and optimize devOPs-related systems, so that applications can go through various r&d stages more smoothly, and continuous integration and continuous delivery can be more efficient.

Next, we’ll expand each point and take a look. First, let’s take a look at what common components it integrates:

  • Monitoring services, including host monitoring (Vector) and application monitoring (Actuator);
  • Storage services, including relational database (MySQL), document database (MangoDB), memory database (Redis), etc.
  • Message service classes, including ActiveMQ, RocketMQ, Kafka, etc.
  • Security services, including OAuth2.0, JWT, etc.

4. What are the Spring Cloud microservice buckets?

In addition to the usual components, Spring Cloud also integrates the microservices family bucket, right out of the box:

  • Service registration discovery classes, including Eureka, Consul, Zookeeper, and Etcd. Service registration: Each microservice component registers its services with the registry, including the host, port number, version number, communication protocol and other information of the service. The registry organizes the service list according to service types and monitors whether the services in the list are available by heartbeat detection. If the services are not available, they need to be removed from the service list to rectify faults. Service discovery: Under the service governance framework, the invocation between services is no longer implemented by specific instance addresses, but by invoking requests from service names. The service caller retrieves a list of service instances from the registry’s list of services by service name and retrieves a service instance location by a specified load balancing policy to make the service invocation.

  • Service invocation framework classes, including: Ribbon, Feign, etc. Client load balancing, which integrates load balancing logic to consumers who learn from the registry what instances of the service are available and then choose one of those addresses to access according to some policy.

  • Service fault tolerant component classes, including: Hystrix, etc. Service meltdown: When a target service is unavailable or a large number of access times out, the system disconnects the invocation of this service. For subsequent invocation requests, the system does not continue to forward the invocation request to this service and directly returns a failure response to release resources quickly. If the target service improves, the call resumes. Service degradation: In the case of emergency masking or service meltdown, the local default reply is returned directly.

  • Unified configuration central class, including: Spring Cloud Config, Spring Cloud Bus, etc. In the service construction phase, cooperate with the construction pipeline to provide configuration for the service software package or image; In the service operation and maintenance stage, service configuration is dynamically adjusted to meet the flexibility requirements of operation and maintenance. During the service development phase, providing a configuration API externalizes the configuration for other system calls.

  • Service Gateway proxy classes, including: Zuul, Spring Cloud Gateway, etc. It mainly provides the service routing function, that is, receives all the requests from the consumer and forwards the requests to the service provider according to a certain policy. At the same time, complete a series of cross-cutting functions in the service gateway, such as: permission verification, request metering, flow control, quality of service, request management, response management, version management, etc.

  • Call link monitoring classes, including Spring Cloud Sleuth, which encapsulates Dapper, Zipkin and HTrace, etc. The number of components in microservice architecture is large, and a business request may need to invoke multiple services. The complexity of invocation makes it difficult to locate errors and exceptions. We need to know exactly what services are involved in each request and what the order of invocation is, so that we can know each invocation step and locate problems quickly.

We usually use Eureka as the service registry to realize service registration and discovery. Service consumption and client load balancing through the Ribbon and Feign; External configuration and version management of different environments are implemented through Spring Cloud Config. To make the service cluster more robust, Hystrix’s melt-down mechanism prevents failure creep and avalanches when individual services fail in the microservices architecture. Service gateway Zuul is a microservice architecture portal, which migrates heavy non-business logic content such as permission control, metering and billing to the service routing level, so that the main body of service cluster can have higher reusability and testability.

The main value of this article is to help you sort out the knowledge framework related to Spring Cloud, which is often referred to as the global perspective or God perspective. With this framework, we can look for related node information according to our own needs to study and learn, so as not to get lost in details. Of course, considering that each of us has different work and study situations, and the problems we encounter are also different, the content of this article cannot cover all the problems we encounter, please leave your comments and ask questions.

Today first share here, if you feel valuable, please move your finger to forward to other partners in need. In addition, I will share my experience in career planning, job interviews, skills improvement and influence building in the future. Please pay attention to this column or “IT veteran brother”!

Other articles in this series are indexed below:

  • How to use Spring Cloud correctly? 【 the 】
  • How to use Spring Cloud correctly? 【 the 】