springcloud basic theory study one

Prerequisite for learning springcloud: You need to have a certain knowledge of java, springboo, etc., come on, and applaud yourself...

Reference link: https://www.cnblogs.com/kashowres/p/9011665.html

Reference link: https://blog.csdn.net/q15102780705/article/details/100045375

1.1 What is a microservice

Microservice architecture is an architectural pattern or an architectural style. It advocates dividing a single application into a group of small services. Each service runs in its own independent process, and the services coordinate and cooperate with each other. , Provide users with ultimate value. Services use a lightweight communication mechanism 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. 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. There can be a very lightweight centralized management to coordinate these Services can be written in different languages ​​or stored in different numbers.

How to learn and use? In the next study, we will mainly focus on the following red key knowledge and then learn.

Service registration and discovery (Eureka)

Service consumer (rest+Ribbon)

Service Consumer (Feign)

Circuit Breaker (Hystrix)

Circuit Breaker Monitoring (Hystrix Dashboard)

Routing gateway (Zuul)

Distributed Configuration Center (Spring Cloud Config)

Message Bus (Spring Cloud Bus)

Service link tracking (Spring Cloud Sleuth)

1.2 How independent communication between microservices

1.3 What are the differences between SpringCloud and Dubbo

   Dubbo communication mechanism is based on RPC remote procedure call, SpingCloud is based on RESTful API call

The biggest difference: SpringCloud abandoned Dubbo's RPC communication and adopted HTTP-based REST

Strictly speaking, these two methods have their own advantages and disadvantages. Although the latter sacrifices the performance of service calls to a certain extent, it also avoids the problems caused by the native RPC mentioned above. Moreover, REST is more flexible than RPC. The dependency between the service provider and the caller only relies on a contract, and there is no strong dependency at the code level. This is more appropriate in a microservice environment that emphasizes rapid deepening.

The difference between brand machine and assembly machine

Obviously, Spring Cloud is more powerful than DUBBO and covers a wider range. As a major project of Spring, it can also be perfectly integrated with other Spring projects such as Spring Framework, Spring Boot, Spring Data, Spring Batch, etc. These are useful for microservices. In terms of it is crucial. The microservice architecture built with Dubbo is like assembling a computer. We have a high degree of freedom in each link, but the final result is likely to be unlit because of the poor quality of the memory. It is always unreasonable, but if you are A master, these are not problems; and Spring Cloud is like a branded machine. Under the integration of Spring Source, a lot of compatibility tests have been done to ensure that the machine has higher stability, but if you want to use non-original Things outside the component, you need to have enough understanding of its foundation.

Community support and update

Most importantly, DUBBO stopped updating for about 5 years, although it restarted in 2017.7. For the new needs of technological development, developers need to expand and upgrade themselves (for example, Dangdang made DubboX), which is obviously not suitable for many small and medium software organizations that want to adopt a microservice architecture. Small and medium companies are not so powerful. The technical ability to modify Dubbo source code + a complete set of surrounding solutions, not every company has Ali's big cow + real online production environment tested.

1.4 SpringBoot and SpringCloud, please talk about your understanding of them

SpringBoot focuses on the rapid and convenient development of individual individual microservices

         SpringCloud is a global microservice coordination and management framework that integrates and manages individual microservices developed by SpringBoot, and provides configuration management, service discovery, circuit breakers, routing, microagents, Integrated services such as event bus, global lock, decision campaign, distributed conversation, etc.

         SpringBoot can leave SpringCloud to independently use development projects, but SpringCloud cannot do without SpringBoot, which is a dependency relationship

         SpringBoot focuses on the rapid and convenient development of individual microservices, and SpringCloud focuses on the global service governance framework.

1.5 What is a service circuit breaker? What is service degradation

1.6 What are the advantages and disadvantages of microservices? Tell me about the pits you encountered in project development

advantage

l Each service is sufficiently cohesive and small enough, and the code is easy to understand so that it can gather a specified business function or business requirement

l Development is simple, development efficiency is improved, a service may be dedicated to only one thing

