Message transmission method and device

文档序号:1864705 发布日期:2021-11-19 浏览:6次 中文

阅读说明:本技术 一种消息传输方法及装置 (Message transmission method and device ) 是由 不公告发明人 于 2021-09-03 设计创作,主要内容包括:本发明提供了一种消息传输方法及装置,该方法包括:计算上一个周期内的平均消息传输时延;根据多个平均消息传输时延计算当前周期消息队列的理想最大深度;根据所述平均消息传输时延以及所述理想最大深度对消息通道进行控制。本发明通过周期性采样消息传输时延,并以其为根据调整发送间隔及发送队列深度,仅控制发送端变可较好地控制消息通道拥塞,从而达到最大限度利用计算资源的目的。(The invention provides a message transmission method and a device, wherein the method comprises the following steps: calculating the average message transmission delay in the last period; calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays; and controlling a message channel according to the average message transmission delay and the ideal maximum depth. The invention can better control the congestion of the message channel only by controlling the change of the sending end by periodically sampling the message transmission delay and adjusting the sending interval and the sending queue depth according to the message transmission delay, thereby achieving the purpose of utilizing the computing resources to the maximum extent.)

1. A method for message transmission, comprising:

calculating the average message transmission delay in the last period;

calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays;

and controlling a message channel according to the average message transmission delay and the ideal maximum depth.

2. The message transmission method of claim 1, wherein calculating the average message transmission delay over the last cycle comprises:

calculating the message transmission time delay of the plurality of messages in the last period according to the processing performance parameters of the receiving and transmitting terminal machine, the network broadband and the receiving and transmitting terminal queue depth;

and calculating the average message transmission delay in the last period according to the message transmission delays of the plurality of messages.

3. The message transmission method according to claim 1, wherein the calculating the ideal maximum depth of the message queue in the current period according to the average message transmission delay comprises:

calculating the message concurrency number and the network transmission delay according to the average message transmission delay;

and calculating the ideal maximum depth according to the message concurrency number and the network transmission delay.

4. The method according to claim 1, wherein the controlling the message channel according to the average message transmission delay and the ideal maximum depth comprises:

comparing the average message transmission delay in the multiple periods with the sending interval time in the current period;

when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches the preset message sending interval time upper limit, comparing the message queue depth in the current period with the preset message queue maximum depth;

and when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

5. The message transmission method according to claim 4, wherein the comparing the average message transmission delay in the plurality of periods with the transmission interval time in the current period comprises:

and when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period does not reach the preset message sending interval time upper limit, increasing the sending interval time in the current period to the preset message sending interval time upper limit.

6. The message transmission method according to claim 4, wherein the comparing the average message transmission delay in the plurality of periods with the transmission interval time in the current period further comprises:

when the average message transmission delay in the multiple periods is not larger than the sending interval time in the current period, comparing the average message transmission delay in the current period with the average message transmission delay in the previous period;

the average message transmission delay in the current period is greater than the average message transmission delay in the last period, and the message sending interval time in the current period is increased to a preset message sending interval time upper limit;

and if the average message transmission delay in the current period is not greater than the average message transmission delay in the last period, reducing the message sending interval time in the current period to a preset message sending interval time lower limit.

7. Message transmission method according to one of the claims 4 to 6,

when the ideal maximum depth is larger than the preset maximum depth of the message queue in the current period, increasing the depth of the message queue in the current period to the preset maximum depth of the message queue;

and when the ideal maximum depth is not greater than the preset maximum depth of the message queue in the current period, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

8. A message transmission apparatus, comprising:

the average time delay calculation module is used for calculating the average message transmission time delay in the last period;

the ideal maximum depth calculation module is used for calculating the ideal maximum depth of the message queue in the current period according to the transmission delay of the average messages;

and the message channel control module is used for controlling a message channel according to the average message transmission delay and the ideal maximum depth.

9. The message transmission apparatus according to claim 8, wherein the average delay calculation module comprises:

