CN115150340B - Method and device for dynamically adjusting message queue weight - Google Patents
Method and device for dynamically adjusting message queue weight Download PDFInfo
- Publication number
- CN115150340B CN115150340B CN202210748405.8A CN202210748405A CN115150340B CN 115150340 B CN115150340 B CN 115150340B CN 202210748405 A CN202210748405 A CN 202210748405A CN 115150340 B CN115150340 B CN 115150340B
- Authority
- CN
- China
- Prior art keywords
- queue
- message
- weight
- adjustment
- message queue
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 54
- 238000012545 processing Methods 0.000 claims description 33
- 230000003247 decreasing effect Effects 0.000 claims description 21
- 230000003111 delayed effect Effects 0.000 claims 1
- 230000006854 communication Effects 0.000 abstract description 4
- 238000004891 communication Methods 0.000 abstract description 3
- 238000005516 engineering process Methods 0.000 abstract description 2
- 238000012544 monitoring process Methods 0.000 description 11
- 230000000903 blocking effect Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 8
- 230000009467 reduction Effects 0.000 description 6
- 238000004364 calculation method Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 230000006870 function Effects 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 241001522296 Erithacus rubecula Species 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000008713 feedback mechanism Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000007619 statistical method Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/50—Queue scheduling
- H04L47/62—Queue scheduling characterised by scheduling criteria
- H04L47/625—Queue scheduling characterised by scheduling criteria for service slots or service orders
- H04L47/6255—Queue scheduling characterised by scheduling criteria for service slots or service orders queue load conditions, e.g. longest queue first
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L49/00—Packet switching elements
- H04L49/90—Buffering arrangements
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Telephonic Communication Services (AREA)
Abstract
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for dynamically adjusting a message queue weight. Mainly comprises the following steps: when message backlog occurs in the message queues, acquiring a state feedback condition of each message queue in each adjustment period; updating the weight of each queue according to the priority of the message queue and the state feedback condition in at least one adjustment period, increasing the queue weight of the message queue with message backlog, and reducing the queue weight of the message queue without message backlog, wherein the queue weight is the number of messages processed at one time by each message queue. The invention can adjust the queue weight according to the real data of the state feedback condition, reduce the average time delay of the dispatch, improve the average throughput of all queues and effectively prevent the backlog of the queue information.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for dynamically adjusting a message queue weight.
Background
With the rapid development of communication networks, network architecture is evolving continuously, the diversity of end user services is increasing, and the requirement on the time delay of the network is also increasing. Therefore, efficient management and scheduling of network resources becomes an important support for improving network quality of service.
In the network communication process, in order to ensure the correct time sequence of message processing, the message to be processed needs to be added into a message queue of a network element for management. In the same network element, there may be multiple message queues due to differences in message types or traffic characteristics, etc. Because of the limited processing performance of each network element, only a limited number of messages can be processed at a time for each message queue. In general, the processing speed of the network element is balanced with the receiving speed of the message, so that the delay of message processing is kept within an acceptable range. However, in the case that a large number of messages are generated in burst traffic, a large number of messages to be processed may be added to some message queues in a short time, and if the messages are processed at a normal processing speed, the message waiting time in the rear part of the queue may be prolonged, and even a packet loss may occur due to the fact that the message queues are full and cannot receive new messages. On the other hand, there may be fewer idle messages to be processed in a certain message queue, resulting in resource waste.
According to research, when network congestion is caused by burst service, network congestion can be effectively relieved by adopting dynamic scheduling of queues, and partial resources for processing idle message queues are distributed to the message queues with congestion so as to fully utilize resources such as calculation power and cache of network elements. There are currently a variety of queue scheduling methods such as multi-priority round robin scheduling, weighted fair queue scheduling, weighted poll queue scheduling, etc. However, the scheduling method may have problems of complex scheduling, more resources consumption, and the like.
In view of this, how to overcome the defects existing in the prior art and solve the problems existing in the existing message queue dynamic scheduling method is a problem to be solved in the technical field.
Disclosure of Invention
Aiming at the defects or the improvement demands of the prior art, the invention solves the problem that the existing dynamic scheduling algorithm is complex in scheduling.
The embodiment of the invention adopts the following technical scheme:
in a first aspect, the present invention provides a method for dynamically adjusting a message queue weight, which specifically includes: when message backlog occurs in the message queues, acquiring a state feedback condition of each message queue in each adjustment period; updating the weight of each queue according to the priority of the message queue and the state feedback condition in at least one adjustment period, increasing the queue weight of the message queue with message backlog, and reducing the queue weight of the message queue without message backlog, wherein the queue weight is the number of messages processed at one time by each message queue.
Preferably, the obtaining the status feedback condition of each message queue in each adjustment period specifically includes: each state acquisition period polls each message queue to acquire corresponding state data of each message queue, wherein the duration of the state acquisition period is an integer multiple of the adjustment period; and counting the state data in the whole adjustment period, comparing the state data with the state data in the last state acquisition period, and calculating the state feedback conditions of all the message queues.
Preferably, the duration of the state acquisition period is an integer multiple of the adjustment period, and specifically includes: when the state feedback condition is the message backlog condition, the state acquisition period is consistent with the adjustment period duration; when the state feedback condition is average time delay or average throughput, each state acquisition period comprises at least two adjustment periods.
Preferably, the weights of the queues are updated according to the priority of the message queues and the state feedback condition in at least one adjustment period, and the specific is: the weight increasing amplitude of the high-priority message queue is larger than that of the low-priority message queue, and the weight decreasing amplitude of the high-priority message queue is smaller than that of the low-priority queue.
Preferably, when the status feedback condition is a message backlog condition, the updating the weight of each queue according to the priority of the message queue and the status feedback condition in at least one adjustment period specifically includes: polling the message backlog condition of each message queue, and adjusting the weight when the message backlog condition exists in any message queue; for a high priority queue, if the current message queue has message backlog, the queue weight is increased by a first adjustment value, and if the current message queue does not have message backlog, the queue weight is decreased by a second adjustment value; for the low-priority queue, if the current message queue has message backlog, the queue weight is increased by a second adjustment value, and if the current message queue does not have message backlog, the queue weight is decreased by the first adjustment value; wherein the first adjustment value is greater than the second adjustment value.
Preferably, when the status feedback condition is average, the step of delaying, wherein the step of updating the weight of each queue according to the priority of the message queue and the status feedback condition in at least one adjustment period specifically includes: polling the average time delay of each message queue, and carrying out weight adjustment when the average time delay in the current adjustment period of any message queue is larger than the average time delay in the state acquisition period; for the high priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a third adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a fourth adjustment value; for the low priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a fourth adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a third adjustment value; wherein the third adjustment value is greater than the fourth adjustment value.
Preferably, when the status feedback condition is average throughput, the updating the weight of each queue according to the priority of the message queue and the status feedback condition in at least one adjustment period specifically includes: polling the average throughput of each message queue, and performing weight adjustment when the average throughput of any message queue in the current adjustment period is greater than the average throughput of the state acquisition period; for the high priority queue, if the average throughput of the current message queue is smaller than the average throughput of the adjustment period, the queue weight is increased by a fifth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the sixth adjustment value; for the low-priority queue, if the average throughput of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a sixth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the fifth adjustment value; wherein the fifth adjustment value is greater than the sixth adjustment value.
Preferably, in the priority of the message queue, the specific is: the first and second adjustment values, the third and fourth adjustment values, and the fifth and sixth adjustment values are calculated according to the proportion of backlog messages in the message queue and the priority of the message queue, respectively.
Preferably, the priority of the message queue is determined according to the service importance degree and/or the processing duration of the processing message.
In another aspect, the present invention provides a device for dynamically adjusting a weight of a message queue, specifically: the method comprises the steps of connecting at least one processor with a memory through a data bus, wherein the memory stores instructions executed by the at least one processor, and the instructions are used for completing the method for dynamically adjusting the weight of a message queue in the first aspect after being executed by the processor.
Compared with the prior art, the embodiment of the invention has the beneficial effects that: the current state of the message queue is dynamically obtained as a state feedback condition, the weight of the queue is adjusted according to the implementation real data of the state feedback condition, the average time delay of scheduling is reduced, the average throughput of all queues is improved, and the backlog of the queue messages is effectively prevented. Further, in a preferred embodiment of the present embodiment, the average state of a plurality of periods is used as a feedback condition, so that both the stability of the medium and long periods and the volatility of the short periods can be achieved during dynamic scheduling.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present invention, the drawings that are required to be used in the embodiments of the present invention will be briefly described below. It is evident that the drawings described below are only some embodiments of the present invention and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a flowchart of a method for dynamically adjusting message queue weights according to an embodiment of the present invention;
FIG. 2 is a flowchart of another method for dynamically adjusting message queue weights according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a message queue status in a specific scenario of a method for dynamically adjusting a message queue weight according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a message queue situation in a specific scenario of a method for dynamically adjusting a message queue weight according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a message queue status in a specific scenario of a method for dynamically adjusting a message queue weight according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of an apparatus for dynamically adjusting message queue weights according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of functional components in an apparatus for dynamically adjusting message queue weights according to an embodiment of the present invention;
FIG. 8 is a timing diagram illustrating the operation of functional components in an apparatus for dynamically adjusting message queue weights according to an embodiment of the present invention;
FIG. 9 is a timing diagram of the operation of functional components in an apparatus for dynamically adjusting message queue weights according to an embodiment of the present invention;
fig. 10 is a flowchart of functional components in an apparatus for dynamically adjusting message queue weights according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The present invention is an architecture of a specific functional system, so that in a specific embodiment, functional logic relationships of each structural module are mainly described, and specific software and hardware implementations are not limited.
In addition, the technical features of the embodiments of the present invention described below may be combined with each other as long as they do not collide with each other. The invention will be described in detail below with reference to the drawings and examples.
Example 1:
the embodiment provides a method for dynamically adjusting queue weight based on a condition feedback mechanism based on the purpose of effectively relieving network congestion caused by burst service, reducing network delay and improving average throughput of a network. The method combines the priority of the message queue and the feedback of the state of the network to adjust the weight of the queue, thereby achieving the aim of optimizing the network.
As shown in fig. 1, the method for dynamically adjusting the message queue weight provided by the embodiment of the invention specifically includes the following steps:
step 101: and when the message queues have message backlog, acquiring the state feedback condition of each message queue in each adjustment period.
The method provided by the embodiment aims to improve the overall processing efficiency of the message queues, and when all the message queues have no message backlog, the message queues do not need to be adjusted so as to reduce the resource consumption. When the message backlog occurs, the blocking state of each queue is obtained according to the state feedback condition of each message queue, and the resources of the idle queue are scheduled to the blocking queue, so that the overall processing efficiency and throughput are improved. In a specific implementation, the state feedback condition may be specifically determined according to network element processing characteristics, message queue characteristics, service characteristics, and the like, such as message backlog degree, processing delay, throughput, and expected time for completing message processing.
Step 102: updating the weight of each queue according to the priority of the message queue and the state feedback condition in at least one adjustment period, increasing the queue weight of the message queue with message backlog, and reducing the queue weight of the message queue without message backlog.
In this embodiment, the number of messages processed by each message queue at a time is referred to as a queue weight, and when scheduling the messages, the messages to be processed are obtained from the message queue according to the size of the queue weight, and the number of messages obtained each time is the size of the queue weight. The larger the queue weight of the message queue, the larger the number of messages processed each time, the higher the message processing efficiency, the lower the possibility of backlog, the lower the time delay and the larger the throughput. In contrast, the smaller the queue weight of the message queue, the smaller the number of messages processed at a time, the lower the message processing efficiency, the greater the likelihood of backlog, the longer the delay, and the smaller the throughput. Therefore, the processing efficiency of the message queue with the blocking condition can be improved by adjusting the queue weight so as to reduce the blocking. However, since each network element has limited processing resources and limited number of messages to be processed, in order to increase the queue weight for blocking, the weight of the unblocked queues needs to be correspondingly reduced so as to ensure that the resources consumed for processing all queue messages at a time are not additionally increased.
After steps 101-102 provided in this embodiment, reasonable allocation of limited resources can be achieved through simple weight adjustment, blocking of message queues is reduced, and overall processing efficiency of the system is improved.
In the method provided by the embodiment, whether adjustment is needed is determined according to the processing conditions of all message queues, and when any message queue is blocked due to message backlog, weight adjustment is dynamically performed in time so that the backlog queue is restored to a normal state as soon as possible. As shown in fig. 2, the following steps may be used to obtain the status feedback condition for each message queue in each adjustment period.
Step 201: and in each adjustment period, polling each message queue to acquire corresponding state data of each message queue.
In the method provided by the embodiment, in order to reduce the message backlog as far as possible, when any message queue is backlogged, weight adjustment is performed, so that the backlogged message queue can process more messages each time, and the backlogged message processing is completed as soon as possible. Therefore, all message queues need to be polled, state data of each message queue is acquired, and whether the message queues with message backlog exist or not is judged.
To ensure a relatively steady state for the medium and long periods, reducing data fluctuations caused by temporary traffic fluctuations, statistics over multiple adjustment periods may be used as state feedback conditions for certain non-instantaneous state feedback conditions, such as average delay or average throughput. Therefore, in the method provided in this embodiment, the lengths of the state acquisition period and the adjustment period are set respectively, and the weight adjustment is performed with the overall state of the plurality of adjustment periods as the adjustment basis. In a specific implementation, in order to avoid collision, the duration of the state acquisition period is an integer multiple of the adjustment period, and when the state acquisition period includes N adjustment periods, the state acquisition period starts simultaneously with the 1 st adjustment period and ends simultaneously with the nth adjustment period. In specific implementation, the time length of the state acquisition period and the adjustment period can be determined according to factors such as service characteristics, network load and the like, a shorter period can be set under the scene of larger service fluctuation or more idle network resources so as to facilitate timely adjustment, and a longer period can be set under the scene of smaller service fluctuation or more tense network resources so as to keep stable and reduce consumption.
Step 202: and counting the state data in the whole adjustment period, comparing the state data with the state data in the last adjustment period, and calculating the state feedback conditions of all the message queues.
Each state acquisition period comprises a plurality of adjustment periods, so that the states of all adjustment periods in the state acquisition period need to be comprehensively counted, and the overall state of the state acquisition period is used as the basis for weight adjustment. The specific statistical method is determined according to the state feedback condition, the judging requirement of the specific service and the like. For example, the state feedback condition is average time delay, the average time delay of all message queues is obtained in each adjustment period, and for the whole state obtaining period, the average time delay of all adjustment periods can be used as the state feedback condition.
After steps 201 to 202 provided in this embodiment, the status feedback condition of each message queue in one status acquisition period may be obtained, and in the subsequent steps, weight adjustment may be performed according to the status feedback condition.
The specific state feedback conditions can be determined according to the actual business characteristics and adjustment requirements. In this embodiment, specific embodiments based on three status feedback conditions are provided, which are feedback based on the message backlog condition, feedback based on the average delay, and feedback based on the average throughput, respectively. For other state feedback conditions, weight adjustment may be performed with reference to the specific implementation in this embodiment.
Further, due to factors such as importance of the service or processing time of the message, the urgent and importance of the message processing in different queues are different, and in order to distinguish when processing, the message queues may be set with priority, and the message queues with higher urgent and importance have higher priority. To ensure that important and urgent messages are handled in a timely manner, it is necessary to ensure that the weight of the high priority message queue is maintained at a high level. Therefore, when the weight adjustment is performed, the weight increasing amplitude of the high-priority message queue is larger than that of the low-priority message queue, and the weight decreasing amplitude of the high-priority message queue is smaller than that of the low-priority queue. The adjustment mode enables the high-priority message queue to obtain the highest possible processing efficiency when blocking occurs, and can keep enough processing efficiency when no blocking occurs. In implementations, the high and low priorities are service-specific, and can be categorized as "high" and "low" by service importance, or "high" and "low" by processing time.
In combination with the above-mentioned queue weight adjustment method, a queue weight adjustment method based on three state feedback conditions and a specific numerical calculation method for each weight adjustment are given below. In a specific implementation, the granularity of queue weight adjustment can be controlled by the data of two dimensions of the proportion of message backlog and queue priority.
(1) When the status feedback condition is a message backlog condition.
The state acquisition period is consistent with the adjustment period in time length, and the time length is T.
As shown in fig. 3, the message backlog condition of each message queue is polled, and weight adjustment is performed when the message backlog condition exists in any one of the message queues. When there is a message backlog in the queue for the T period, the weight of the queue needs to be increased. Conversely, if the queue does not have message backlog for the T period, the weight of the queue needs to be reduced.
For the high priority queue, if the current message queue has message backlog, the queue weight is increased by a first adjustment value, and if the current message queue has no message backlog, the queue weight is decreased by a second adjustment value.
The queue weights for the high priority queue reduction are: w2=w1+w1×m/(w1×n2).
The queue weight added by the high priority queue is as follows: w2=w1+w1×m/(w1×n3).
For the low-priority queue, if the current message queue has message backlog, the queue weight is increased by a second adjustment value, and if the current message queue does not have message backlog, the queue weight is decreased by the first adjustment value;
the queue weights for the low priority queue reduction are: w2=w1+w1×m/(w1×n1).
The queue weight added by the low priority queue is as follows: w2=w1+w1×m/(w1×n4).
Wherein m=s-W1, M is the number of blocked messages in the T period, S is the message queue size, W1 is the queue weight before update, W2 is the queue weight after update, T is the length of the state acquisition period and the adjustment period, and the queue weight is updated once per T period. The value of n is set according to the priority of the queue. N2 is larger and n3 is smaller at high priority; at low priority, n1 is smaller and n4 is larger. In a specific implementation scenario, n2 and n4 may be the same or different, and n1 and n3 may be the same or different. For example, n1=2, n2=4, n3=2, n4=4 may be set.
(2) When the state feedback condition is average delay or average throughput
Each state acquisition period comprises at least two adjustment periods, the duration of the state acquisition period is T1, the duration of the adjustment period is T2, and the duration of the T1 is an integer multiple of T2.
As shown in fig. 4, the average delay of each message queue is polled, and when the average delay in the current adjustment period of any message queue is greater than the average delay in the state acquisition period, weight adjustment is performed. When the average delay of the queue in the T2 period is greater than the average delay in the T1 period, the weight of the queue needs to be increased. Conversely, when the average delay in the period of the queue T2 is smaller than the average delay in the period of T1, the weight of the queue needs to be reduced.
For the high priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a third adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a fourth adjustment value.
The queue weights for the high priority queue reduction are: w2=w1+w1 (t 2-t 1)/(t 1 n 1).
The queue weight added by the high priority queue is as follows: w2=w1+w1 (t 2-t 1)/(t 1 n 2).
For the low priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a fourth adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a third adjustment value;
the queue weights for the low priority queue reduction are: w2=w1+w1 (t 2-t 1)/(t 1 n 3).
The queue weight added by the low priority queue is as follows: w2=w1+w1 (t 2-t 1)/(t 1 n 4).
Wherein m=s—w1, M is the number of blocked messages in the T period, S is the size of the message queue, W1 is the queue weight before update, W2 is the queue weight after update, T1 is the state acquisition period duration, T2 is the adjustment period duration, T1 is the average time delay in the T1 period, T2 is the average time delay in the T2 period, and the queue weight is updated once every T2 period is experienced. The value of n is set according to the priority of the queue. N2 is larger and n3 is smaller at high priority; at low priority, n1 is smaller and n4 is larger. In a specific implementation scenario, n2 and n4 may be the same or different, and n1 and n3 may be the same or different. For example, n1=2, n2=4, n3=2, n4=4 may be set.
(3) When the state feedback condition is average throughput
Each state acquisition period comprises at least two adjustment periods, the duration of the state acquisition period is T1, the duration of the adjustment period is T2, and the duration of the T1 is an integer multiple of T2.
As shown in fig. 5, the average throughput of each message queue is polled and weight adjustment is performed when the average throughput in any one of the message queue current adjustment periods is greater than the average throughput of the state acquisition period. When the average throughput of the queue in the T2 period is smaller than the average throughput in the T1 period, the weight of the queue needs to be increased. Conversely, when the average throughput in the period of the queue T2 is greater than the average throughput in the period of T1, the weight of the queue needs to be increased.
For the high priority queue, if the average throughput of the current message queue is smaller than the average throughput of the adjustment period, the queue weight is increased by a fifth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the sixth adjustment value.
The queue weights for the high priority queue reduction are: w2=w1+w1 (g1—g2)/(g1×n1).
The queue weight added by the high priority queue is as follows: w2=w1+w1 (g1—g2)/(g1×n2).
For the low-priority queue, if the average throughput of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a sixth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the fifth adjustment value;
the queue weights for the low priority queue reduction are: w2=w1+w1 (g1—g2)/(g1×n3).
The queue weight added by the low priority queue is as follows: w2=w1+w1 (g1—g2)/(g1×n4).
Wherein m=s—w1, M is the number of blocked messages in the T period, S is the message queue size, W1 is the queue weight before update, W2 is the queue weight after update, T1 is the state acquisition period duration, T2 is the adjustment period duration, g1 is the average throughput in the T1 period, and g2 is the average throughput in the T2 period. The queue weight is updated once every T2 period elapses. The value of n is set according to the priority of the queue. N2 is larger and n3 is smaller at high priority; at low priority, n1 is smaller and n4 is larger. In a specific implementation scenario, n2 and n4 may be the same or different, and n1 and n3 may be the same or different. For example, n1=2, n2=4, n3=2, n4=4 may be set.
In the above three adjustment processes, the first adjustment value, the second adjustment value, the third adjustment value, the fourth adjustment value, the fifth adjustment value or the sixth adjustment value is calculated according to the backlog proportion in the message queue and the priority of the message queue. N in the formula is used to control more and less granularity of adjustment, which can be determined by the particular service and level of priority. For example, the priority level is 5, n may be divided into corresponding 10 values, more 5 and less 5.
By using the method, the queue weight value which needs to be adjusted each time of each queue can be calculated, and the weight adjustment is completed according to the message backlog condition and the queue priority. The formula in the above embodiment is only one available general algorithm, and a specific calculation mode and values of each parameter are related to the service. In the implementation, all the letters in the above calculation formula can be the same value or different values, and the specific value depends on the specific requirement of the service and the specific condition of the network, and the optimal value can be obtained through actual test adjustment in the specific scene.
When the queue weight is dynamically adjusted, the increase and decrease of the weight may be out of range, resulting in excessive idle increase or excessive new congestion. In the method provided by the embodiment, when the weight is reduced, the queue with high original priority should be reduced less, and the queue with low priority should be reduced more, so that the factor for adjusting the weight of the queue is controlled by the data of two dimensions, namely the feedback of the condition and the priority of the queue, and inaccuracy controlled by a single dimension is avoided.
In a specific implementation, the above adjustment modes are used independently or in combination, and the adjustment mode of the message queue weight is determined according to one of the state feedback conditions, or the adjustment mode of the message queue weight can be determined jointly according to at least two state feedback conditions. When a plurality of state feedback conditions are used jointly, various state feedback conditions can be treated equally, and specific service requirements can be met. For example: three state feedback condition weights a, b, c, a+b+c=1, and the values of a, b, and c may be equal or different, respectively. When the queue weight needs to be adjusted, the final update weight may be (a is the update weight of the message backlog case+b is the update weight of the average delay+c is the update weight of the average throughput).
According to the method for dynamically adjusting the weight of the message queue, the weight adjustment mode is determined through the feedback of each queue and the feedback states of all queues, so that more and less queues with high priority are balanced in resource, more and less queues with low priority are balanced in resource, the processing efficiency of the queues with high priority is ensured, the task amount processed each time of each queue is adjusted through dynamically adjusting the queue weight of each queue, and the maximization of the processing efficiency of all queues under the condition of limited resource is achieved.
Example 2:
on the basis of the method for dynamically adjusting the message queue weight provided in the above embodiment 1, the present invention further provides a device for dynamically adjusting the message queue weight, as shown in fig. 6, which is a schematic device architecture diagram of an embodiment of the present invention.
The apparatus for dynamically adjusting message queue weight in this embodiment includes one or more processors 11 and a memory 12. In fig. 6, a processor 11 is taken as an example. The processor 11 and the memory 12 may be connected by a bus or otherwise, for example in fig. 6. The memory 12 is used as a nonvolatile computer readable storage medium for storing nonvolatile software programs, nonvolatile computer executable programs and modules, such as the executable programs of the dynamic message queue weight adjustment method in embodiment 1, message queues, status feedback condition values, related parameters of weight adjustment, and calculation intermediate values. The processor 11 executes various functional applications and data processing of the apparatus for dynamically adjusting the message queue weight, that is, implements the method for dynamically adjusting the message queue weight of embodiment 1, by running nonvolatile software programs, instructions, and modules stored in the memory 12. Memory 12 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 12 may optionally include memory located remotely from processor 11, which may be connected to processor 11 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The program instructions/modules are stored in the memory 12 and when executed by the one or more processors 11 perform the method of dynamically adjusting message queue weights of embodiment 1 described above, for example, performing the steps shown in fig. 1 described above. Those of ordinary skill in the art will appreciate that all or a portion of the steps in the various methods of the embodiments may be implemented by a program that instructs associated hardware, the program may be stored on a computer readable storage medium, the storage medium may include: read Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk.
As shown in fig. 7, in the present embodiment, when the method for dynamically adjusting the message queue weight provided in embodiment 1 is performed, the processor 11 may perform the corresponding functions through the following system modules.
The system is divided into a scheduler module, a monitoring thread, a message queue and a component. The monitoring thread is responsible for monitoring the state of the message queue and adjusting the queue weight of the queue according to the state feedback condition of the message queue acquired in the step 101. The message queues are divided into different queues according to different service types and have different priorities and queue weights. The scheduler performs adjustment of the queue weight in step 102 according to the weight of the message queue, and completes service scheduling. And finally, executing the tasks corresponding to the messages by the components. The scheduling mechanism can dynamically adjust the sequence of queue scheduling according to the service change of the current network, for example, when burst service causes certain queue backlog or certain high-priority queue backlog, the scheduler can increase the queue weight of the queue, so that the number of messages scheduled by the queue each time is increased.
The timing of the execution of tasks by the modules in the system is as follows.
(1) As shown in fig. 8, a queue-based message backlog scenario.
1. And initializing the monitoring thread.
2. The monitoring thread starts a timer, sets a T period timing task and is responsible for updating the queue weight.
3. The state feedback condition of the queue, here the message backlog condition of the queue, is obtained according to the method of step 101 every T time period, and the weight of the queue is updated according to the method of step 102 based on the queue backlog condition.
4. The scheduler processes the messages according to the queue weights, and the number of the messages processed at one time is the size of the queue weights.
5. The component performs the specific task of message processing.
(2) As shown in fig. 9, based on the average latency of the queue or the average throughput of the queue.
1. And initializing the monitoring thread.
2. The monitoring thread starts a timer, sets a T1 period and a T2 period to time tasks, wherein the T1 period is a state acquisition period and is responsible for counting the average time delay of the queue. The T2 period is an adjustment period and is responsible for updating the queue weight. The period T1 is an integer multiple of the period T2.
3. The average delay or average throughput condition of the queue is obtained per T1 time period according to the method of step 101.
4. The method according to step 102 updates the weights of the queues based on the average delay or average throughput condition of the queues every T2 time periods.
5. The scheduler processes the messages according to the queue weights, and the number of the messages processed at one time is the size of the queue weights.
6. The component performs the specific task of message processing.
After the corresponding modules execute the corresponding functions according to the above-mentioned time sequences, the weight adjustment of the message queue can be completed according to the method provided in embodiment 1.
The monitoring thread is responsible for monitoring the state condition of the queue, and adjusting the weight of the queue according to the state of the queue, and the working flow is as follows.
(1) As shown in fig. 10, based on a message backlog situation.
1. And initializing a thread.
2. A timer is started.
3. The queue status is queried.
4. The queue status is recorded.
5. The queue weights are updated.
6. The timer times out, starting to loop execution every T cycles by 3.
(2) Based on the queue average delay or the queue average throughput.
1. And initializing a thread.
2. A timer is started.
3. The queue status is queried.
4. The queue status is recorded.
5. The queue weights are updated.
6. The timer times out, the return 3 queries the queue state every T1 period, and the update 5 queue weight every T2 period.
Through the process, the monitoring thread periodically schedules the corresponding functional module to initiate the required execution action according to the timer, and the state inquiry and the weight update are completed.
As shown in fig. 10, a specific procedure for adjusting the queue weight according to the status feedback condition is as follows.
Step 301: the monitoring thread judges whether the condition of weight adjustment exists in all queues. If yes, go to step 302.
Step 302: and judging whether the current queue needs to be weighted. If yes, go to step 303; if not, go to step 306;
step 303: and judging whether the current queue is a high-priority queue or not. If yes, go to step 304; if not, go to step 305.
Step 304: less current queue weight is reduced.
Step 305: the current queue weight is reduced more.
Step 306: and judging whether the current queue is a high-priority queue or not. If yes, go to step 307; if not, go to step 308.
Step 307: the current queue weight is increased more.
Step 308: less increasing the current queue weight.
Step 309: it is determined whether all queues are processed. If not, the next queue is acquired, and step 302 is performed.
Through steps 301-309, the supervisory thread may schedule the corresponding functional module to complete the weight adjustment according to the acquired status.
The decision in step 301 and step 302 is set according to specific state feedback conditions. For example: when the status feedback condition is the message backlog condition, in step 301, the condition is determined whether any queue has the message backlog condition, and in step 302, the condition is determined whether the current queue has the message backlog condition. When the state feedback condition is average delay or average throughput, in step 301, the judgment condition is whether the average delay or average throughput of all queues is reduced, and the specific judgment criterion is that the average delay T2 of the short period T2 and the average delay T1 of the long period T1 are compared, that is, the average delay of the queues in a short time is smaller than the average delay in a long time, then the average delay of the queues is considered to be reduced, and in step 302, the judgment condition is whether the average delay or average throughput of the current queues is increased.
After each functional module of the device provided in this embodiment executes the corresponding function according to the above procedure, the weight of the queue may be dynamically adjusted according to the current status information and the priority of the queue, so as to complete the method for dynamically adjusting the weight of the message queue provided in embodiment 1.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, and alternatives falling within the spirit and principles of the invention.
Claims (7)
1. A method for dynamically adjusting message queue weights, comprising:
when the message queues have message backlog, acquiring a state feedback condition of each message queue in each adjustment period, wherein the state feedback condition comprises: one or more of feedback based on message backlog conditions, feedback based on average latency, and feedback based on average throughput; the obtaining the state feedback condition of each message queue in each adjustment period specifically includes: each state acquisition period polls each message queue to acquire corresponding state data of each message queue, wherein when the state feedback condition is a message backlog condition, the state acquisition period is consistent with the adjustment period duration; when the state feedback condition is average time delay or average throughput, each state acquisition period comprises at least two adjustment periods; counting the state data in the whole adjustment period, comparing the state data with the state data of the last state acquisition period, and calculating the state feedback conditions of all the message queues;
updating the weight of each queue according to the priority of the message queue and the state feedback condition in at least one adjustment period, increasing the queue weight of the message queue with message backlog, and reducing the queue weight of the message queue without message backlog, wherein the queue weight is the number of messages processed at one time by each message queue, the weight increasing amplitude of the high-priority message queue is larger than that of the low-priority message queue, and the weight decreasing amplitude of the high-priority message queue is smaller than that of the low-priority queue.
2. The method for dynamically adjusting weights of message queues according to claim 1, wherein when the status feedback condition is a message backlog condition, updating weights of each queue according to the priority of the message queue and the status feedback condition in at least one adjustment period specifically comprises:
polling the message backlog condition of each message queue, and adjusting the weight when the message backlog condition exists in any message queue;
for a high priority queue, if the current message queue has message backlog, the queue weight is increased by a first adjustment value, and if the current message queue does not have message backlog, the queue weight is decreased by a second adjustment value;
for the low-priority queue, if the current message queue has message backlog, the queue weight is increased by a second adjustment value, and if the current message queue does not have message backlog, the queue weight is decreased by the first adjustment value;
wherein the first adjustment value is greater than the second adjustment value.
3. The method for dynamically adjusting weights of message queues according to claim 1, wherein the updating weights of the queues according to the priority of the message queues and the status feedback condition in at least one adjustment period is delayed when the status feedback condition is average, specifically comprising:
polling the average time delay of each message queue, and carrying out weight adjustment when the average time delay in the current adjustment period of any message queue is larger than the average time delay in the state acquisition period;
for the high priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a third adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a fourth adjustment value;
for the low priority queue, if the average time delay of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a fourth adjustment value, and if the average time delay of the current message queue is larger than the average time delay of the adjustment period, the queue weight is decreased by a third adjustment value;
wherein the third adjustment value is greater than the fourth adjustment value.
4. The method for dynamically adjusting weights of message queues according to claim 1, wherein when the status feedback condition is an average throughput, the updating weights of the queues according to the priority of the message queues and the status feedback condition in at least one adjustment period specifically comprises:
polling the average throughput of each message queue, and performing weight adjustment when the average throughput of any message queue in the current adjustment period is greater than the average throughput of the state acquisition period;
for the high priority queue, if the average throughput of the current message queue is smaller than the average throughput of the adjustment period, the queue weight is increased by a fifth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the sixth adjustment value;
for the low-priority queue, if the average throughput of the current message queue is smaller than the average time delay of the adjustment period, the queue weight is increased by a sixth adjustment value, and if the average throughput of the current message queue is larger than the average throughput of the adjustment period, the queue weight is decreased by the fifth adjustment value;
wherein the fifth adjustment value is greater than the sixth adjustment value.
5. The method for dynamically adjusting message queue weights according to any one of claims 2-4, wherein in the priority of the message queues, the following is specified:
the first and second adjustment values, the third and fourth adjustment values, and the fifth and sixth adjustment values are calculated according to the proportion of backlog messages in the message queue and the priority of the message queue, respectively.
6. The method for dynamically adjusting message queue weights according to claim 1, wherein the method is specifically:
the priority of the message queue is determined according to the importance degree of the service and/or the processing duration of the processed message.
7. An apparatus for dynamically adjusting message queue weights, comprising:
comprising at least one processor and a memory connected by a data bus, the memory storing instructions for execution by the at least one processor, the instructions, when executed by the processor, for performing the method of dynamically adjusting message queue weights of any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210748405.8A CN115150340B (en) | 2022-06-29 | 2022-06-29 | Method and device for dynamically adjusting message queue weight |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210748405.8A CN115150340B (en) | 2022-06-29 | 2022-06-29 | Method and device for dynamically adjusting message queue weight |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115150340A CN115150340A (en) | 2022-10-04 |
CN115150340B true CN115150340B (en) | 2023-10-27 |
Family
ID=83410308
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210748405.8A Active CN115150340B (en) | 2022-06-29 | 2022-06-29 | Method and device for dynamically adjusting message queue weight |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115150340B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115550280B (en) * | 2022-11-24 | 2023-03-31 | 云账户技术(天津)有限公司 | Multi-level message queue implementation method, system, electronic device and readable storage medium |
CN116155817B (en) * | 2023-02-24 | 2024-09-24 | 云南电网有限责任公司电力科学研究院 | Data polling scheduling method, device, equipment and storage medium |
CN120075302B (en) * | 2025-04-28 | 2025-08-29 | 北京智游网安科技有限公司 | An event-driven service message processing and routing method, device, computer equipment and readable storage medium for improving system elasticity |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2010117358A1 (en) * | 2009-04-07 | 2010-10-14 | Cisco Technology, Inc. | Method and system to manage network traffic congestion |
CN107483363A (en) * | 2017-08-15 | 2017-12-15 | 无锡职业技术学院 | A hierarchical weighted round robin scheduling device and method |
CN107733689A (en) * | 2017-09-15 | 2018-02-23 | 西南电子技术研究所(中国电子科技集团公司第十研究所) | Dynamic weighting polling dispatching strategy process based on priority |
CN108259383A (en) * | 2016-12-29 | 2018-07-06 | 北京华为数字技术有限公司 | The transmission method and the network equipment of a kind of data |
WO2021114793A1 (en) * | 2019-12-09 | 2021-06-17 | 华为技术有限公司 | Data forwarding method, data buffering method, device, and related apparatus |
CN113259266A (en) * | 2021-05-28 | 2021-08-13 | 北京达佳互联信息技术有限公司 | Message pushing method and device of message queue, server and storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7761875B2 (en) * | 2005-06-10 | 2010-07-20 | Hewlett-Packard Development Company, L.P. | Weighted proportional-share scheduler that maintains fairness in allocating shares of a resource to competing consumers when weights assigned to the consumers change |
US9686204B2 (en) * | 2014-02-05 | 2017-06-20 | Verizon Patent And Licensing Inc. | Capacity management based on backlog information |
US9807015B2 (en) * | 2014-03-19 | 2017-10-31 | Dell Products L.P. | Message processing using dynamic load balancing queues in a messaging system |
-
2022
- 2022-06-29 CN CN202210748405.8A patent/CN115150340B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2010117358A1 (en) * | 2009-04-07 | 2010-10-14 | Cisco Technology, Inc. | Method and system to manage network traffic congestion |
CN108259383A (en) * | 2016-12-29 | 2018-07-06 | 北京华为数字技术有限公司 | The transmission method and the network equipment of a kind of data |
CN107483363A (en) * | 2017-08-15 | 2017-12-15 | 无锡职业技术学院 | A hierarchical weighted round robin scheduling device and method |
CN107733689A (en) * | 2017-09-15 | 2018-02-23 | 西南电子技术研究所(中国电子科技集团公司第十研究所) | Dynamic weighting polling dispatching strategy process based on priority |
WO2021114793A1 (en) * | 2019-12-09 | 2021-06-17 | 华为技术有限公司 | Data forwarding method, data buffering method, device, and related apparatus |
CN113259266A (en) * | 2021-05-28 | 2021-08-13 | 北京达佳互联信息技术有限公司 | Message pushing method and device of message queue, server and storage medium |
Non-Patent Citations (1)
Title |
---|
DiffServ中基于优先级的队列调度算法;李娟;周井泉;;计算机技术与发展(第07期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN115150340A (en) | 2022-10-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115150340B (en) | Method and device for dynamically adjusting message queue weight | |
Zhao et al. | A cooperative scheduling scheme of local cloud and internet cloud for delay-aware mobile cloud computing | |
CN107579926B (en) | QoS setting method of Ceph cloud storage system based on token bucket algorithm | |
Rajput et al. | A priority based round robin CPU scheduling algorithm for real time systems | |
CN110489217A (en) | A kind of method for scheduling task and system | |
US7536689B2 (en) | Method and system for optimizing thread scheduling using quality objectives | |
US8737227B2 (en) | Packet transmission device, memory control circuit, and packet transmission method | |
CN109039953B (en) | Bandwidth scheduling method and device | |
US20140281034A1 (en) | System and Method for Compressing Data Associated with a Buffer | |
CN111580949B (en) | Automatic regulating method for network packet receiving mode | |
US8018958B1 (en) | System and method for fair shared de-queue and drop arbitration in a buffer | |
CN116521234B (en) | Method and device for polling and scheduling processor pipeline instructions | |
CN113132265A (en) | Multi-stage scheduling method and device for multi-path Ethernet | |
CN119621274A (en) | A batch task optimization method based on dynamic priority scheduling | |
WO2025124248A1 (en) | Dynamic io scheduling method and system | |
CN111638986A (en) | QoS queue scheduling method, device, system and readable storage medium | |
CN118678306A (en) | Short message sending method, device, equipment, storage medium and program product | |
CN113055292A (en) | Method for improving forwarding performance of multi-core router and multi-core router | |
Pham et al. | Dilos: A dynamic integrated load manager and scheduler for continuous queries | |
CN115840632B (en) | Distributed scheduling management method and system based on time sequence database | |
WO2024131421A1 (en) | Adaptive dynamic traffic-limiting method and device for message middleware, and medium | |
US7231425B1 (en) | Rate-based scheduling method and system | |
CN116010085A (en) | Load balancing method, device, network equipment and storage medium | |
CN113225263B (en) | Flow request processing method and device and network chip | |
US6987774B1 (en) | Method and apparatus for traffic scheduling |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |