Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the SpringCloud micro-service architecture

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to understand the SpringCloud micro-service architecture". In the daily operation, I believe many people have doubts about how to understand the SpringCloud micro-service architecture. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to understand the SpringCloud micro-service architecture". Next, please follow the editor to study!

Nowadays, micro-service architecture is very popular, and using micro-service to build systems will also bring clearer business division and scalability. At the same time, there are a variety of technology stacks that support micro-services, and Spring Cloud is the leader of these technologies.

As a new generation of service framework, Spring Cloud's slogan is to develop "cloud-oriented applications", which provides more comprehensive technical support for micro-service architecture. And as a fist project of Spring, it can also be perfectly integrated with other Spring projects such as Spring Framework, Spring Boot, Spring Data, Spring Batch and so on, which are essential for microservices.

The complete technical composition of Spring Cloud:

Today, I will share with you the most complete and easy-to-understand spring cloud video.

Practice of SpringCloud Micro Service Architecture

Https://www.ixigua.com/6895923297481916939

The carding of theoretical concepts

In the practice of system architecture and design, it can be summarized into three stages macroscopically.

Centralized architecture: all functions and modules are centralized in one project and deployed on a server to provide services (single architecture, single service, single application).

To put it bluntly: there is only one project, only one war

Distributed architecture: all the functions and modules are divided into different sub-projects and deployed on several different servers. These sub-projects cooperate with each other to provide services.

To put it bluntly: there are many projects, there are many war packages, these projects cooperate with each other to complete the required functions, which can not be completed by a war, but not by a war package.

For example:

Shop project: monolithic application

Shop Project: split-- > (user-center, order-center, trade-center) distributed applications

Micro-service architecture: distributed emphasizes the split of the system, and micro-service also emphasizes the split of the system. Micro-service architecture belongs to the category of distributed architecture.

And so far, there is no unified standard definition of micro-service, so what on earth is micro-service?

