[] Why should we use the Message Queue message queues, message queues advantages and disadvantages?

This article first appeared in the public micro-channel number Sakamoto [Mr.]

Original Address: https://mp.weixin.qq.com/s/XjfuMdLZALH7h7JNXrpIpA

First, why the use of message queues

There are three core: decoupling, asynchronous, clipping

(1) decoupling

The traditional model:

The traditional model of disadvantages:

  • Coupling inter-system too, as shown above, the system calling code system A and system B directly in C code, if the future access system D, the system also need to modify the code A, too cumbersome!

Middleware mode:

Middleware advantage mode:

  • Writes messages to the message queue, the system requires its own subscription message from the message queue, so that the system A without any modification.

(2) asynchronous

The traditional model:

The traditional model of disadvantages:

  • Some non-essential business logic running in a synchronized manner, too time-consuming.

Middleware mode:

Middleware advantage mode:

  • Writes messages to the message queue, the non-essential business logic operates in an asynchronous manner, to speed up response

(3) clipping

The traditional model

The traditional model of disadvantages:

  • Concurrent large amount of time, all the hate requests directly to the database, resulting in abnormal database connection

Middleware mode:

Middleware advantage mode:

  • A system in accordance with the amount of slowly concurrent database can handle, and slowly pull message from the message queue. In production, this short peak of the backlog is allowed.

Second, the message queues disadvantages

  • Reduce system availability: If the message queue is running crashes will directly lead to system failure, so to speak: "the complexity of the system and its availability negative correlation"

  • Increased complexity of the system: the need to solve many problems, such as data consistency, the message repeated consumption problem, the message transmission reliability problems

CONCLUSIONS

    Message Queue is good enough to help us deal with: decoupling, asynchronous, clipping problems, but can also cause the system to reduce the availability and increase the complexity of the system. So we need to be careful to introduce, of course, had to use the time to have to use, the best way is to find someone to write a messaging queue to experience some demo program message queue, so that in the future will be able to on their own in the face of business demand response judge

 

 

 

 

Guess you like

Origin www.cnblogs.com/hwtblog/p/12078373.html