Elastic scaling control method and system for monitoring flow change based on message queue
By monitoring the traffic changes of the message queue, collecting and calculating relevant indicators for elastic scaling control, it solves the problem of difficult monitoring of CPU and memory usage in the existing technology, achieves high-accuracy and low-cost computing resource management, and is suitable for traffic A volatile scene.
Patent Information
- Application Number
- CN202410863294.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-29
- Publication Date
- 2024-09-17
AI Technical Summary
When the existing technology monitors the CPU and memory usage of computing devices to control elastic scaling, it is difficult to accurately perceive the traffic changes of the business system, resulting in high labor and time costs, and it is unable to effectively deal with the waste of computing resources during traffic peaks and troughs.
By monitoring the traffic changes of the message queue, we collect and calculate relevant indicators, such as message entry offset, consumption offset, message inflow speed and backlog, and combine the indicators at multiple consecutive time points to perform node elastic scaling control to achieve capacity expansion and Shrinkage judgment.
It improves the accuracy of expansion and contraction in traffic processing scenarios, reduces the waste of computing resources, simplifies calculation formulas, reduces labor and time costs, and improves computing resource utilization.
Smart Images

Figure CN118656270A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of big data automated operation and maintenance, and in particular to an elastic scaling control method and system based on message queue monitoring of traffic changes. Background Art
[0002] With the advent of the digital age, computer information has exploded exponentially, and the amount of information data will also experience peaks and troughs over time. In particular, when encountering unexpected social hot spots, the information flow will experience a sudden surge, which can easily lead to the collapse of big data computing or business systems and the inability to provide computing services to the outside world. In addition, the computing resources of the computer system that withstand the peak pressure are also a waste of computing resources in the subsequent long trough period. Therefore, in order to more effectively withstand the sudden increase in peak traffic pressure and to recycle excess computing resources during the trough, the method of controlling the elastic scaling of computing resources in real time according to traffic changes is very effective.
[0003] The current mainstream elastic scaling method mainly monitors the CPU and memory usage of computing devices to sense computing pressure and control the scaling of devices. Users need to discover the relationship between the CPU, memory usage, and traffic of the business system and summarize the calculation formula of the three. However, in most cases, the three are not linear relationships, which makes it extremely difficult to summarize the calculation formula. In addition, the rules of each computing software system do not have much commonality and cannot be copied and used. Therefore, the manpower and time costs of using CPU and memory usage to control elastic scaling are extremely high, and it needs to be improved. Summary of the invention
[0004] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0005] Therefore, in order to solve the above technical problems, the present invention provides the following technical solutions: an elastic scaling control method based on message queue monitoring of traffic changes, calculating collection indicators and extension indicators, calculating traffic speed and backlog related state indicators according to the collection indicators and extension indicators, and combining indicators at multiple consecutive time points to perform node elastic scaling control;
[0006] The specific steps are as follows:
[0007] The following are the specific steps for collecting indicators and calculating extended indicators:
[0008] 1. Collect the offset of messages that have entered each partition of the message queue (hereinafter referred to as message entry offset) and the consumer's consumption offset indicator (offset of consumed messages) at a certain interval (default 5 seconds);
[0009] 2. Obtain the offset of consecutive messages entering and consuming messages before the current time of the node. The difference between two consecutive message entry offsets divided by the time points of the two collections can be used to obtain the speed at which messages flow into the message queue.
[0010] 3. Similarly, the message consumption speed can also be calculated based on two consecutive consumption offsets;
[0011] 4. Subtract the message consumption offset from the message inflow offset at a certain point in time to get the message backlog at that point in time;
[0012] 5. De-duplicate statistics are performed based on the consumer ID in the offset of message consumption to obtain the current number of consumers;
[0013] 6. Divide the current consumption rate by the number of consumers to get the consumption rate of a single consumer.
[0014] The following are the specific steps for capacity expansion judgment and calculation:
[0015] 7. When the expansion judgment starts, check whether the number of consumers of the current consumer program is zero. If it is zero, check whether there is a backlog in the message queue. If there is a backlog, expand the consumer to 1;
[0016] 8. When determining whether to expand the capacity of a surviving node, collect and calculate the message inflow speed and message consumption speed of the node for multiple consecutive times with the same interval before the current time. When the message consumption speed is less than 80% of the message inflow speed and the message delay obtained by dividing the current backlog by the consumption speed is greater than the maximum allowable delay threshold, it can be determined that the node needs to be expanded;
[0017] 9. Add the current node backlog and the consumption interruption duration caused by the expansion, multiply by the message inflow speed, multiply by the redundancy coefficient (default 120%), and then divide by the single consumption speed to obtain the required number of consumers after expansion.
[0018] The following are the specific steps for judging and calculating the shrinkage:
[0019] 10. If the speed of multiple samples at a certain interval is less than 130% of the trough value, it is determined to be the trough period within the 24-hour cycle;
[0020] 11. Get the message inflow rate of the queue in the past certain days. If all are zero, the queue is judged to be temporarily idle and the number of consumers is reduced to 0;
[0021] 12. If the inflow rate in the past three days is not zero, and the peak value of the message inflow rate is less than 30% of the maximum consumption rate of the current message user, it is determined that the number of consumers can be reduced;
[0022] 13. Collect and store message queues, calculate message processing delays based on indicators at multiple consecutive time points, and determine whether the node needs to be expanded based on the delay; if the peak message inflow rate in the past 24 hours is less than 30% of the average consumer consumption rate, determine that the node needs to be reduced;
[0023] Specifically, multiply the 24-hour message inflow rate by the redundancy coefficient (the default is 120%) and divide it by the maximum consumption rate of a single consumer to obtain the number of consumers after scaling down.
[0024] The present invention also provides the above-mentioned elastic scaling control system based on message queue monitoring of traffic changes, which is characterized in that: the elastic scaling control system is used to implement the above-mentioned elastic scaling control method, and the elastic scaling control system includes a collection indicator and extended indicator calculation module, an expansion judgment and calculation module, and a reduction judgment and calculation module; the above-mentioned system adopts a traffic indicator voting mechanism for multiple consecutive message queues, and perceives the changing trend of message traffic by monitoring multiple consecutive indicator samples.
[0025] The present invention is developed for a big data real-time distributed computing system and is designed for scenarios with sudden traffic changes. The beneficial effects of the solution are:
[0026] 1. This solution targets traffic processing scenarios and has a high accuracy in scaling the number of consumers. It can more directly reflect the current state of the traffic by collecting indicators at each moment of the traffic itself, and can more directly reflect the change trend of the traffic itself by using historical data in a short period of time. It can predict the future size of the traffic through the state and change trend of the traffic itself, and then calculate the computing resources required for processing. The linear calculation of traffic and required computing resources has a simple relationship and high accuracy.
[0027] 2. The implementation method of this solution is easy and low-cost. Taking the maximum delay in processing traffic messages as the criterion, the required calculation method is obtained by a linear calculation method that calculates the processing traffic based on the traffic state and change trend, and the data delay does not exceed the maximum delay. The linear method is simple, and the maximum parameters can be obtained through a short period of parameter adjustment, and the required manpower and time costs are low.
[0028] 3. This solution has a high computing resource utilization rate; it accurately calculates the computing resources required for processing expansion and reduction, reduces equipment redundancy, and reduces the waste of computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0030] Figure 1 This is a flow chart of the speed at which messages flow into a message queue according to the present invention.
[0031] Figure 2 This is a flow chart of the message consumption speed of the present invention.
[0032] Figure 3 A flow chart showing the number of consumers of the present invention.
[0033] Figure 4 It is a flow chart of the consumption speed of a single consumer of the present invention.
[0034] Figure 5 A flow chart of the backlog of the present invention.
[0035] Figure 6 This is a flow chart of the capacity expansion judgment of the present invention.
[0036] Figure 7 It is a flow chart of the capacity reduction judgment of the present invention. DETAILED DESCRIPTION
[0037] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0038] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0039] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0040] Reference Figures 1 to 7 , is an embodiment of the present invention, and provides an elastic scaling control method based on message queue monitoring traffic changes, and the specific steps are as follows:
[0041] 1. If Figures 1 to 5As shown in the figure, the message offset and consumption offset of each partition of the Kafka message queue are collected, and combined with the offset collected last time, the message inflow speed, message consumption speed, backlog, etc. can be calculated, and the indicators are stored in the time series database Prometheus;
[0042] 2. In this implementation case, the interval for collecting indicators is set to once every 5 seconds, which can achieve a balance between accuracy and performance;
[0043] 3. If Figure 6 As shown in the figure, when making a capacity expansion judgment, the flow indicators and consumer program indicators of the message queue are obtained from Prometheus; when the message queue of computing resources has been completely recovered, the flow is restored by observing the message inflow offset. If the flow is restored, a consumer is pulled up to transmit the message; the indicators consumed by a consumer can be used to judge whether the subsequent capacity expansion is necessary;
[0044] 4. For the surviving consumer programs, obtain the consumption speed, message inflow speed, and Kafka backlog of the program and the Kafka message queue at the judgment time and six time points with an interval of 20 seconds before. If the Kafka backlog of the six collection points divided by the message delay of the consumption speed is greater than the maximum message delay of 180 seconds, and continues to increase, it is determined that capacity expansion is needed;
[0045] 5. Add the current backlog to the backlog after the expansion and multiply it by the redundancy factor of 120%, and then divide it by the consumption speed of a single consumer to get the number of consumers required after the expansion.
[0046] 6. If Figure 7 As shown, to determine whether the capacity is reduced, you need to check whether the message queues in the past three days have data. If the result is no data, it is determined that the traffic channel has been suspended and all computing resources are recovered.
[0047] 7. The surviving channels compare the 24-hour peak value with the maximum consumption speed of a single consumer obtained through the test. If the 24-hour peak value is less than 30% of the maximum consumption speed of a single consumer, it is determined that the resources are redundant and the capacity is reduced;
[0048] 8. To reduce capacity, multiply the peak value of the 24-hour message inflow rate by the redundancy factor (120%), and then divide it by the maximum consumption rate of a single consumer to obtain the number of consumers required for the consumption program.
[0049] The present invention proposes a method and system for monitoring the full-link traffic changes of a computer distributed computing system to control the elastic scaling of link computing nodes, thereby ensuring the elastic scaling of computing resources, enabling the system to handle traffic pressure exceeding expectations, timely recovering excess computing resources, improving computing resource utilization, and reducing the equipment cost of big data systems. The method can solve the current problem of the difficulty and high cost of controlling elastic scaling based on CPU and memory usage in distributed computing systems. Compared with the prior art, the algorithm of the present invention is simple, the implementation cost is low for computing scenarios with constantly changing traffic, and it can be quickly promoted.
[0050] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. An elastic scaling control method based on monitoring traffic changes in a message queue, characterized in that: Calculate the collection indicators and extension indicators, calculate the traffic speed and backlog related status indicators based on the collection indicators and extension indicators, and combine the indicators of multiple consecutive time points to perform node elastic scaling control; The specific steps are as follows: Step S1: Determine whether to expand capacity; divide the backlog amount by the consumption speed of the consumer program for multiple consecutive times. When the result is greater than the maximum message delay and continues to increase, the traffic delay is detected in time and it is determined that the node needs to be expanded; S2: computing resources required for computing expansion; Divide the existing backlog by the maximum allowed delay in seconds to get the backlog consumption speed and add the message inflow speed. Add a certain coefficient of redundancy and divide it by the consumer's consumption speed to get the number of consumers after expansion. S3: Determine whether to reduce capacity; sense the arrival of the trough period. When the 24-hour peak value of the trough period is less than 30% of the maximum consumption capacity of the consumer program, the computing capacity of the consumer program is redundant, and it is determined that the node needs to be reduced; S4: Calculate the computing resources required for scaling down; multiply the 24-hour traffic inflow peak by the redundancy factor, and divide it by the consumption speed of a single consumer program to obtain the number of consumers after scaling down.
2. The elastic scaling control method based on message queue monitoring traffic changes according to claim 1 is characterized in that: The specific steps for calculating the collection indicators and extended indicators are as follows: Collect the offset of messages that have entered each partition of the message queue and the consumer's consumption offset indicators at regular intervals; Get the offset of consecutive messages entering and consuming messages before the current time of the node. Divide the difference between two consecutive message entry offsets by the time points of the two collections to get the speed at which messages flow into the message queue. Similarly, the message consumption speed is calculated based on two consecutive consumption offsets; Subtract the message consumption offset from the message inflow offset at a certain point in time to obtain the message backlog at that point in time; De-duplicate statistics are performed based on the consumer ID in the offset of message consumption to obtain the current number of consumers; Divide the current consumption rate by the number of consumers to get the consumption rate of a single consumer.
3. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S1, the specific method for determining whether to expand capacity is: collecting and storing message queues, calculating message processing delays based on indicators at multiple consecutive time points, and determining whether the node needs to be expanded based on the size of the delay.
4. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S1, when the consumer program is closed, first check whether the message queue is restored; if restored, add consumers to the consumer program.
5. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S1, when the expansion judgment starts, it is obtained whether the number of consumers of the current consumer program is zero; when the number of consumers is zero, it is checked whether the message queue has a backlog; when the message queue has a backlog, the consumer is expanded to 1.
6. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S1, when judging whether the surviving node needs to be expanded, the message inflow speed and message consumption speed of the node with the same interval time for multiple consecutive times before the current time are collected and calculated; when the message consumption speed is less than 80% of the message inflow speed, and the message delay time obtained by dividing the current backlog by the consumption speed is greater than the maximum allowable delay threshold, it is judged that the node needs to be expanded.
7. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S3, when there is no data flowing into the message queue for a long time, the consumers of the consumer program are temporarily recovered, and high-frequency expansion judgment is added to monitor whether the traffic is restored and perceive the traffic in time; when the traffic arrives, the consumer program is restored in time.
8. The elastic scaling control method based on monitoring traffic changes by message queue according to claim 1, characterized in that: In step S3, if the speed of multiple samples at a certain interval are all less than 130% of the trough value, it is determined to be a trough period within a 24-hour cycle; the message inflow speed of the queue in the past certain days is obtained. If they are all zero, it is determined that the queue is temporarily idle and the number of consumers is reduced to zero; if the inflow speed in the past three days is not zero, and the peak value of the message inflow speed is less than 30% of the maximum consumption speed of the current message sender, it is determined that the number of consumers can be reduced.
9. The elastic scaling control system based on message queue monitoring traffic changes according to any one of claims 1 to 8, characterized in that: The elastic scaling control system is used to implement the elastic scaling control method. The elastic scaling control system includes a collection index and an extended index calculation module, an expansion judgment and calculation module, and a contraction judgment and calculation module.
10. The elastic scaling control system based on monitoring traffic changes by message queue according to claim 9, characterized in that: The above system adopts a traffic indicator voting mechanism for multiple consecutive message queues, and perceives the changing trend of message traffic by monitoring multiple consecutive indicator samples.
Citation Information
Cited By
Real-time monitoring method and system for satellite data processing software
CN122614669A
Real-time monitoring method and system for satellite data processing software
CN122614669B