a transmission delay calculating unit, configured to calculate message transmission delays of the multiple messages in the previous period according to the transceiver machine processing performance parameter, the network bandwidth, and the transceiver queue depth;

and the average time delay calculating unit is used for calculating the average message transmission time delay in the last period according to the message transmission time delays of the plurality of messages.

10. The message transmission apparatus according to claim 8, wherein the ideal maximum depth calculation module comprises:

the message concurrency number calculation unit is used for calculating the message concurrency number and the network transmission delay according to the average message transmission delay;

and the ideal maximum depth calculating unit is used for calculating the ideal maximum depth according to the message concurrency number and the network transmission delay.

11. The message transmission apparatus according to claim 8, wherein the message channel control module comprises:

a first comparing unit, configured to compare the average message transmission delay in the multiple periods with the sending interval time in the current period;

a second comparing unit, configured to compare the depth of the message queue in the current period with a preset maximum depth of the message queue when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches a preset upper limit of the message sending interval time;

a first maximum depth reducing unit, configured to reduce the preset maximum depth of the message queue to the depth value of the message queue in the current period when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue.

12. The message transmission apparatus according to claim 11, wherein the first comparing unit further comprises:

a first interval time increasing unit, configured to increase the transmission interval time in the current period to a preset message transmission interval time upper limit when the average message transmission delay in the multiple periods is greater than the transmission interval time in the current period and the transmission interval time in the current period does not reach the preset message transmission interval time upper limit.

13. The message transmission apparatus according to claim 11, wherein the first comparing unit further comprises:

a third comparing unit, configured to compare the average message transmission delay in the current period with the average message transmission delay in the previous period when the average message transmission delay in the multiple periods is not greater than the sending interval time in the current period;

a second time interval increasing unit, configured to increase the message sending interval time in the current period to a preset message sending interval time upper limit, where the average message transmission delay in the current period is greater than the average message transmission delay in the previous period;

and the time interval reducing unit is used for reducing the message sending time interval in the current period to a preset message sending time interval lower limit if the average message transmission delay in the current period is not more than the average message transmission delay in the last period.

14. The message transmission apparatus according to any one of claims 11 to 13, wherein the message channel control module further comprises:

a queue depth increasing unit, configured to increase the depth of the message queue in the current period to a preset maximum depth value of the message queue when the ideal maximum depth is greater than the preset maximum depth value of the message queue in the current period;

a second maximum depth reducing unit, configured to reduce the preset maximum depth of the message queue to the depth value of the message queue in the current period when the ideal maximum depth is not greater than the preset maximum depth of the message queue in the current period.

15. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the message transmission method according to any one of claims 1 to 7 are implemented when the program is executed by the processor.

16. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the message transmission method according to one of claims 1 to 7.

Technical Field

The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for transmitting a message.

Background

In the prior art, message middleware is a tool for asynchronous communication between systems, focuses on sending and receiving data, and integrates a distributed system by using an efficient and reliable asynchronous message transfer mechanism. The method is mainly used for solving the problems of application decoupling, asynchronous messages, flow peak clipping and the like.

It can be understood that, the message middleware performs message transmission through the message channel, and message identifiers in the intermediate state are all stored in the channel sending queue, but in practical applications, the receiving and sending end rates are often not matched due to network bandwidth or machine performance difference, and specifically: when the sending end speed is too high, messages can be accumulated in a sending queue, and congestion is caused; when the sending end is too slow, resources are wasted and rapid transmission cannot be achieved, so that congestion control needs to be performed on a channel of the sending end to match the processing rate of the receiving end and the sending end. The existing method for controlling queue congestion detection includes determining repeated ACK, detecting the number and change rate of messages in the queue, detecting the memory utilization rate and the like, considering that a channel is congested when an abnormal condition occurs, and performing corresponding abnormal processing.