The term microservice comes from Martin Fowler (Martin. Fowler's post, called Microservices, can be found on his official blog:

Http://martinfowler.com/articles/microservices.html

Chinese translation:

Https://www.martinfowler.cn/articles/microservices.html

To put it simply, micro-service is a design style of system architecture, its main purpose is to split an independent system into several small services, these small services run in their own independent processes, and the services communicate and cooperate through HTTP-based RESTful API.

(dubbo-- > dubbo protocol) RESTful API (controller-- > call congtroller)

After the split, each small service focuses on completing a certain business function in the system, the responsibility is single, and each service is an independent project, which can be tested, developed and deployed independently.

Because each independent service uses HTTP-based JSON as the basis for data communication and cooperation, these micro-services can also be developed in different languages.

For example, there are User module and Order module in the project, but there is no direct relationship between User module and Order module, just some data need to interact, so these two modules can be separated. When user needs to call order, order is a server, but when order needs to call user, user is the server, so they don't care who is the server and who is the caller. They are all two independent services, which is the concept of micro-services.

Classic interview: what's the difference between distributed and microservices?

Distributed is to divide a huge system into multiple modules, which is the same as micro-service, which is to split the system and deploy it to different machines, because one machine may not be able to withstand so much access pressure. in other words, in order to support such a large access pressure, it is necessary to purchase a super-good server, and its financial cost is very high. With these budgets, it is possible to purchase many ordinary servers. Each module of a distributed system exchanges data through interfaces. In fact, distribution is also a kind of micro-service, because it splits modules into independent units and provides interfaces to call them. So what is the essential difference between them?

The essential difference between them is reflected in the "goal". What is the goal, that is, if you adopt a distributed architecture or a micro-service architecture, what is your ultimate goal and what do you want to achieve?

What is the goal of a distributed architecture? That is, the traffic is so large that one machine cannot bear it, or because of the cost, multiple machines have to be used to deploy the service.

And what is the goal of microservices? Just let each module be separated, will not be affected each other, such as module upgrade or the emergence of BUG or refactoring, etc., do not affect other modules, micro-service it can be deployed on a machine

But: distributed is also a kind of micro-service, and micro-service is also distributed.

Interview: what is the relationship or difference between microservices and Spring-Cloud?

Micro-service is only a kind of project architecture, architecture concept, or a concept, just like our MVC architecture, then Spring Cloud is the technical implementation of this architecture.

Interview: do microservices have to use Spring Cloud?

Micro-service is only the architectural way and concept of a project, so any technology can realize this architectural concept, but there are many problems that we need to solve in the micro-service architecture, such as: load balancing, service registration and discovery. A series of problems, such as service invocation, service routing, service breaker and so on, if you start to implement the architectural concept of microservice from 0, you will lose all your hair. So Spring Cloud did these things for us, and Spring Cloud packaged all the technologies to deal with these problems, and we just need to use them out of the box.

What is Spring Cloud?

Official website:

Https://spring.io/projects/spring-cloud

Version: Greenwich SR3

From the official:

Spring Cloud provides developers with tools to quickly build common patterns and solve common problems in distributed systems (such as configuration management, service discovery, circuit breakers, intelligent routing, micro-agents, control buses, one-time tokens, global locks, leadership elections, distributed sessions, cluster state). The coordination of distributed systems leads to a lot of boilerplate code (many fixed patterns of code), and using Spring Cloud developers can quickly build services and applications that implement these patterns. They work well in any distributed environment, including managed platforms such as developers' own laptops, bare metal data centers and cloud computing

Spring Cloud characteristics

Spring Cloud provides good out-of-the-box functionality for typical application scenarios of distributed system development, such as:

Distributed / versioned configuration

Service registration and discovery

Routin

Invocation between services

Load balancing

Circuit breaker

Global lock

Leadership Election and Cluster status

Distributed message delivery

Major projects under Spring Cloud

Spring Cloud Config

Spring Cloud Netflix

Spring Cloud Bus

Spring Cloud Cloudfoundry

Spring Cloud Open Service Broker

Spring Cloud Cluster

Spring Cloud Consul

Spring Cloud Security

Spring Cloud Sleuth

Spring Cloud Data Flow

Spring Cloud Stream

Spring Cloud Stream App Starters

Spring Cloud Task

Spring Cloud Task App Starters

Spring Cloud Zookeeper

Spring Cloud AWS

Spring Cloud Connectors

Spring Cloud Starters

Spring Cloud CLI

Spring Cloud Contract

Spring Cloud Gateway

Spring Cloud OpenFeign

Spring Cloud Pipelines

Spring Cloud Function

The version of Spring Cloud

Spring Cloud is composed of a series of independent projects, each with a different release rhythm. Each time Spring Cloud releases a version, it will combine this series of sub-projects. In order to avoid misunderstanding of the version number and to avoid confusion with the sub-project version number, the version released by Spring Cloud is an alphabetical name of London subway station ("Angel" is the first version). "Brixton" is the second), alphabetically from Amurz, the latest stable version of Greenwich SR3. When critical bug or major updates occur in some sub-projects in Spring Cloud, the release sequence will launch a version with the name ending with ".SRX", where "X" is a number, such as Greenwich SR1, Greenwich SR2, Greenwich SR3.

Spring Cloud is a complete set of solutions developed by micro-services, which is developed with Spring Cloud, and each project still uses Spring Boot.

Compatible versions of Spring Cloud and Spring Boot

The overall architecture of Spring Cloud

Service Provider: the provider of the exposed service.

Service Consumer: the service consumer that invokes the remote service.

EureKa Server: service registry and service discovery center.

The service consumer calls the service provider directly

We know that Springcloud builds microservices based on SpringBoot.

1. Create a SpringBoot project and add SpringBoot dependencies

2. Create the access method of the service provider, that is, how the subsequent consumers access the provider

Spring Cloud is based on rest access, so we add a Controller to provide an access entry in the Controller:

3. Start and run the SpringBoot program and access the controller

Service consumer is also a SpringBoot project, which is mainly used to consume services provided by service providers.

1. Create a SpringBoot project and add SpringBoot dependencies

2. Develop a consumer method to consume the services provided by the service provider, and this consumer method is also

A Controller:

3. Start the SpringBoot program to test the service consumer to invoke the service provider

At this point, the study on "how to understand the SpringCloud micro-service architecture" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report