l Microservices can be independently developed by a small team, which is composed of 2 to 5 developers

l Microservices are loosely coupled and are functionally meaningful services that are independent in both the development and deployment phases

l Microservices can be developed in different languages

l Easy to integrate with third parties, microservices allow easy and flexible ways to integrate automatic deployment through continuous integration tools such as Jenkins, Hudson, bamboo

l Microservices are easy to be understood, modified, and maintained by a developer, so that small teams can pay more attention to their work results. No need to show value through cooperation.

l Microservices allow you to take advantage of the latest technology integration

l Microservices are only business logic code, and will not be mixed with HTML, CSS or other interface components

l Each microservice has its own storage capacity, which can have its own database or a unified database

Disadvantage

Developers have to deal with the complexity of distributed systems

Multi-service operation and maintenance is difficult, with the increase of services, the pressure on operation and maintenance is also increasing

System deployment dependency

Inter-service communication cost

Data consistency

System integration test

Performance monitoring…………

In development, we have two development models

1. Front and rear separation

a) We Java programmers are relatively happy, why?

b) We only need to manage the back-end, and the H5 engineer at the front-end will follow the agreement

c) Rest address + input parameter format and message convention + output parameter

$.post{rest,jsonParameter,callBack}

Can it be flexibly matched, connecting public libraries + independent libraries? ? ?

2. Full stack engineer

         H5+javaEE+………..

1.7 What are the microservice technology stacks you know? Please list one or two

 Microservice technology stack: a collection of multiple technologies

         If we discuss a distributed microservice architecture, what dimensions does it need? ?

         A distributed microservice architecture dimension Digital life in the E era

                  Service governance

                  Service Registration Computer

                  Service call power bank

                  Service load balancing router

                  Service monitoring... Xiaomi Technology

                         

                          Various brands

                  SpringCloud

 

Microservice entry

Landing technology

Remarks

Service development

SpringBoot、Spring、SpringMVC

 

Service configuration and management

Archaius of Netflix, Diamond of Ali, etc.

 

Service registration and discovery

Eureka、Consul、Zookeeper等

 

Service call

Rest、RPC、GRP C

 

Service fuse

Hystrix、Envoy等

 

Load balancing

Ribbon、Nginx等

 

Service interface call

(Simplified tool for client calling service)

Feign et al

 

message queue

Kafka、RabbitMQ、ActiveMQ等

 

Service Configuration Center Management

SpringCloudConfig、Cherf等

 

Service routing (API gateway)

Zuul et al

 

Service monitoring

Zabbix、Nagios、Metrics、Spectator等

 

Full link tracking

Zipkin 、 Brave 、 Kubernetes 等

 

Service deployment

Docker、OpenStack、Kubernetes等

 

Data flow operation development kit

SpringCloud Stream (encapsulate and send and receive messages with Redis, Rabbit, Kafka, etc.)

 

Event message bus

Spring Cloud Bus

 

……

 

 

1.8 Both eurek and zookeeper can provide service registration and discovery functions, please tell us the difference between the two?

The famous CPA theory in distributed: a distributed system cannot satisfy C (consistency), A (availability) and P (partition fault tolerance) at the same time. Since partition fault tolerance must be guaranteed in a distributed system, we can only make a trade-off between A and C. Here Zookeeper guarantees CP, while Eureka is AP.

Consistency (consistency), data is updated consistently, all data changes are synchronized
Availability (availability), good response performance
Partition tolerance (partition tolerance) reliability

Zookeeper is guaranteed CP

When querying the registry for the service list, we can tolerate that the registry returns the registration information a few minutes ago, but we cannot accept the service directly down and unavailable. In other words, the service registration function requires more availability than consistency. But zk will have such a situation, when the master node loses contact with other nodes due to a network failure, the remaining nodes will re-elect the leader. The problem is that the leader election time is too long, 30 ~ 120s, and the entire zk cluster is unavailable during the election period, which causes the registration service to be paralyzed during the election period. In a cloud deployment environment, it is a high probability that the zk cluster will lose the master node due to network problems. Although the service can eventually be restored, the long-term unavailability of registration caused by the long election time is intolerable.