In the above conventional message transmission method, a processing method for detecting the number of messages in the message queue and the change rate of the number of messages is generally used to compare with a preset message number threshold and a preset message rate threshold, and if the number of messages is higher or lower than the threshold, it is considered to be abnormal, and corresponding abnormal handling is performed. The message quantity and the change rate are relatively dependent on the actual message quantity in the current queue, the message quantity and the change rate have reference significance only when the message is stable to reach a certain magnitude, and the preset threshold value is not easy to artificially confirm in advance and cannot adapt to various complex network scenes.

The method of handling message channel congestion by detecting the memory usage of the consumer itself also has drawbacks: when the memory utilization rate reaches the set feedback triggering condition, the producer is informed to adjust the message sending window so as to achieve the effect of flow control. The influence factors of the memory utilization rate of the consumer are more, the situation that the receiving capacity is insufficient cannot be clearly reflected, the consumer actively informs the producer, the producer does not actively adjust, and certain time delay may exist to cause congestion.

In summary, there is a need in the art for a method that can adjust the sending interval and the sending queue depth of the message channel in real time to achieve better solution for message transmission.

Disclosure of Invention

According to the message transmission method and the device provided by the invention, by periodically sampling the message transmission delay and adjusting the sending interval and the sending queue depth, the message channel congestion can be well controlled only by controlling the sending end (without controlling the message receiving end), and the value is kept at a stable value under the current machine and bandwidth load, so that the computing resources are utilized to the maximum extent, and the resource utilization is low by the periodic sampling mode.

In order to achieve the above object, the present invention provides a message transmission method, including:

calculating the average message transmission delay in the last period;

calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays;

and controlling a message channel according to the average message transmission delay and the ideal maximum depth.

In one embodiment, calculating the average message transmission delay over the last cycle comprises:

calculating the message transmission time delay of the plurality of messages in the last period according to the processing performance parameters of the receiving and transmitting terminal machine, the network broadband and the receiving and transmitting terminal queue depth;

and calculating the average message transmission delay in the last period according to the message transmission delays of the plurality of messages.

In an embodiment, the calculating the ideal maximum depth of the message queue in the current period according to the average message transmission delay includes:

calculating the message concurrency number and the network transmission delay according to the average message transmission delay;

and calculating the ideal maximum depth according to the message concurrency number and the network transmission delay.

In an embodiment, the controlling a message channel according to the average message transmission delay and the ideal maximum depth includes:

comparing the average message transmission delay in the multiple periods with the sending interval time in the current period;

when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches the preset message sending interval time upper limit, comparing the message queue depth in the current period with the preset message queue maximum depth;

and when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

In an embodiment, the comparing the average message transmission delay in the multiple periods with the transmission interval time in the current period includes:

and when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period does not reach the preset message sending interval time upper limit, increasing the sending interval time in the current period to the preset message sending interval time upper limit.

In an embodiment, the comparing the average message transmission delay in the multiple periods with the transmission interval time in the current period further includes:

when the average message transmission delay in the multiple periods is not larger than the sending interval time in the current period, comparing the average message transmission delay in the current period with the average message transmission delay in the previous period;

the average message transmission delay in the current period is greater than the average message transmission delay in the last period, and the message sending interval time in the current period is increased to a preset message sending interval time upper limit;

and if the average message transmission delay in the current period is not greater than the average message transmission delay in the last period, reducing the message sending interval time in the current period to a preset message sending interval time lower limit.

In an embodiment, when the ideal maximum depth is greater than a preset maximum depth of a message queue in a current period, increasing the depth of the message queue in the current period to the preset maximum depth of the message queue;

and when the ideal maximum depth is not greater than the preset maximum depth of the message queue in the current period, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

In a second aspect, the present invention provides a message transmission apparatus, comprising:

the average time delay calculation module is used for calculating the average message transmission time delay in the last period;

the ideal maximum depth calculation module is used for calculating the ideal maximum depth of the message queue in the current period according to the transmission delay of the average messages;

and the message channel control module is used for controlling a message channel according to the average message transmission delay and the ideal maximum depth.

In one embodiment, the average delay calculating module includes:

