"Distributed technical principles and algorithm analysis" summarizes four: Distributed Communication Technology

Is the essence of distributed multi-process collaboration together to accomplish the task, certainly we need to communicate with each other

1 long-distance calls

Mutual communication between processes running on different machines, commonly used is RPC, this we should know everything, do not say ~

We can see dubbo, internal RPC + registry is implemented

2 release subscription

Is a direct interaction between the RPC process, when the process relatively long time, will cause the process to maintain communication complexity is very high, and a process-process communication interface changes, with which it communicates are affected;
As the business scale gradually and distributed computing increased and complicated, there has been a dedicated asynchronous communication model, which is the news release subscription model and message queues mode, first explain publish and subscribe

Principle: Producer Consumer

Here Insert Picture Description
Figure is very clear, publish and subscribe can be one to one, one to many, is that the core message center

Scene: kafka, ahead of the needs of consumers subscribe message to the message center, more suitable for consumer-resident process or service scene.

Publish and subscribe model is very similar to the observer pattern, except that: the
Observer Pattern direct communication, the observer and the observed communication delay will be lower, but their dependencies are relatively strong, whether it is to be an observer or observers logic or the interface has changed, is another are affected;
publisher and subscriber indirect communication mode, the message center is introduced, is relatively thick and relatively communication delay will be higher, but to achieve a solution of subscribers and publishers decoupling

Message Queue 3

Publish subscribe model to generate data are created by the message center, the subscriber subscription message of interest, the message center according to the subscriber's subscriptions,
to send messages or data related to the corresponding subscribers, can be understood as "push"

May use "pull", or the data into a message queue, which queue who needs to take will come, this pattern is the message queue mode

Scene: RocketMQ, this model is not particularly consumer demand, and therefore more suitable for the casual user of the consumer scene, more flexible

Comparative message center: a message queue pattern using FIFO queue structure having the characteristics stored, and released using the subscription stored map, or the like array

Published 238 original articles · won praise 268 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_41594698/article/details/105249385