Eureka is a guaranteed AP

Eureka understands this, so we prioritize usability when designing. All nodes of Eureka are equal, and the failure of several nodes will not affect the work of normal nodes, and the remaining nodes can still provide registration and query services. When Eureka's client registers with an Eureka or finds that the connection fails, it will automatically switch to other nodes. As long as one Eureka is still there, the registration service can be guaranteed to be available (guaranteed availability), but the information is found May not be up to date (strong consistency is not guaranteed). In addition, Eureka also has a self-protection mechanism. If more than 85% of the nodes do not have a normal heartbeat within 15 minutes, then Eureka believes that there is a network failure between the client and the registry, and the following will occur at this time Situation: 
1. Eureka no longer removes from the registration list services that should expire because they have not received a heartbeat for a long time 
. 2. Eureka can still accept new service registration and query requests, but will not be synchronized to other nodes (that is, guarantee The current node is still available) 
3. When the network is stable, the new registration information of the current instance will be synchronized to other nodes

Therefore, Eureka can deal with the situation that some nodes lose contact due to network failures, without paralyzing the entire registration service like zookeeper.

1.9……..

2.5 Why choose SpringCloud as the microservice architecture

Selection basis

Overall solution and framework maturity

Community popularity

Maintainability

learning curve

What are the current microservice architectures used by major IT companies?

Ali Dobbo/HSF

JD JSF

Sina Weibo Motan

Dangdang DubboX

……

Comparison of various microservice frameworks

Function point/service

frame

Options

Netflix/Spring Cloud

tomcat

gRPc

Thrift

Dubbo/DubboX

Functional positioning

Complete microservice framework

RPC framework, but integrated ZK

Or Consul, realize the basic service registration/discovery of the cluster environment

RPC framework

RPC framework

Service framework

Support Rest

Yes Ribbon supports multiple pluggable serialization options

no

no

no

no

Support RPC

no

Yes (Hession2)

Yes

Yes

Yes

Support multiple languages

Yes (Rest form)?

no

Yes

Yes

Yes

Service registration/discovery

Yes (Eureka) Eureka service registry, Karyon server framework supports service self-registration and health check

Yes (Zookeeper/consul)

no

no

Yes

Load balancing

Yes (server zuul + client Ribbon) Zuul-service, dynamic routing Cloud load balancing Eureka (

For middle-tier servers)

Yes (client)

no

no

Yes (client)

Configuration service

Netflix Archaius Spring Cloud Config Server centralized configuration

Yes (provided by zookeeper)

no

no

no

Service call chain monitoring

Yes (zuul) Zuul provides edge services, API gateway

no

no

no

no

High availability/fault tolerance

Yes (server Hystrix + client Ribbon)

Yes (client)

no

no

Yes (client)

Typical application case

Netflix

China

Gooogle

Fackbook

 

Community activity

high

general

high

general

2017.8 restart

Difficulty of learning

medium

low

high

high

low

Document richness

high

general

general

general

high

other

Spring Cloud Bus brings more management endpoints to our application

Support downgrade

Netflix is ​​developing and integrating gRPC internally

IDL definition

More companies that practice

 

Stand-alone system All In One

It can be seen that there is only one project in the eclipse workspace

Such as: Tmall  

                  com.atguigu.service

                          Commodities/transactions/points/orders…….

distributed

         Give professional things to professional people to minimize coupling

         Each module/service is independent of each other and eats separately

         Each tiny process allows professional people to do professional things with professional modules

         Independent deployment

l Split

l Separate processes

l Have its own independent database

 

         Dubbo communication mechanism is based on RPC remote procedure call, SpingCloud is based on RESTful API call

Technical dimension understanding

         The core of microservices is to split the traditional one-stop application into services one by one according to the business, and completely decouple. Each microservice provides a service of a single business function, and one service does one thing.

       From a technical point of view, it is a small and independent process, similar to the concept of a process, which can be started or destroyed by itself, and has its own independent database

Guess you like

Origin blog.csdn.net/qq_30764991/article/details/100327126