a transmission delay calculating unit, configured to calculate message transmission delays of the multiple messages in the previous period according to the transceiver machine processing performance parameter, the network bandwidth, and the transceiver queue depth;

and the average time delay calculating unit is used for calculating the average message transmission time delay in the last period according to the message transmission time delays of the plurality of messages.

In one embodiment, the ideal maximum depth calculation module comprises:

the message concurrency number calculation unit is used for calculating the message concurrency number and the network transmission delay according to the average message transmission delay;

and the ideal maximum depth calculating unit is used for calculating the ideal maximum depth according to the message concurrency number and the network transmission delay.

In one embodiment, the message channel control module includes:

a first comparing unit, configured to compare the average message transmission delay in the multiple periods with the sending interval time in the current period;

a second comparing unit, configured to compare the depth of the message queue in the current period with a preset maximum depth of the message queue when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches a preset upper limit of the message sending interval time;

a first maximum depth reducing unit, configured to reduce the preset maximum depth of the message queue to the depth value of the message queue in the current period when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue.

In one embodiment, the first comparing unit further includes:

a first interval time increasing unit, configured to increase the transmission interval time in the current period to a preset message transmission interval time upper limit when the average message transmission delay in the multiple periods is greater than the transmission interval time in the current period and the transmission interval time in the current period does not reach the preset message transmission interval time upper limit.

In one embodiment, the first comparing unit further includes:

a third comparing unit, configured to compare the average message transmission delay in the current period with the average message transmission delay in the previous period when the average message transmission delay in the multiple periods is not greater than the sending interval time in the current period;

a second time interval increasing unit, configured to increase the message sending interval time in the current period to a preset message sending interval time upper limit, where the average message transmission delay in the current period is greater than the average message transmission delay in the previous period;

and the time interval reducing unit is used for reducing the message sending time interval in the current period to a preset message sending time interval lower limit if the average message transmission delay in the current period is not more than the average message transmission delay in the last period.

In one embodiment, the message channel control module further includes:

a queue depth increasing unit, configured to increase the depth of the message queue in the current period to a preset maximum depth value of the message queue when the ideal maximum depth is greater than the preset maximum depth value of the message queue in the current period;

a second maximum depth reducing unit, configured to reduce the preset maximum depth of the message queue to the depth value of the message queue in the current period when the ideal maximum depth is not greater than the preset maximum depth of the message queue in the current period.

In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the message transmission method when executing the program.

In a fourth aspect, the invention provides a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the message transmission method.

As can be seen from the above description, the message transmission method and apparatus provided in the embodiments of the present invention first calculate an average message transmission delay in a last cycle; then, calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays; and finally, controlling the message channel according to the average message transmission delay and the ideal maximum depth. By periodically sampling the message transmission delay and adjusting the sending interval and the sending queue depth according to the message transmission delay, the congestion of a message channel can be well controlled only by controlling a sending end (without controlling a message receiving end), the value is kept at a stable value under the current machine and bandwidth load, the computing resources are utilized to the maximum extent, and the resource utilization is low by the periodic sampling mode.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.

Fig. 1 is a schematic flowchart of a message transmission method provided in an embodiment of the present invention;

FIG. 2 is a flow chart illustrating step 100 according to an embodiment of the present invention;

FIG. 3 is a flowchart illustrating step 200 according to an embodiment of the present invention;

FIG. 4 is a first flowchart illustrating step 300 according to an embodiment of the present invention;

FIG. 5 is a flowchart illustrating step 301 according to an embodiment of the present invention;

FIG. 6 is a second flowchart illustrating step 300 according to an embodiment of the present invention;

fig. 7 is a flowchart illustrating a message transmission method according to an embodiment of the present invention;

FIG. 8 is a logic diagram of a message transmission method according to an embodiment of the present invention;

FIG. 9 is a flowchart illustrating step S2 according to an embodiment of the present invention;

FIG. 10 is a schematic flow chart of step a) in an embodiment of the present invention;

FIG. 11 is a schematic flow chart of step c) in an embodiment of the present invention;

