[Getting Started with Spring Cloud (1)] What is Spring Cloud?

I. Overview

Cluster: Multiple service nodes of the same software service jointly provide service processes for the system, which is called the software service cluster.

Distribute: Distributed is a system architecture that distributes different components in the system on different computers for execution. A distributed system is a system composed of multiple independent computer nodes. The design of a distributed system needs to be considered. Many important factors such as communication method, data consistency. Therefore, the design and implementation of distributed systems require the use of appropriate technologies and tools, such as distributed algorithms, message queues, load balancing, etc. Different software clusters jointly provide services for a system, which is called a distributed system.

Micro Service: Microservice is an architecture that divides a single overall application into independent services associated with smaller projects. A service usually implements a set of independent features or functions, containing its own business logic and adapters (kind of like forcing an application to adhere to the single responsibility principle). The association between various microservices is achieved by exposing APIs. These independent microservices do not need to be deployed in the same virtual machine, the same system and the same application server.

Why microservices?

Single application

Insert image description here

# 1. 优点
-	单体架构模式在项目初期很小的时候开发方便,测试方便,部署方便,运行良好
# 2. 缺点
-	应用随着时间的推进,加入的功能越来越多,最终会变得巨大,一个项目中很有可能数百万行的代码,互相之间繁琐的jar包。
-	久而久之,开发效率低,代码维护困难。
-	还有一个如果想整体应用采用新的技术,新的框架或者语言,那是不可能的。
-	任何模块的漏洞或者错误都会应用这个应用,降低系统的可靠性。

Microservice architecture application

Insert image description here

# 1. 优点
-	将服务拆分成多个单一职责的小的服务,进行单独部署,服务之间通过网络进行通信。
-	每个服务应该有自己单独的管理团队,高度自治
-	服务各自有自己的单独的职责,服务之间松耦合,避免因一个模块的问题导致服务崩溃
# 2. 缺点
-	开发人员要处理分布式系统的复杂性
-	多服务运维难度,随着服务的增加,运维的压力也在增大
-	服务治理 和 服务监控 关键

Spring Cloud is used to deal with problems that may arise in the microservice architecture. It has various components inside, and each component is used to deal with these problems. So it can be said that Spring Cloud is a tool (framework) for processing microservice architecture applications.

The evolution of architecture

Insert image description here

  1. All In One

At first, when the website traffic was very small, all functions were written in one application and the entire application was deployed to reduce deployment nodes and costs. For this architecture, a data access framework (ORM) that simplifies the workload of adding, deleting, modifying, and retrieving is key.

  1. vertical architecture

As the number of visits gradually increases, the acceleration brought by a single application amplifier becomes smaller and smaller. One way to improve efficiency is to split the application into several unrelated applications to improve efficiency. At this time, the web framework (MVC) used to accelerate front-end page development is the key.

  1. Distributed service architecture (Tomcat cluster, MySQL cluster, Redis cluster)

When there are more and more vertical applications, interactions between applications are inevitable. Core businesses are extracted and used as independent services to gradually form a stable service center, allowing front-end applications to respond more quickly to changing market demands. At this time, distributed service architecture (RPC) to improve business reuse and integration is the key.

RPC: Remote Procedure Call Role: A means of communication between services

OSI seven layers: physical layer, data link layer, network layer, transport layer, session layer, presentation layer, application layer

  1. SOA Service Oriented Architecture Micro Service (Micro Service)

When there are more and more services, problems such as capacity evaluation and resource waste of small services gradually arise. At this time, it is necessary to add a dispatch center to manage the cluster capacity in real time based on access pressure and improve cluster utilization. At this point, resource scheduling and governance (SOA) to improve resource utilization are key.

Microservice solutions

Insert image description here

a. 国内的阿里系

SpringBoot + Dubbo + Zookeeper	最早期

b. Spring Cloud 技术栈

Spring Cloud netflix	
最早期(基于Netflix公司开源的组件进行封装,提供了微服务一栈式解决方案)

Spring Cloud  Spring	
自己封装的服务解决方案(在Spring Cloud Netflix基础上封装了阿里巴巴的微服务的解决方案)

Spring Cloud  alibaba	
阿里巴巴解决方案(目前Spring官方趋势整在逐渐吸收Netflix组件的精华,并在此基础进行二次封装优化,打造Spring专有的解决方案)

2. Introduction to Spring Cloud

Spring Cloud is a Java languageMicroservice framework (Microservice is an idea and an architecture, and Spring Cloud is a Its implementation, it can be used to manage all aspects of microservices), it relies on Spring Boot, and has the characteristics of rapid development, continuous delivery and easy deployment. There are many Spring Cloud components, covering all aspects of microservices, making it easier for us to manage.

Spring Cloud inherits some of the advantages of Spring Boot in development and deployment, improving its efficiency in development and deployment. **The primary goal of Spring Cloud is to help developers quickly build a distributed microservice system by providing a series of development components and frameworks. **Spring Cloud is implemented by packaging other technology frameworks, such as packaging open source Netflix OSS components, and implementing a microservice framework based on annotations, Java configuration and template-based development. Spring Cloud provides some common components for developing distributed microservice systems, such as service registration and discovery, configuration center, circuit breaker, remote call, intelligent routing, micro-agent, control bus, global lock, distributed session, etc.

Study URL:

Spring Cloud official document address

Documentation of Spring Cloud Alibaba

The version correspondence can be viewed in the corresponding document.

3. SpringCloud common component table

Insert image description here

Service registration and discovery. (eureka, nacos, consul)

Load balancing of services. (ribbon, dubbo)

Services call each other. (openFeign, dubbo)

Service fault tolerance. (hystrix, sentinel)

Service gateway. (gateway, zuul)

Unified management of service configurations. (config-server, nacos, apollo)

Message bus for services. (bus)

Service security components. (Security, Oauth2.0)

Service monitoring. (admin) (jvm)

Link tracing. (sleuth+zipkin)

Microservice architecture style diagram (from power node)

img

Guess you like

Origin blog.csdn.net/qq_63691275/article/details/132039781