For interviewer chain gun message queue

1. primer

Distributed system message queue important component of a storage container message, the main role decoupling, asynchronous, cut front, large distributed systems is indispensable middleware.

Common message queue has ActiveMQ, RabbitMQ, RocketMQ, Kafka.

Resume related to the message queue, the interviewer to ask the following questions:

  1. Why do you want to use the system message queue?
  2. Since the use of message queues, talk about what else he use scenarios?
  3. What are the advantages and disadvantages message queue?

2. Why use a message queue?

My answer: Party EOS provides prepaid service, we make the call. For decoupling purposes, the introduction of the message queue.

A similar examination answer method is to think an interviewer asks this question is for what purpose, what kind of want to get the answer?

When asked why the use of message queues, the interviewer desired answer is the company's business challenges faced xxx, MQ do not get into trouble, brought benefits after using MQ.

Can be seen by a problem with the order and with, or after thinking through use.

3. Message Queue usage scenarios?

Q. message queue usage scenarios, and ask what are the advantages message queues, message queues, what role are equivalent.

Message queue has three main effect decoupling, asynchronous, clipping .

Decoupling

Decoupling

B, C, D systems require the use of critical data A generated by the system.

  • When no message queue
    • A system providing a respective interface to the system B, C, D, etc., resulting in tightly coupled systems A and they
    • E system and the need to add interfaces, system B to delete the original interfaces and useless
  • When the message queue
    • A system as producers, sends the message to the message queue
    • System B, C, D as consumers subscribe messaging
    • Consumers simply subscribe to new messages, no effect on the original system and business

asynchronous

Asynchronous .png

When a user requests data, the response time of the system is to ensure that an important part of the user experience.

  • When no message queue
    • After a user request A system, A system needs to wait for execution completion response BCD
    • It received nearly one second user response by
  • When the message queue with
    • A system user request, A push request to the system message queue, B, C, D asynchronous execution
    • When the user receives a response 200 ms

Clipping

Clipping .png

The spike scenario, there are 5,000 requests per second, Mysql second maximum processing 2000 sql.

  • When no message queue
    • Direct user request data to a database, the database concurrency high pressure surge even collapse Ben
    • Mysql is down, the whole system can be used not
  • When there is message queuing systems B, C, D
    • MQ user requests data stored in the first
    • A reading system for processing data per 2000
    • A second plurality unprocessed data 3000 for later processing by the scene

4. Message Queue What are the disadvantages?

In front of the advantages we have already said, also need to discuss shortcomings.

Why do you want to ask disadvantage is that?

Everything has two sides, the advantage of taking into account only if the message queue, without considering the drawback in that a Pandora's Box. Open the Box, what follows will be a series of accidents.

To promote the introduction of other technologies versa, only after taking into account the shortcomings can take additional technical solutions or infrastructure to avoid these shortcomings.

Reduce system availability

  • The more external systems rely introduced, the greater the likelihood of downtime
  • System into the message queue, the message queue is necessary to consider the reliability of
  • Originally only need to consider such as A, B, C, D four systems
  • After the message queue need to consider the introduction of A, B, C, D plus four system message queue

Increase system complexity

  • Message repeated consumption problem
  • Message loss problem
  • Message delivery order issue

Consistency

  • A system returns successfully processed, i.e., that the request was successful
  • But there are cases where BC system successfully written, and written D system failure
  • Such is the case of data inconsistency

to sum up

The interviewer asked MQ when we want to investigate whether there have been in their thinking when using MQ. There is no perfect technology, any technology has two sides, to consider its usage scenarios, and be aware of the possible risks, early prevention.

FIG message queue Mind

Think

After the introduction of the message queue:

  • How to ensure high availability?
  • How to avoid the duplication of spending a message and the message is lost?
  • How to ensure that the message of order execution?

Discuss in the next article.

Guess you like

Origin www.cnblogs.com/shuiyj/p/12656378.html