FIG. 12 is a flowchart illustrating step S3 according to an embodiment of the present invention;

FIG. 13 is a schematic structural diagram of a pin message transmission apparatus according to an embodiment of the present invention;

fig. 14 is a schematic structural diagram of the average delay calculating module 10 according to an embodiment of the present invention;

FIG. 15 is a schematic structural diagram of an ideal maximum depth calculation module 20 according to an embodiment of the present invention;

FIG. 16 is a first diagram illustrating a structure of an ideal message channel control module 30 according to an embodiment of the present invention;

fig. 17 is a first schematic structural diagram of an ideal first comparing unit 301 according to an embodiment of the present invention;

fig. 18 is a first schematic structural diagram of an ideal first comparing unit 301 according to an embodiment of the present invention;

fig. 19 is a second schematic structural diagram of an ideal message channel control module 30 according to an embodiment of the present invention;

fig. 20 is a schematic structural diagram of an electronic device in an embodiment of the invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.

An embodiment of the present invention provides a specific implementation of a message transmission method, and referring to fig. 1, the method specifically includes the following steps:

step 100: the average message transmission delay over the last cycle is calculated.

Specifically, the average message transmission delay in the previous period is periodically and dynamically calculated, and it should be noted that "periodically", i.e. one calculation period and "in-period" in step 100, refer to a time interval. The message transmission process can be simplified into the processes of putting the message into a sending queue → transmitting the message in a network → a receiving end processing a sending receipt → transmitting the receipt in the network → a sending end confirming the receipt and deleting the local cache message, and the like, wherein the time difference between the starting time of putting the message into the sending queue and the ending time of confirming the receipt is the integral transmission delay of the message, and the average transmission delay of the messages within one period is obtained by averaging the transmission delays of the messages.

Step 200: and calculating the ideal maximum depth of the message queue in the current period according to the plurality of average message transmission delays.

It can be understood that the depth of the message sending queue determines the sending concurrency number, when the sending concurrency number is too high, accumulation can be caused to influence the processing speed of a sending end, and when the sending concurrency number is too low, idle can be caused; therefore, the ideal maximum depth of the sending queue is positively correlated with the network transmission delay (the whole transmission delay minus the processing time of the receiving end) and inversely correlated with the processing time after the receiving end receives the message, the processing time of the receiving end is carried to the message sending end through the receipt for reference, and then the maximum depth of the ideal queue can be obtained according to the relation and the lower limit of the constant depth (the lower limit of the constant depth is generally set according to the empirical value, the factors of the bandwidth of the actual using environment, the machine memory and the like can be comprehensively considered, when the bandwidth is higher and the machine memory is larger, the upper limit and the lower limit of the preset sending interval can be both adjusted lower, and the upper limit and the lower limit of the maximum depth of the sending queue can be both adjusted higher).

Step 300: and controlling a message channel according to the average message transmission delay and the ideal maximum depth.

Specifically, the average message transmission delay in the latest period is calculated by sampling, and with this as a reference, the message channel is controlled by adjusting the transmission interval and the maximum depth of the transmission queue according to the average message transmission delay.

As can be seen from the above description, in the message transmission method provided in the embodiment of the present invention, first, the average message transmission delay in the last period is calculated; then, calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays; and finally, controlling the message channel according to the average message transmission delay and the ideal maximum depth. By periodically sampling the message transmission delay and adjusting the sending interval and the sending queue depth according to the message transmission delay, the congestion of a message channel can be well controlled only by controlling a sending end (without controlling a message receiving end), the value is kept at a stable value under the current machine and bandwidth load, the computing resources are utilized to the maximum extent, and the resource utilization is low by the periodic sampling mode.

In one embodiment, referring to fig. 2, step 100 comprises:

step 101: calculating the message transmission time delay of the plurality of messages in the last period according to the processing performance parameters of the receiving and transmitting terminal machine, the network broadband and the receiving and transmitting terminal queue depth;

