As one of the most popular technologies, SpringCloud is loved by many developers. Out of the box, simple configuration features allow developers to only focus on the development of business code, without having to struggle with cumbersome and architecture. SpringCloud has also become a skill that Java developers must understand and use.

The series will begin with an introduction to hoxton in its official form, as well as an introduction to the principles of some of the components, with a focus on real-world use. This article will also take care of beginners, some of the detailed configuration will be easy to understand.

The outline

  • Why study Spring Cloud
  • What is Spring Cloud
  • The advantages and disadvantages
  • Required version
  • Component Introduction
  • Application introduction in actual combat

Why study springcloud

Whether it’s a business application or a user application, it’s very simple at the beginning of the business, and we usually implement it as a singleton application. However, as the business grows, the product ideas will become more and more complex, and the application of individual structures will become more and more complex. This leads to several problems with the application:

  • Code structure chaos: Business complexity leads to large code volumes that become increasingly difficult to manage. At the same time, this poses a huge challenge to the rapid iteration of the business;
  • Less efficient development: Developers are working on a set of code at the same time, making it difficult to avoid code conflicts. The development process is accompanied by continuous conflict resolution process, which seriously affects the development efficiency;
  • Troubleshooting is expensive: When an online business finds a bug, the process of fixing it can be simple. However, because there is only one set of code, it needs to be recompiled, packaged, and put online, which is costly.

As the application of monomer structure increases with the complexity of the system, various problems will be exposed. In recent years, microservice architectures have replaced individual architectures, and this trend will become more and more popular. Spring Cloud is the most commonly used microservices development framework and has been widely used in enterprise development.

What is Spring Cloud

Spring Cloud is an ordered collection of frameworks. It makes use of the development convenience of Spring Boot to simplify the development of distributed system infrastructure, such as service discovery and registration, configuration center, intelligent routing, message bus, load balancing, circuit breaker, data monitoring, etc., which can be started and deployed with one click in the development style of Spring Boot. Instead of reinventing the wheel, Spring Cloud is a combination of mature, proven service frameworks developed by various companies and repackaged in the Spring Boot style, eliminating the complexity of configuration and implementation principles. Finally, developers are left with a set of distributed system development kit that is simple to understand, easy to deploy and easy to maintain.

The advantages and disadvantages

Advantages:

  • Produced in the Spring family, Spring is unrivaled in enterprise-level development framework, which can guarantee the follow-up update and improvement
  • Rich components and complete functions. Spring Cloud provides very complete support for microservices architecture. For example, configuration management, service discovery, circuit breaker, microservice gateway, etc.
  • The Spring Cloud community is very active, tutorials are rich, and solutions are easy to find when problems arise
  • The granularity of service separation is finer and the coupling degree is lower, which is conducive to resource reuse and development efficiency
  • It can develop and optimize the service plan more accurately and improve the maintainability of the system
  • Reduce costs for your team, develop in parallel, don’t worry about what other people are doing, focus on your own development first
  • Microservices can be cross-platform and can be developed in any language
  • Suitable for the Internet era, the product iteration cycle is shorter

Disadvantages:

  • Too many micro services, high governance costs, is not conducive to the maintenance of the system
  • The high cost of distributed system development (fault tolerance, distributed transactions, etc.) is challenging for teams

In general, the advantages of Spring Cloud are more than disadvantages. At present, It seems that Spring Cloud is a very complete distributed framework. At present, many enterprises start to use microservices, and the advantages of Spring Cloud are obvious. Therefore, for students who want to study microservices architecture, learning About Spring Cloud is a good choice.

version

This tutorial is integrated with the latest Hoxton RELEASE.

Why use the Hoxton version?

Since SpringBoot is the underlying infrastructure of SpringCloud, SpringCloud and SpringBoot versions need to be correctly compatible, otherwise there will be many problems in the process of integration. Various classes are not found, methods are not found. Back to the question itself, why use the Hoxton version? It’s because until now, the only official stable update was hoxton.release. In production, it’s best to use the release version.

So how can beginners quickly find the right version?

Check the official documents, of course

Release train Spring Boot compatibility

This shows the latest stable version.

Component Introduction

Springcloud family has many components, not all of them are applicable to us, we need to choose the appropriate components to use in combination with the business, other components can be understood, the following tutorial will be combined with the current popular solutions for integration and use, the following table is the introduction of the popular components:

Component Introduction

Other components will be covered later.

Practical application

Let’s start with a technical architecture diagram:

So let’s say I have a request coming in,

  • The gateway is responsible for the routing of the request (the request is sent to the specific service node), traffic limiting permission authentication (login, permission), and request filtering;
  • The second station is routed to specific services, such as user center, which calls the course management center interface. There are many nodes in the course management center service. Which node should be selected? The ribbon performs load balancing based on specific policies.
  • If the node curriculum management center service the request timeout exception, then feign integrated hystrix is responsible for the service of the fuse, if not fuse can lead to request block, the request has been backlog, eventually lead to the entire server cluster outages, with service circuit breakers, when the service is not available to the node set to unavailable state, The request will be sent to other available nodes, and the node will be polled. If available, the node will be restored to the available state.

conclusion

I covered why springcloud is used and an introduction to the underlying components, which will be covered in more detail later.

Build source code address: WinterChenS/ spring-cloud-Hoxton-study

Reference documents:

Spring Cloud

Spring Cloud Hoxton Release Notes · Spring-cloud /spring-cloud-release Wiki

Springcloud version