1. What is a microservice
1.1, architecture evolution
The development process of architecture is from monolithic architecture, to distributed architecture, to SOA architecture, to microservice architecture.
Monolithic architecture: Java Web program without any split
Distributed architecture: According to the vertical division of business, each business is a single architecture, which calls each other through API.
SOA architecture: SOA is a service-oriented architecture. Different components of its application provide services or consume services to other components through communication protocols on the network, so it is also a kind of distributed architecture.
1.2, microservice architecture
To some extent, the microservice architecture is a further development of the SOA architecture, and there is currently no official definition. Martin Fowler, the father of Microservices, gave a general overview of microservices as follows:
1) At present, there is no unified and standard definition for the microservice industry (While there is no precise definition of this architectural style).
2) But generally speaking, microservice architecture is an architectural pattern or an architectural style. It advocates dividing a single application into a set of small services. Each service runs in its own independent process. Coordinate and cooperate with each other to provide users with ultimate value.
3) A lightweight communication mechanism is used between services to communicate with each other (usually HTTP-based RESTful API). Each service is built around a specific business and can be independently deployed to production environments, production-like environments, etc.
4) In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, the appropriate language and tools should be selected according to the business context to build it, which can have a very lightweight centralized Management to coordinate these services. You can use different languages to write services, or you can use different data stores.
1.3, microservice solutions
The two most popular microservice solutions are SpringCloud and Dubbo.
2. Overview of SpringCloud
2.1, what is SpringCloud
As a Java language microservice framework, Spring Cloud relies on Spring Boot and has the characteristics of rapid development, continuous delivery, and easy deployment. Spring Cloud has many components, involving all aspects of microservices, and is becoming more and more perfect with the promotion of the open source community Spring and Netflix Pivotal.
SpringCloud is an organic collection of a series of components.
2.2, SpringCloud main components
2.2.1、Eureka
Netflix Eureka is a REST-based service discovery component open sourced by Netflix, including Eureka Server and Eureka Client.
2.2.2、Ribbon
A load balancing component open sourced by Ribbon Netflix.
2.2.3、Feign
Feign is a declarative Web Service client.
2.2.4 、 Hystrix
Hystrix is an open source project of Netflix, which provides a fuse function to prevent linkage failures in distributed systems.
2.2.5、Zuul
Zuul is an open source component dedicated to "gateway" solutions incubated by Netflix.
2.2.6、Gateway
Spring Cloud Gateway is a gateway developed by Spring officially based on Spring 5.0, Spring Boot 2.0 and Project Reactor technologies. Spring Cloud Gateway aims to provide a simple, effective and unified API routing management method for microservice architecture.
2.2.7、Config
Spring Cloud provides Spring Cloud Config in distributed configuration, which provides client and server support for external configuration.
2.2.8、 Bus
Using Spring Cloud Bus, you can easily build a message bus.
2.2.9、OAuth2
The microservice system built by Sprin Cloud can use Spring Cloud OAuth2 to protect the microservice system.
2.2.10、Sleuth
Spring Cloud Sleuth is a component of Spring Cloud. Its main function is to provide a solution for service link tracking in a distributed system.
3. Summary
This article provides an overview of the evolution of the architecture and the basic components of Spring Cloud to build microservices.