it can be understood that the single message transmission delay means that the whole process is influenced by the processing performance of the machine at the transceiving end, the network bandwidth, the queue depth of the transceiving end, and the like until the local end confirms that the opposite end receives the message from the local end.

Specifically, the transmission delay of each message is the time difference between the local terminal sending time and the local terminal receiving time for confirming the opposite terminal receiving time. Affected by factors such as processing performance, bandwidth, etc.

Step 102: and calculating the average message transmission delay in the last period according to the message transmission delays of the plurality of messages.

Preferably, the average message transmission delay is calculated by using the message transmission delays in a plurality of stable periods, where a stable period refers to a period (less than a preset threshold time) in which the variation amplitude of the average message transmission delay is small.

In one embodiment, referring to fig. 3, step 200 further comprises:

step 201: calculating the message concurrency number and the network transmission delay according to the average message transmission delay;

step 202: and calculating the ideal maximum depth according to the message concurrency number and the network transmission delay.

In one embodiment, referring to fig. 4, step 300 further comprises:

step 301: comparing the average message transmission delay in the multiple periods with the sending interval time in the current period;

step 302: when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches the preset message sending interval time upper limit, comparing the message queue depth in the current period with the preset message queue maximum depth;

step 303: and when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

In one embodiment, referring to fig. 5, step 301 further comprises:

step 3011: and when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period does not reach the preset message sending interval time upper limit, increasing the sending interval time in the current period to the preset message sending interval time upper limit.

It can be seen that steps 302 and 304 are two counter examples of the case that the sending interval time in the current period reaches and does not reach the preset upper limit of the message sending interval time on the premise that "when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period".

In one embodiment, referring to fig. 6, step 301 further comprises:

step 3012: when the average message transmission delay in the multiple periods is not larger than the sending interval time in the current period, comparing the average message transmission delay in the current period with the average message transmission delay in the previous period;

step 3013: the average message transmission delay in the current period is greater than the average message transmission delay in the last period, and the message sending interval time in the current period is increased to a preset message sending interval time upper limit;

step 3014: and if the average message transmission delay in the current period is not greater than the average message transmission delay in the last period, reducing the message sending interval time in the current period to a preset message sending interval time lower limit.

In one embodiment, based on the result of any of steps 3011-3014, there are:

when the ideal maximum depth is larger than the preset maximum depth of the message queue in the current period, increasing the depth of the message queue in the current period to the preset maximum depth of the message queue;

and when the ideal maximum depth is not greater than the preset maximum depth of the message queue in the current period, reducing the preset maximum depth of the message queue to the depth value of the message queue in the current period.

To further illustrate the present solution, the present application provides a specific application example of the message transmission method, see fig. 7 and fig. 8, and the specific application example specifically includes the following contents.

S1: periodically sampling and calculating the average message transmission delay of a channel in the latest fixed time period, simultaneously storing the average message transmission delay of the last period, and calculating the maximum depth (ideal maximum depth) of an ideal sending queue matched with the average message transmission delay in n stable periods (the change amplitude of the average message transmission delay is small);

s2: presetting upper and lower limit values of a message sending interval and upper and lower limit values of the maximum depth of a sending queue, and defaulting the current message sending interval and the maximum depth of the current sending queue to be the respective upper limit values, and comparing the average message transmission delay with the current message sending interval at the end of each period; specifically, referring to fig. 9, step S2 includes:

a) if the average message transmission delay is greater than the current message sending interval and the current message sending interval reaches the upper limit value of the message sending interval, the depth of the current sending queue and the maximum depth of the current sending queue need to be judged; referring to fig. 10, step a) includes:

i. if the depth of the current sending queue is less than or equal to the maximum depth of the sending queue, the maximum depth of the current sending queue is reduced proportionally to the lower limit value of the maximum depth of the sending queue or the depth of the current sending queue;

a case where the current transmit queue depth is not greater than the transmit queue maximum depth;

b) if the average message transmission delay is larger than the current message sending interval and the current message sending interval does not reach the upper limit value of the message sending interval, the current message sending interval is increased proportionally;

