MQ that something (six) --- how to do message backlog in the message queue

1. mq large number of messages in the backlog for a few hours yet been solved

Scene: tens of millions of pieces of data in the MQ backlog seven or eight hours from 16:00 more backlog to late at night, 10 points, 11 points. Line fault, this time or else fix consumer problems, let him recover rate of consumption, and then wait several hours consumption silly completed. This is certainly not. 1000 is a consumer one second, one second three consumers is 3000, one minute is 180 000, more than 10 million.
So if you are a backlog of millions to tens of millions of data, even if the consumer recovery, and also takes about one hour to recover.
Solution: "
This can only be operated when the temporary expansion, faster consumption data to the specific steps and ideas are as follows:.
① to fix consumer issues, to ensure that the recovery rate of consumption, and then stop all existing consumer off.
② temporary build good original 10 or 20 times the number of queue (create a new topic, partition is 10 times the original).
after ③ then write consumer program a temporary distributing messages, this deployment up consumer backlog of messages, consumption not time-consuming process, even directly written to a temporary polling built in 10 the number of queue inside.
message ④ 10 times immediately requisitioned to deploy consumer machine, each batch of consumer consumption of a temporary queue.
⑤ this practice is quite the temporary queue resources and consumer resources to expand 10 times to 10 times the normal speed to consume news.
after ⑥ and other fast-moving consumer finished, restore the original deployment architecture, re-using the original consumer machine to consume news.
Here Insert Picture Description

2. The message set an expiration time, expired on lost how to do

Suppose you are using a rabbitmq, rabbitmq can set the expiration time, that is, TTL, if the message backlog in the queue for more than a certain period of time will be rabbitmq to clean up, the data is gone. Well, this is the second pit. This is not to say that the data will be a substantial backlog in mq, but rather a large amount of data is not lost directly.
Solution:
In this case, no news is actually squeeze, but lost a lot of news. Therefore, the first increase in consumer certainly does not apply.
This situation can take the "bulk redirect" programs to be resolved.
In the low peak flow (such as late at night), write a program to manually query portion of the data is lost, and then re-send the message to mq inside, missing data re-make it up.

3. backlog of messages a long time without treatment, mq fit how to do

If you take the way of the message backlog in mq years, so if you did not get rid of a long time, this time resulting in mq almost filled, it supposed to? There are other ways to do this?
Solution:
This is no way, and certainly the first implementation of the program is too slow, this time had to use "Drop + Batch redirect" approach to solve.
First, write a temporary program, which is connected to the mq consumption data, after receiving messages directly discarded, quickly consumed the backlog of messages, MQ reduced pressure, and then take the second option, to manually re-query in the dead of night night this part of the guide data loss.

Published 32 original articles · won praise 5 · Views 8661

Guess you like

Origin blog.csdn.net/weixin_43679441/article/details/104669988