The ultimate note on microservices: "Take Kyoto directly" through needles, and refuse to straggler

Preface 

The most taboo for learning knowledge is "a hammer in the east and a stick in the west" unless you have the willpower to learn and a tireless learning attitude. Xueba and Xueshi always get more attention, but most people are between Xueba and Xueshi.

How many can perseverely be buried in the sea of ​​books to resist loneliness? In the same way, no one really wants to waste their lives and live in a misty way. Who doesn't want to work hard?

Why use microservices? Decoupling! Regardless of multi-language development, independent deployment, scalability, independent database, team split and agile development, just two words: decoupling! ! ! ! ! Ask again to cut JJ

for example?   Payment and points are taken as examples. If the points service is suspended, the payment can be used normally because they are deployed on different hosts.

Microservice concept?   Microservice architecture is an architectural pattern in which a single application is divided into a set of small services, each service is an independent process, and the services coordinate and cooperate with each other. The services use a lightweight communication mechanism to cooperate with each other (usually restful api based on HTTP protocol).

The evolution process from monolithic architecture to microservices : less business ---" monolithic architecture beauty

- "Business increase and poor application performance --- " Read and write separation, add cache, add load balancing server, application cluster deployment

--- "Management is chaotic, governance is difficult, and headaches ----" Consider distributed systems and microservice architecture. (The follow-up will be in no particular order)--" Registration center manages all services

---"Too much configuration is annoying---" Add a configuration center

--- "Deploying so many machines, some machines are too much to visit, and some machines are idle for a long time ---" Do a load balancing

----" The service ran and found that a service B host was down, and service A called B, causing a large number of threads to block A, and finally A also hung up, and finally a large number of microservices were hung up with the "avalanche effect"- ----》Add a fuse

----"All cats and dogs will adjust my service, I don't want them to adjust, so I have to add a permission control and routing and forwarding function----" Add a gateway

---"I was complained today. One customer paid a fee, and one week has passed without seeing an increase in points. It turned out that the micro-service of the points was suspended before, but the points did not increase after the payment was successful. ------" Talk about distributed transaction solutions (two-phase, TCC, etc.)

--- "There was a problem in production, and N microservices were called in the middle. I don't know which link is the problem. I still don't know the specific call link. Find a ghost, how to dump the pot ------ " Call Link Tracking (Zipkin)

---" Beautifully, running steadily, suddenly the leader said: Look at how many interfaces we have, and how many calls-"mmp....

 

What are the core components of microservices?   Registration center, load balancing, service fuse/downgrade, gateway, configuration center, remote call, etc.

There are three main ways to develop
 microservices:1. dubbo+zookeeper   
 2. spring boot+spring cloud
 3. ServiceComb
dubbo: is an RPC framework with netty at the bottom layer (what is netty? It is a package improvement for NIO, simple It is a high-performance network communication framework. What is NIO? Ge Wu En!), micro-service call, load balancing, service registration.
zookeeper: service registry
spring boot: encapsulation of the spring family bucket, not a new technology.
spring cloud: a set of microservice framework based on springboot, a solution.
servicecomb: It is also the apache open source framework. Compatible with springcloud's microservice framework, using Saga to provide a one-stop solution, service deployment governance and monitoring.

Communication methods between microservices: REST protocol (http-text), RPC (binary).

RPC: The essence is the process of converting an object into a binary system, and then performing network communication through a socket. After the callee gets the binary data, it converts it to a java object and calls the specific interface. Dubbo is an RPC framework, and the bottom layer is implemented by Netty.

Netty:  https://mp.csdn.net/editor/html/114745014

The three major problems of microservice architecture? Poor splitting, distributed transactions, and a single failure cause a large number of upper-level threads to block.

Deployment container comparison :
monomer: serlet container such as tomcat, jettry, etc. Microservice
: Docker container

Transaction difference comparison :

Monomer: Controlled by Transactional, the transaction of the database itself.
Microservices: Distributed transactions. Solutions include two-phase commit, three-phase, TCC, and MQ message transactions.

Five major components of springcloud : registration center eureka, load balancing ribbon, service fuse hystrix, configuration center springcloudconfig, and gateway zuul. In fact, there are remote calls to feign.

The appetizer is over!

Anything, if too many people know, then you have no advantage.


Microservice CAP theory : Consistency (consistency), Availability (availability), Partition tolerance (partition tolerance), it is impossible to satisfy "consistency", "availability", and "partition tolerance" at the same time.

The types of registration centers are AP and CP. AP has priority to ensure availability, and CP has priority to ensure consistency. AP stands for: zookeeper. CP stands for: eureka of springcloud, nacos of Ali can support both AP and CP.

Although now many use nacos to replace eureka,

 

Eureka is divided into client and server. An eureka can be either a client or a server. The client sends a heartbeat every 30s after the service starts, and the server checks whether a heartbeat is received every 90s. Unfortunately, it stopped updating after eureka2.0. Currently, it is generally replaced by Ali's nacos.

What is Eureka's self-protection model

By default, if Eureka Service does not receive the heartbeat of a certain microservice within a certain period of time, Eureka Service will enter the self-protection mode. In this mode, Eureka Service will protect the information in the service registry without deleting the information in the registry. Data, when the network failure is restored, the Eureka Servic node will automatically exit the self-protection mode.

The following error warning will appear on the server:

EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

 

Guess you like

Origin blog.csdn.net/x18094/article/details/114737297