c) if the average message transmission delay is less than or equal to the current message sending interval, judging the current average message transmission delay and the average message transmission delay of the previous period; referring to fig. 11, step c) further comprises:

c 1: if the current average transmission delay is larger than the average message transmission delay of the previous period, the current message sending interval is increased in proportion until the current average transmission delay reaches an upper limit value;

c 2: if the current average transmission delay is less than or equal to the average message transmission delay of the previous period, reducing the current message sending interval in proportion until the current message sending interval reaches a lower limit value, and simultaneously entering the step S3 to adjust the maximum depth of a sending queue;

d) if the sampling messages in the previous period are not completely transmitted, increasing the current message sending interval in proportion;

e) if no message is transmitted in the previous period, the message sending interval is not adjusted;

s3: after each n stable periods are finished, comparing the maximum depth of the sending queue obtained by calculation with the maximum depth of the current sending queue;

referring to fig. 12, further, step S3 includes the following steps:

f) if the calculated maximum depth of the sending queue is larger than the maximum depth of the current sending queue, the maximum depth of the current sending queue is increased in proportion until the maximum depth reaches an upper limit value;

g) and if the calculated maximum depth of the sending queue is less than or equal to the maximum depth of the current sending queue, reducing the maximum depth of the current sending queue according to a proportion until the maximum depth reaches a lower limit value or the actual current depth of the current sending queue.

In the specific application example of the invention, a special time delay structure data structure is arranged for the channel in the message middleware, a certain number of message state time is stored, and after the message is finally sent, the transmission time delay of the message is calculated. And simultaneously setting data structures such as the maximum depth and the sending interval of the sending queue. Setting a special time delay check thread, calculating the average transmission time delay once every a period of time, and simultaneously storing historical n times of average transmission time delays to calculate and obtain the ideal maximum depth of the sending queue. After the time delay check thread completes the calculation in each period to obtain an effective average transmission time delay, the time delay check thread compares the effective average transmission time delay with the current sending interval, the queue depth and the historical transmission time delay according to the flow in the scheme, adjusts the sending interval and the current sending queue maximum depth in real time, and can realize congestion control at the sending end of the channel.

Based on the same inventive concept, the embodiments of the present application further provide a message transmission apparatus, which can be used to implement the methods described in the above embodiments, such as the following embodiments. Because the principle of the message transmission device for solving the problem is similar to the message transmission method, the message transmission device can be implemented by the message transmission method, and repeated details are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the embodiments below is preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.

An embodiment of the present invention provides a specific implementation of a message transmission apparatus capable of implementing a message transmission method, and referring to fig. 13, the message transmission apparatus specifically includes the following contents:

an average time delay calculation module 10, configured to calculate an average message transmission time delay in a last cycle;

an ideal maximum depth calculation module 20, configured to calculate an ideal maximum depth of the message queue in the current period according to multiple average message transmission delays;

and a message channel control module 30, configured to control a message channel according to the average message transmission delay and the ideal maximum depth.

In an embodiment, referring to fig. 14, the average delay calculating module 10 includes:

a transmission delay calculating unit 101, configured to calculate message transmission delays of the multiple messages in the previous period according to the transceiver machine processing performance parameter, the network bandwidth, and the transceiver queue depth;

an average delay calculating unit 102, configured to calculate an average message transmission delay in the previous period according to the message transmission delays of the multiple messages.

In one embodiment, referring to fig. 15, the ideal maximum depth calculation module 20 includes:

a message concurrency number calculating unit 201, configured to calculate a message concurrency number and a network transmission delay according to the average message transmission delay;

and an ideal maximum depth calculating unit 202, configured to calculate the ideal maximum depth according to the message concurrency number and the network transmission delay.

In one embodiment, referring to fig. 16, the message channel control module 30 includes:

a first comparing unit 301, configured to compare the average message transmission delay in the multiple periods with the sending interval time in the current period;

a second comparing unit 302, configured to compare the depth of the message queue in the current period with a preset maximum depth of the message queue when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period reaches a preset upper limit of the sending interval time of the message;

a first maximum depth decreasing unit 303, configured to decrease the preset maximum depth of the message queue to the depth value of the message queue in the current period when the depth of the message queue in the current period is not greater than the preset maximum depth of the message queue.

In one embodiment, referring to fig. 17, the first comparing unit 301 includes:

a first interval time increasing unit 3011, configured to increase the sending interval time in the current period to a preset message sending interval time upper limit when the average message transmission delay in the multiple periods is greater than the sending interval time in the current period and the sending interval time in the current period does not reach the preset message sending interval time upper limit.

In an embodiment, referring to fig. 18, the first comparing unit 301 further includes:

a third comparing unit 3012, configured to compare, when the average message transmission delay in the multiple periods is not greater than the sending interval time in the current period, the average message transmission delay in the current period with the average message transmission delay in the previous period;

a second time interval increasing unit 3013, configured to increase the message sending interval time in the current period to a preset message sending interval time upper limit, where the average message transmission delay in the current period is greater than the average message transmission delay in the previous period;

a time interval reducing unit 3014, configured to reduce the message sending interval time in the current period to a preset message sending interval time lower limit if the average message transmission delay in the current period is not greater than the average message transmission delay in the previous period.

In one embodiment, referring to fig. 19, the message channel control module 30 further includes:

a queue depth increasing unit 304, configured to increase the message queue depth in the current period to a preset message queue maximum depth value when the ideal maximum depth is greater than the preset message queue maximum depth in the current period;

a second maximum depth reducing unit 305, configured to reduce the preset message queue maximum depth to the message queue depth value in the current cycle when the ideal maximum depth is not greater than the preset message queue maximum depth in the current cycle.

As can be seen from the foregoing description, the message transmission apparatus provided in the embodiment of the present invention first calculates an average message transmission delay in a last period; then, calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays; and finally, controlling the message channel according to the average message transmission delay and the ideal maximum depth. The invention can better control the congestion of the message channel by only controlling the sending end (without controlling the message receiving end) by periodically sampling the message transmission delay and adjusting the sending interval and the sending queue depth according to the transmission delay, and keeps the value at a stable value under the current machine and bandwidth load, thereby utilizing the computing resources to the maximum extent, and the periodic sampling mode has lower utilization rate of the resources.

An embodiment of the present application further provides a specific implementation manner of an electronic device, which is capable of implementing all steps in the message transmission method in the foregoing embodiment, and referring to fig. 20, the electronic device specifically includes the following contents:

a processor (processor)1201, a memory (memory)1202, a communication Interface 1203, and a bus 1204;

the processor 1201, the memory 1202 and the communication interface 1203 complete communication with each other through the bus 1204; the communication interface 1203 is configured to implement information transmission between related devices, such as a server-side device, a power measurement device, and a client device.

The processor 1201 is configured to call the computer program in the memory 1202, and the processor executes the computer program to implement all the steps in the message transmission method in the above embodiments, for example, the processor executes the computer program to implement the following steps:

step 100: calculating the average message transmission delay in the last period;

step 200: calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays;

step 300: and controlling a message channel according to the average message transmission delay and the ideal maximum depth.

Embodiments of the present application further provide a computer-readable storage medium capable of implementing all steps in the message transmission method in the foregoing embodiments, where the computer-readable storage medium stores thereon a computer program, and the computer program, when executed by a processor, implements all steps of the message transmission method in the foregoing embodiments, for example, when the processor executes the computer program, the processor implements the following steps:

step 100: calculating the average message transmission delay in the last period;

step 200: calculating the ideal maximum depth of the message queue in the current period according to a plurality of average message transmission delays;

step 300: and controlling a message channel according to the average message transmission delay and the ideal maximum depth.

The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment.

The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.

Although the present application provides method steps as in an embodiment or a flowchart, more or fewer steps may be included based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or client product executes, it may execute sequentially or in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures.

The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

26页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:移动边缘计算场景下的资源分配方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!