Heartbeat control method and device, storage medium, and electronic device
By dynamically adjusting the heartbeat interval length, combined with network congestion, request time and server load, it solves the problems of network congestion and resource consumption in existing technology center heartbeat control, reduces server pressure, and ensures message timeliness and resource efficiency.
Patent Information
- Application Number
- CN202210179059.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-02-25
AI Technical Summary
Existing heartbeat control methods may cause complete network congestion or high resource consumption when network congestion occurs, and cannot flexibly adjust the heartbeat cycle according to business scenarios, resulting in excessive server pressure or even paralysis.
By obtaining the current heartbeat round-trip time of the target service, calculate the degree of network congestion, and dynamically configure the heartbeat interval based on this degree. Combined with the request time factor, server load factor and scenario priority factor, the heartbeat frequency is adjusted in real time to adapt to the network status and avoid Heartbeat packets increase network congestion and reduce server pressure.
It realizes dynamic adjustment of heartbeat frequency to adapt to the current network status, avoids network congestion and server pressure, and ensures message timeliness and resource efficiency.
Smart Images

Figure CN114553778B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and more specifically, embodiments of the present invention relate to a heartbeat control method and device, a storage medium, and an electronic device. Background Art
[0002] This section is intended to provide a background or context to embodiments of the invention, and no description herein is admitted to be prior art by inclusion in this section.
[0003] In current technology, the heartbeat mechanism generally refers to a mechanism that sends a custom heartbeat packet at regular intervals to allow both communicating parties to confirm whether the other party is working properly to ensure the validity of the connection. Without the heartbeat mechanism, there will be failures such as dead links and inability to communicate instantly. For example, between the server and the client, the client can send heartbeat information to the server at regular intervals to allow the server to determine whether the client is currently online or has been disconnected. Summary of the invention
[0004] However, in some technologies, configuring a fixed heartbeat period may lead to complete network congestion in the case of network congestion; or, in some technologies, configuring multiple different heartbeat period schemes may result in high resource consumption and unreasonable heartbeat period selection.
[0005] Therefore, there is a great need for an improved heartbeat control method and device, storage medium and electronic device to provide a flexible and accurate heartbeat cycle control solution.
[0006] In this context, embodiments of the present invention are intended to provide a heartbeat control method and apparatus, a storage medium, and an electronic device.
[0007] According to one aspect of the present disclosure, there is provided a heartbeat control method, comprising: obtaining a current round trip time corresponding to a current heartbeat of a target service, and determining a current network congestion degree based on the current round trip time;
[0008] The update heartbeat interval duration of the target service is dynamically configured based on the current network congestion level.
[0009] In an exemplary embodiment of the present disclosure, determining the current network congestion level based on the current round trip time includes:
[0010] Determine a request time factor corresponding to the current heartbeat according to the current round trip time corresponding to the target service and the average round trip time; and
[0011] The current network congestion level is determined by combining the request time factor and the server load factor.
[0012] In an exemplary embodiment of the present disclosure, determining the current network congestion level based on the current round trip time includes:
[0013] Determine a request time factor corresponding to the current heartbeat according to the current round trip time corresponding to the target service and the average round trip time; and
[0014] Determine an application scenario type corresponding to the target service, and determine a scenario priority factor corresponding to the application scenario type;
[0015] The current network congestion level is determined by combining the request time factor, the server load factor, and the scenario priority factor.
[0016] In an exemplary embodiment of the present disclosure, the request time factor and the server load factor are respectively configured with a first weight coefficient and a second weight coefficient.
[0017] In an exemplary embodiment of the present disclosure, the dynamically configuring the update heartbeat interval of the target service based on the current network congestion level includes:
[0018] Compare the current network congestion level with the preset first interval duration and second interval duration respectively;
[0019] When the value of the current network congestion level is less than the first interval duration, configuring the value of the first interval duration as the update heartbeat interval duration of the target service; or,
[0020] When the value of the current network congestion level is greater than the second interval duration, configuring the value of the second interval duration as the update heartbeat interval duration of the target service; or
[0021] When the value of the current network congestion level is greater than or equal to the first interval duration and less than or equal to the second interval duration, the value of the current network congestion level is configured as the update heartbeat interval duration of the target service.
[0022] In an exemplary embodiment of the present disclosure, the method further includes:
[0023] Obtaining the request round trip time of each heartbeat of the target service within a preset statistical period;
[0024] When the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, triggering dynamic configuration of the target service heartbeat interval duration; or,
[0025] When the number of heartbeats whose request round-trip time is less than the average round-trip time is less than a second threshold, dynamic configuration of the target service heartbeat interval duration is triggered.
[0026] In an exemplary embodiment of the present disclosure, when determining the current network congestion level based on the current round trip time, the method further includes:
[0027] When the current network congestion level is greater than a third threshold, determining an associated service corresponding to the target service based on a preset rule;
[0028] The target service and the corresponding associated service are configured to merge the heartbeat packets.
[0029] In an exemplary embodiment of the present disclosure, determining the current network congestion level based on the current round trip time includes:
[0030] Determine a request time factor corresponding to the current heartbeat according to the current round trip time corresponding to the target service and the average round trip time; and
[0031] The request time factor is configured as the current network congestion level.
[0032] In an exemplary embodiment of the present disclosure, dynamically configuring the heartbeat interval of the target service based on the current network congestion level includes:
[0033] The update heartbeat interval duration of the target service is configured in inverse proportion to the request time factor.
[0034] According to one aspect of the present disclosure, there is provided a heartbeat control device, comprising: a current network congestion degree calculation module, configured to obtain a current round trip time corresponding to a current heartbeat of a target service, and determine a current network congestion degree based on the current round trip time;
[0035] A heartbeat interval duration updating module is used to dynamically configure the updated heartbeat interval duration of the target service based on the current network congestion level.
[0036] In an exemplary embodiment of the present disclosure, the current network congestion degree calculation module is used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and to determine the current network congestion degree in combination with the request time factor and the server load factor.
[0037] In an exemplary embodiment of the present disclosure, the current network congestion degree calculation module is used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and determine the application scenario type corresponding to the target service, and determine the scenario priority factor corresponding to the application scenario type; and determine the current network congestion degree in combination with the request time factor, the server load factor and the scenario priority factor.
[0038] In an exemplary embodiment of the present disclosure, the request time factor and the server load factor are respectively configured with a first weight coefficient and a second weight coefficient.
[0039] In an exemplary embodiment of the present disclosure, the heartbeat interval duration update module is used to compare the numerical value of the current network congestion level with the preset first interval duration and second interval duration values respectively; when the numerical value of the current network congestion level is less than the first interval duration, the numerical value of the first interval duration is configured as the updated heartbeat interval duration of the target service; or, when the numerical value of the current network congestion level is greater than the second interval duration, the numerical value of the second interval duration is configured as the updated heartbeat interval duration of the target service; or, when the numerical value of the current network congestion level is greater than or equal to the first interval duration, and less than or equal to the second interval duration, the numerical value of the current network congestion level is configured as the updated heartbeat interval duration of the target service.
[0040] In an exemplary embodiment of the present disclosure, the device further includes:
[0041] A heartbeat request round-trip time comparison module is used to obtain the request round-trip time of each heartbeat of the target service within a preset statistical period; when the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, trigger the dynamic configuration of the heartbeat interval duration of the target service; or, when the number of heartbeats whose request round-trip time is less than the average round-trip time is less than a second threshold, trigger the dynamic configuration of the heartbeat interval duration of the target service.
[0042] In an exemplary embodiment of the present disclosure, the device further includes:
[0043] The associated service processing module is used to determine the associated service corresponding to the target service based on a preset rule when the current network congestion level is greater than a third threshold; and configure a merged heartbeat packet for the target service and the corresponding associated service.
[0044] In an exemplary embodiment of the present disclosure, the current network congestion level calculation module is used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and configure the request time factor as the current network congestion level.
[0045] In an exemplary embodiment of the present disclosure, the heartbeat interval duration updating module is used to configure the updated heartbeat interval duration of the target service in inverse proportion to the request time factor.
[0046] According to one aspect of the present disclosure, a storage medium is provided, on which a computer program is stored, and the computer program performs the above-mentioned heartbeat control method when executed by a processor.
[0047] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0048] Processor; and
[0049] A memory, configured to store executable instructions of the processor;
[0050] The processor is configured to execute any one of the above-mentioned heartbeat control methods by executing the executable instructions.
[0051] According to the heartbeat control method implemented in the embodiment of the present invention, the current round-trip time corresponding to the current heartbeat of the target service is used to calculate the current network congestion level, and then the updated heartbeat interval of the target service is dynamically configured based on the current network congestion level. This can achieve real-time dynamic adjustment of the heartbeat cycle based on the network congestion level, so that the heartbeat frequency can meet the current network status and the heartbeat cycle can obtain a reasonable value; this avoids the problem of aggravating network congestion due to heartbeat packets and effectively reduces server pressure. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:
[0053] Figure 1 A flowchart of a heartbeat control method according to an embodiment of the present invention is schematically shown;
[0054] Figure 2 The flowchart of the method for dynamically configuring the trigger heartbeat interval duration according to an embodiment of the present invention is schematically shown;
[0055] Figure 3The flowchart of the method for configuring the current network congestion degree by using the request time factor according to the embodiment of the present invention is schematically shown;
[0056] Figure 4 A flowchart of a method for determining the current network congestion degree by combining a request time factor and a server load factor according to an embodiment of the present invention is schematically shown;
[0057] Figure 5 A flowchart of a method for calculating the current network congestion degree according to an embodiment of the present invention is schematically shown;
[0058] Figure 6 The flowchart of the method for determining the duration of the update heartbeat interval according to an embodiment of the present invention is schematically shown;
[0059] Figure 7 Schematically shows a block diagram of a heartbeat control device according to an embodiment of the present invention;
[0060] Figure 8 A schematic diagram showing a storage medium according to an embodiment of the present invention; and
[0061] Fig. 9 A block diagram of an electronic device according to an embodiment of the invention is schematically shown.
[0062] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION
[0063] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0064] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0065] According to an embodiment of the present invention, a message pushing method, a message pushing device, a storage medium and an electronic device are provided.
[0066] In this document, any number of elements in the drawings is used for illustration rather than limitation, and any naming is used only for distinction and does not have any limiting meaning.
[0067] The principle and spirit of the present invention are described in detail below with reference to several representative embodiments of the present invention. SUMMARY OF THE INVENTION
[0069] The inventors have found that in the prior art, in a heartbeat scheme, a fixed time detection is set, for example, detection is performed every 5 seconds. However, such a method will cause the sending of information to slow down in the case of network congestion, because the network congestion is serious and a large number of heartbeats need to be sent. Generally speaking, for a small-scale enterprise, an ordinary app has at least one million daily active users. If these one million connections send a heartbeat every 5 seconds, under large-scale congestion or weak network, the network will be completely congested or paralyzed, and the message cannot be sent at all. It may also cause huge pressure on the server; since the server needs to process the received heartbeat and the returned confirmation, large-scale heartbeat processing will seriously occupy the resources of the server, and in extreme cases, it will cause the server to be paralyzed. In another heartbeat scheme, multiple different heartbeat cycles can be preset, and then one is selected as the optimal heartbeat cycle; but such a method is not accurate enough and consumes a lot of resources. Moreover, it cannot be flexibly adjusted according to unused services. For example, in the application scenario of a gateway cluster, the gateway cluster maintains tens of millions of connections and is located in the same computer room. At this moment, the dedicated line traffic at the entrance of the computer room is already full, but millions of clients still need to send a large number of heartbeats, causing the TCP (Transmission Control Protocol) layer traffic to be more congested and unable to recover for a long time; each client will send a heartbeat at a fixed time. Once the heartbeat does not come back, it will cause disconnection and reconnection. In the middle, there will be a TLS (Transport Layer Security) encryption connection negotiation process. This process will greatly aggravate the exhaustion of the CPU resources of the already very heavily loaded server, and the entire gateway cluster will be temporarily unavailable, and the client will be unable to connect for a long time; for example, the application page is in a loading state for a long time (for example, it will display a spinning circle, waiting for prompt text, etc.).
[0070] In view of the above content, the basic idea of the present invention is: according to the heartbeat control method and the heartbeat control device of the implementation mode of the present invention, by obtaining the current network congestion level corresponding to the target service in real time, and then dynamically configuring the updated heartbeat interval duration corresponding to the target service in real time based on the current network congestion level, the heartbeat frequency adjustment for a single service is realized, and the heartbeat frequency can meet the current network status, so that the heartbeat cycle can obtain a reasonable value; the problem of aggravating network congestion due to heartbeat packets is avoided, and the server pressure is effectively reduced.
[0071] After introducing the basic principles of the present invention, various non-limiting embodiments of the present invention are described in detail below.
[0072] Exemplary Methods
[0073] Combine the following Figure 1 A heartbeat control method according to an exemplary embodiment of the present invention will be described.
[0074] refer to Figure 1 , the heartbeat control method may include the following steps:
[0075] S11, obtaining the current round trip time corresponding to the current heartbeat of the target service, and determining the current network congestion level based on the current round trip time;
[0076] S12. Dynamically configure the update heartbeat interval duration of the target service based on the current network congestion level.
[0077] In the heartbeat control method of the implementation mode of the present invention, the current network congestion level is calculated by utilizing the current round-trip time corresponding to the current heartbeat of the target service, and then the updated heartbeat interval of the target service is dynamically configured based on the current network congestion level. This enables real-time dynamic adjustment of the heartbeat cycle based on the network congestion level, so that the heartbeat frequency can meet the current network status and the heartbeat cycle can obtain a reasonable value; this avoids the problem of aggravating network congestion due to heartbeat packets and effectively reduces server pressure.
[0078] In an exemplary embodiment of the present disclosure, a trigger condition for dynamically configuring the heartbeat interval duration may be pre-configured. Figure 2 As shown, it may specifically include:
[0079] Step S21, obtaining the request round trip time of each heartbeat of the target service within a preset statistical period;
[0080] Step S22, when the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, triggering dynamic configuration of the target service heartbeat interval duration; or,
[0081] Step S23: When the number of heartbeats for which the request round-trip time is less than the average round-trip time is less than a second threshold, triggering dynamic configuration of the target service heartbeat interval duration.
[0082] In an exemplary embodiment of the present disclosure, the above method can be executed by a terminal device and / or a server. An application may contain multiple service contents, and different services are used to implement different functions. Taking a user terminal as an example, in a browser application, service contents such as text services and advertising services may be included. Among them, each service can send heartbeats to the server, maintain connection and interact with data. For each service, an initial or default heartbeat sending frequency can also be pre-configured.
[0083] In some exemplary embodiments, trigger conditions for dynamically configuring the heartbeat interval duration can be pre-configured on the terminal and / or server side. For example, a monitoring period for the heartbeat can be pre-configured to record the request round trip duration of each heartbeat within the heartbeat monitoring period; and based on the statistical results of the request round trip duration within the heartbeat monitoring period, it is determined whether the heartbeat interval duration needs to be reconfigured in the next monitoring period. For example, the duration of the monitoring period can be 30 seconds, 1 minute, 3 minutes, or 5 minutes, etc.; it can be specifically configured according to the type of service and the default heartbeat interval duration of the service.
[0084] Specifically, for the round trip time of the heartbeat request, in the gateway server with a long connection, the round trip of the request means that after the request is sent under the current protocol, the gateway immediately replies with a response, indicating that the current request packet has been received. An average round trip time can be calculated based on the historical data statistics of the long-term heartbeat round trip time of the target service. For different services in the application, the statistical average round trip time may be different. The request round trip time of each heartbeat recorded in the current statistical period is compared with the average round trip time. For example, the above-mentioned first threshold and second threshold can be calculated based on the duration of the statistical period and the average round trip time; or, they are reconfigured based on the calculation result. Alternatively, the first threshold and the second threshold can also be configured based on empirical values. For example, if the difference between the duration of the statistical period and the average round trip time is 10, the first threshold can be configured with a value such as 3, 4 or 5; the second threshold can be configured with a value such as 4, 5 or 6. When there are multiple heartbeats in the statistical period whose request round-trip time is greater than the average round-trip time, and the number is greater than the first threshold, it means that there is a certain degree of network congestion at present; if the request round-trip time of multiple consecutive heartbeats shows an increasing trend, it means that the degree of network congestion is gradually getting worse. At this time, the heartbeat interval can be reconfigured to increase the heartbeat interval to avoid worsening network congestion and further increase the pressure on the server. Alternatively, if there are multiple heartbeats in the statistical period whose request round-trip time is less than the average round-trip time, and the number is greater than the second threshold, it means that the current network status is good, and the heartbeat interval can be reconfigured according to the actual needs of the business. That is, when the network status deteriorates or improves, the dynamic configuration of the heartbeat interval can be triggered.
[0085] Alternatively, in some exemplary embodiments, corresponding monitoring may be performed for each heartbeat of the terminal or server, and whether the adjustment of the heartbeat interval duration is currently triggered is determined by comparing the request round-trip time of each heartbeat. For example, the request round-trip time of the current heartbeat is compared with the average round-trip time. If the current request round-trip time is greater than the average round-trip time, and the difference is greater than a preset value, the dynamic configuration of the target service heartbeat interval duration may be triggered. Alternatively, if the current request round-trip time is less than the average round-trip time, and the difference is greater than a preset value, the dynamic configuration of the target service heartbeat interval duration may also be triggered. Alternatively, the dynamic configuration of the target service heartbeat interval duration may be triggered when multiple consecutive heartbeats meet the above conditions.
[0086] For example, the target service can be any service on the terminal or server side. The round trip time of the request corresponding to the current heartbeat of the target service can be collected as the current round trip time. The round trip time of the heartbeat request can be the time between the moment when the application of the terminal sends a heartbeat packet to the server side and the moment when the fixed information replied by the server side is received.
[0087] In step S11, the current round trip time corresponding to the current heartbeat of the target service is obtained, and the current network congestion level is determined based on the current round trip time.
[0088] In an exemplary embodiment of the present disclosure, after determining that the dynamic configuration of the heartbeat interval duration is currently triggered by the method in the above embodiment, the current network congestion degree is calculated. Alternatively, in the absence of a triggering condition, the corresponding network congestion degree is calculated for each heartbeat.
[0089] In some exemplary embodiments, only the current round trip time may be used to represent the current network congestion level. That is, the network congestion level is proportional to the round trip time consumed by the heartbeat; if the round trip time of the heartbeat is longer, the current network congestion level is higher, and the value of the current network congestion level corresponding to the corresponding configuration is higher; similarly, if the round trip time of the heartbeat is shorter, the value of the current network congestion level corresponding to the configuration is lower.
[0090] Alternatively, in some exemplary embodiments, reference Figure 3 As shown, the determination of the current network congestion level based on the current round trip time in the above step S11 may specifically include:
[0091] Step S311, determining a request time factor corresponding to the current heartbeat according to the current round-trip time corresponding to the target service and the average round-trip time; and
[0092] Step S312: configuring the request time factor to be the current network congestion level.
[0093] Specifically, after obtaining the current round trip time of the current heartbeat, the request time factor can be calculated according to the current round trip time and the average round trip time of the target service, and the request time is thus configured as the current network congestion level. Specifically, calculating the request time factor may include:
[0094] t=(t0*Q) / (Q0*T)
[0095] Among them, t0 is the average round-trip time; Q0 is the average request size; Q is the current request size; T is the current request round-trip time.
[0096] For example, the value range of t is (0, 1). If it is calculated that t > 1, then take t = 1; otherwise, take the actual value of t, and it can be accurate to two decimal places. For example, the round-trip time of the current heartbeat is 50 ms, the average round-trip time is 10 ms, the current request size is 500 bytes, and the average request size is 200 bytes. The calculated request time is: t = (10 * 500) / 200 / 50, and it is calculated that t = 0.5. The larger t is, the better the current network condition is, and the request is returned on time; if t is smaller, it means that the current request takes more time and the network congestion is more serious.
[0097] Alternatively, in some exemplary embodiments, referring to Figure 4 As shown, determining the current network congestion degree based on the current round-trip time described in step S11 above may specifically include:
[0098] Step S41, determining a request time factor corresponding to the current heartbeat according to the current round-trip time corresponding to the target service and the average round-trip time; and
[0099] Step S42, combining the request time factor and the server load factor to determine the current network congestion degree.
[0100] Specifically, the above time factor and server load factor can be used to calculate the current network congestion degree. Among them, the server load factor can be used to characterize the current server load. The larger the load factor is, the busier the current server is; on the contrary, it means the server is idle. For example, the server load factor can be calculated through the occupancy ratios of four different sampling points: CPU, memory, network card, and disk; or, the highest value among the sampling points can also be selected as the server load factor. The value range of the server load factor can be 0 < f < 1. For example, if the CPU occupancy is 90% among the current four sampling points, which is the maximum value, then the server load factor is configured to 0.9. If the calculation of the current network congestion degree is performed on the terminal side, the server can send the server load factor in the heartbeat packet to the terminal.
[0101] In addition, a first weight coefficient and a second weight coefficient can be respectively configured for the request time factor and the server load factor.
[0102] The above calculation of the current network congestion degree using the time factor and the server load factor may include:
[0103] z = (1 - t) * a + f * b
[0104] Where a and b are weight coefficients respectively, t is the request time factor, and f is the server load factor.
[0105] Alternatively, in some exemplary embodiments, reference Figure 5 As shown, the determination of the current network congestion level based on the current round trip time in the above step S11 may specifically include:
[0106] Step S51, determining the application scenario type corresponding to the target service, and determining the scenario priority factor corresponding to the application scenario type;
[0107] Step S52, determining the current network congestion level in combination with the request time factor, the server load factor, and the scenario priority factor.
[0108] Specifically, when calculating the degree of network congestion, the priority of the current business can also be considered. For different types of business, the corresponding priority can be pre-configured according to the frequency of sending and receiving messages and the real-time requirements of the messages. For example, the stock market interface needs to be pushed frequently, so a higher heartbeat detection priority can be configured; the advertising interface does not need to be refreshed and pushed in time, so a low level of priority can be configured. For example, the value range of the heartbeat priority factor can be set to (1, 10); then the scenario priority factor of the above-mentioned advertising business can be configured to 1, 2 or 3 and other values; the scenario priority factor corresponding to the above-mentioned stock service can be 9.5 or 10 and other values.
[0109] The above-mentioned calculation of the current network congestion degree by combining the request time factor, the server load factor, and the scene priority factor may include:
[0110]
[0111] Where a and b are weight coefficients, t is the request time factor, f is the server load factor, p is the scenario priority factor, and l is the preset maximum heartbeat time interval of the target service. Where a+b=1, a and b are both greater than zero. For example, a=0.4 and b=0.6 can be configured.
[0112] In step S12, the update heartbeat interval duration of the target service is dynamically configured based on the current network congestion level.
[0113] In an exemplary embodiment of the present disclosure, after obtaining the current network congestion level, the heartbeat interval duration can be updated by adjusting the current default heartbeat interval duration according to a certain ratio according to a preset rule.
[0114] For example, when only the current round trip time is used to represent the current network congestion level, the update heartbeat interval duration can be configured in direct proportion according to a preset rule. That is, when the network congestion level increases, the update heartbeat interval duration is extended; or, when the network congestion level decreases, the heartbeat interval duration can be kept unchanged or shortened.
[0115] Alternatively, in some exemplary embodiments, in the above step S12, dynamically configuring the heartbeat interval of the target service based on the current network congestion level includes: configuring the update heartbeat interval duration of the target service in inverse proportion to the request time factor.
[0116] Specifically, when the request time factor is calculated based on the current round-trip time and the average round-trip time of the target service, and the request time is configured as the current network congestion level, the larger t is, the better the current network condition is, and the request is returned on time; if t is smaller, it means that the current request takes more time and the network congestion is more serious. Based on this, the request time factor can be used to configure the update heartbeat interval duration of the target service in inverse proportion. For example, when the calculated t is less than a preset value, the current congestion is serious. At this time, the update heartbeat interval duration can be extended according to a certain proportion according to the preset rules; or, when the calculated t is greater than another preset value, the current network condition is good. At this time, the update heartbeat interval duration can be shortened according to a certain proportion according to the preset rules.
[0117] Alternatively, in some exemplary embodiments, the longest heartbeat interval l and the minimum heartbeat interval s may be pre-configured for different target services. After obtaining the current network congestion level, it may be compared with the longest heartbeat interval l and the minimum heartbeat interval s, and the updated heartbeat interval duration may be determined based on the comparison result. Figure 6 As shown, the above step S12 may include:
[0118] Step S61, comparing the value of the current network congestion level with the preset first interval duration and second interval duration values respectively;
[0119] Step S62, when the value of the current network congestion level is less than the first interval duration, configuring the value of the first interval duration as the update heartbeat interval duration of the target service; or,
[0120] Step S63, when the value of the current network congestion level is greater than the second interval duration, configuring the value of the second interval duration as the update heartbeat interval duration of the target service; or
[0121] Step S64, when the value of the current network congestion level is greater than or equal to the first interval duration and less than or equal to the second interval duration, configure the value of the current network congestion level as the updated heartbeat interval duration of the target service.
[0122] Specifically, when calculating the current network congestion level z according to the above formula, compare z with s and l respectively. If z < s, then z = s, that is, when the current network congestion level z is less than the minimum heartbeat time interval s, configure the minimum heartbeat time interval s as the updated heartbeat interval duration. Or, if z > l, then z = l, that is, when the current network congestion level z is greater than the maximum heartbeat time interval l, configure the maximum heartbeat time interval l as the updated heartbeat interval duration. If s < z < l, then configure the value of z as the updated heartbeat interval duration. That is, s ≤ z ≤ l. In addition, the minimum heartbeat time interval and the maximum heartbeat time interval of the target service can be configured according to service attributes. For example, set values such as l = 20 and s = 5.
[0123] For example, if within a preset time period, such as 10 minutes, more than 90% of the request round-trip times are less than the average round-trip time, then heartbeat adjustment can be triggered to increase the heartbeat frequency to ensure the timeliness of detection. Or, if within 10 minutes, the heartbeat requests of a certain service of the current application exceed its average round-trip request time during this period and reach a threshold, such as 60% or 90%, then dynamic adjustment of the heartbeat interval duration can be triggered to reduce network pressure.
[0124] In addition, in some exemplary embodiments, the above method may further include:
[0125] Step S71, when the current network congestion level is greater than a third threshold, determine the associated service corresponding to the target service based on a preset rule;
[0126] Step S72, configure a combined heartbeat packet for the target service and the corresponding associated service.
[0127] Specifically, if the current network congestion level of the target service is calculated to be greater than a certain level, such as the third threshold mentioned above, at least one associated service that is associated with the target service can be merged, and multiple services can share one heartbeat packet. Among them, the third threshold mentioned above can be the longest heartbeat interval preset by the target service; or, the third threshold is a value such as 80% or 85%. Alternatively, after the current network congestion level is greater than the third threshold and continues for a certain period of time, the heartbeat packets of multiple associated services are merged. For example, the above-mentioned associated service can be the same server side as the target service, that is, the heartbeat packets of different services will be sent to the same destination; in addition, it can also be services with different functions within the same application. For example, if the heartbeat addresses of service A and service B are the same server port and the heartbeat packets are the same, the heartbeat packet merge method can be used.
[0128] Specifically, when the terminal or server determines that it is necessary to use the merged heartbeat packet, taking the server as an example, a notification message of the merged heartbeat packet can be first sent to the terminal, and the notification message can include the service identification of the merged heartbeat packet, the merging rule, the heartbeat packet content, the heartbeat packet sending interval and other configuration information. After receiving the notification message, the terminal can execute the corresponding configuration information and add the identification information of the merged heartbeat packet to the sent heartbeat packet for the server to identify. Alternatively, the terminal and the server can also pre-store a service association form that can merge the heartbeat packet; when the terminal or the server determines that it is necessary to merge the heartbeat packet, it can also directly send the merged heartbeat packet to the opposite end, and add the specified identification information in the merged heartbeat packet; after receiving the merged heartbeat packet, the opposite end determines the target service and the corresponding associated service of the merged heartbeat packet according to the specified identification information. If the received heartbeat packet does not contain the specified identification information, it is confirmed that the received heartbeat packet is not a merged heartbeat packet.
[0129] In addition, the server needs to support the ability to merge heartbeat packets, pre-configure the packet splitting strategy or apply the packet transfer strategy. If the server ports of service A and service B are the same, but the heartbeat packets are different, the server program needs to support the heartbeat conversion module from service A to service B, and convert the heartbeat packets received by service A into the heartbeat packets of service B. At this time, service A and service B only need one heartbeat packet to detect the connection status of the two services.
[0130] When merging heartbeat packets, the target service still executes the above method. When it is recognized that the network congestion level is reduced and the conditions for dynamically configuring the heartbeat duration update are met, the heartbeat packets can be canceled and sent to the server in a separate heartbeat packet.
[0131] In summary, the method provided by the present disclosure can determine the current congestion level of the network in real time based on the round-trip time of the heartbeat of the target service, and decide whether to adjust the heartbeat interval length based on the current congestion level, and how to adjust it specifically. When calculating the current network congestion level, the calculation is performed in combination with one or more of the request time factor, server load factor, and scenario priority factor, and the network status, server load capacity and other factors are fully considered. The dynamic adjustment of the heartbeat interval length can be achieved in both the network idle state and the network congestion state, and adjusted to a reasonable value.
[0132] In the case of network congestion, the heartbeat will be sent later, which effectively solves the problem of heartbeat packets aggravating network congestion and reduces the pressure on the server. When the network is idle, the connection status can be detected in time to ensure the timeliness of the message. It can increase the heartbeat detection frequency for businesses that require high heartbeat priority, that is, businesses with very high message timeliness, while delaying detection for applications that do not require high timeliness, such as text services. This can ensure timely detection of high-priority businesses to the greatest extent possible, while alleviating some network pressure and facilitating rapid network recovery without causing avalanche consequences. Moreover, businesses that require relatively low heartbeat frequencies will not waste a lot of client resources, server resources, and network resources.
[0133] Exemplary Devices
[0134] After introducing the heartbeat control method according to the exemplary embodiment of the present invention, Figure 7 A heartbeat control device according to an exemplary embodiment of the present invention is described.
[0135] refer to Figure 7 As shown, the heartbeat control device 70 of the exemplary embodiment of the present invention may include: a current network congestion degree calculation module 701, and a heartbeat interval duration update module 702; wherein:
[0136] The current network congestion degree calculation module 701 may be used to obtain a current round trip time corresponding to a current heartbeat of a target service, and determine a current network congestion degree based on the current round trip time.
[0137] The heartbeat interval duration updating module 702 may be used to dynamically configure the updated heartbeat interval duration of the target service based on the current network congestion level.
[0138] According to an exemplary embodiment of the present disclosure, the device also includes: the current network congestion level calculation module 701 is used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and determine the current network congestion level in combination with the request time factor and the server load factor.
[0139] According to an exemplary embodiment of the present disclosure, the current network congestion degree calculation module 701 is used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and determine the application scenario type corresponding to the target service, and determine the scenario priority factor corresponding to the application scenario type; and determine the current network congestion degree in combination with the request time factor, the server load factor and the scenario priority factor.
[0140] According to an exemplary embodiment of the present disclosure, the request time factor and the server load factor are respectively configured with a first weight coefficient and a second weight coefficient.
[0141] According to an exemplary embodiment of the present disclosure, the heartbeat interval duration update module 702 is used to compare the numerical value of the current network congestion level with the preset first interval duration and second interval duration values respectively; when the numerical value of the current network congestion level is less than the first interval duration, the numerical value of the first interval duration is configured as the updated heartbeat interval duration of the target service; or, when the numerical value of the current network congestion level is greater than the second interval duration, the numerical value of the second interval duration is configured as the updated heartbeat interval duration of the target service; or, when the numerical value of the current network congestion level is greater than or equal to the first interval duration, and less than or equal to the second interval duration, the numerical value of the current network congestion level is configured as the updated heartbeat interval duration of the target service.
[0142] According to an exemplary embodiment of the present disclosure, the device further includes: a heartbeat request round trip time comparison module.
[0143] The heartbeat request round-trip time comparison module can be used to obtain the request round-trip time of each heartbeat of the target service within a preset statistical period; when the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, the dynamic configuration of the heartbeat interval duration of the target service is triggered; or, when the number of heartbeats whose request round-trip time is less than the average round-trip time is less than a second threshold, the dynamic configuration of the heartbeat interval duration of the target service is triggered.
[0144] According to an exemplary embodiment of the present disclosure, the device further includes: an associated service processing module.
[0145] The associated service processing module can be used to determine the associated service corresponding to the target service based on a preset rule when the current network congestion level is greater than a third threshold; and configure a merged heartbeat packet for the target service and the corresponding associated service.
[0146] According to an exemplary embodiment of the present disclosure, the current network congestion level calculation module 701 can be used to determine the request time factor corresponding to the current heartbeat based on the current round-trip time corresponding to the target service and the average round-trip time; and configure the request time factor as the current network congestion level.
[0147] According to an exemplary embodiment of the present disclosure, the heartbeat interval duration updating module 702 may be configured to configure the updated heartbeat interval duration of the target service in inverse proportion to the request time factor.
[0148] Since the functional modules of the heartbeat control device in the embodiment of the present invention are the same as those in the embodiment of the heartbeat control method invention, they will not be described in detail here.
[0149] Exemplary Storage Media
[0150] After introducing the heartbeat control method and heartbeat control device according to the exemplary embodiment of the present invention, Figure 8 A storage medium according to an exemplary embodiment of the present invention is described.
[0151] refer to Figure 8 As shown, a program product 80 for implementing the above method according to an embodiment of the present invention is described. When a computer program corresponding to the program product is executed by a processor, the embodiments described in the above exemplary method can be implemented, as well as Figure 1-Figure 6 The heartbeat control method shown in . The program product 80 can be in the form of a portable compact disk read-only memory (CD-ROM) and includes program code, and can be run on a device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device.
[0152] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0153] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0154] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0155] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user computing device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0156] Exemplary Electronic Devices
[0157] After introducing the storage medium of the exemplary embodiment of the present invention, next, reference is made to Fig. 9 An electronic device according to an exemplary embodiment of the present invention is described.
[0158] Fig. 9The electronic device 800 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0159] like Fig. 9 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include, but are not limited to: the at least one processing unit 810, the at least one storage unit 820, a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810), and a display unit 840.
[0160] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 performs the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification. For example, the processing unit 810 can perform the following steps: Figure 1-Figure 6 Follow the steps shown in .
[0161] The storage unit 820 may include a volatile storage unit, such as a random access storage unit (RAM) 8201 and / or a cache storage unit 8202 , and may further include a read-only storage unit (ROM) 8203 .
[0162] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0163] The bus 830 may include a data bus, an address bus, and a control bus.
[0164] The electronic device 800 can also communicate with one or more external devices 900 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), and this communication can be performed through an input / output (I / O) interface 850. The electronic device 800 also includes a display unit 840, which is connected to the input / output (I / O) interface 850 for display. In addition, the electronic device 800 can also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs) and / or public networks, such as the Internet) through a network adapter 860. As shown in the figure, the network adapter 860 communicates with other modules of the electronic device 800 through a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0165] It should be noted that although several modules or submodules of the audio playback device and the audio sharing device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules for embodiment.
[0166] In addition, although the operations of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0167] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.
Claims
1. A heartbeat control method, It is characterized in that include: Obtaining a current round trip time corresponding to a current heartbeat of a target service, and determining a current network congestion level based on the current round trip time; Dynamically configure the update heartbeat interval of the target service based on the current network congestion level; Determining the current network congestion level based on the current round trip time includes: Determine the request time factor corresponding to the current heartbeat according to the current round-trip time, average round-trip time, current request size and average request size corresponding to the target service; configuring a first weight coefficient and a second weight coefficient for the request time factor and the server load factor; Determine an application scenario type corresponding to the target service, and determine a scenario priority factor corresponding to the application scenario type; The current network congestion level is determined by combining the request time factor, the server load factor, the first weight coefficient, the second weight coefficient, and the scenario priority factor; the formula for determining the current network congestion level is: z=((1-t)×a+f×b)×l / p; Among them, z is the current network congestion level, t is the request time factor, a is the first weight coefficient, f is the server load factor, b is the second weight coefficient, l is the longest heartbeat time interval preset for the target service, and p is the scenario priority factor.
2. The heartbeat control method according to claim 1, It is characterized in that The dynamically configuring the update heartbeat interval duration of the target service based on the current network congestion level includes: Compare the current network congestion level with the preset first interval duration and second interval duration respectively; When the value of the current network congestion level is less than the first interval duration, configuring the value of the first interval duration as the update heartbeat interval duration of the target service; or, When the value of the current network congestion level is greater than the second interval duration, configuring the value of the second interval duration as the update heartbeat interval duration of the target service; or When the value of the current network congestion level is greater than or equal to the first interval duration and less than or equal to the second interval duration, the value of the current network congestion level is configured as the update heartbeat interval duration of the target service.
3. The heartbeat control method according to claim 1, It is characterized in that The method further comprises: Obtaining the request round trip time of each heartbeat of the target service within a preset statistical period; When the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, triggering dynamic configuration of the target service heartbeat interval duration; or, When the number of heartbeats whose request round-trip time is less than the average round-trip time is less than a second threshold, dynamic configuration of the target service heartbeat interval duration is triggered.
4. The heartbeat control method according to claim 1 or 3, It is characterized in that When determining the current network congestion level based on the current round trip time, the method further includes: When the current network congestion level is greater than a third threshold, determining an associated service corresponding to the target service based on a preset rule; The target service and the corresponding associated service are configured to merge the heartbeat packets.
5. The heartbeat control method according to claim 1, It is characterized in that Determining the current network congestion level based on the current round trip time includes: Determine a request time factor corresponding to the current heartbeat according to the current round trip time corresponding to the target service and the average round trip time; and The request time factor is configured as the current network congestion level.
6. The heartbeat control method according to claim 5, It is characterized in that Dynamically configuring the heartbeat interval of the target service based on the current network congestion level includes: The update heartbeat interval duration of the target service is configured in inverse proportion to the request time factor.
7. A heartbeat control device, It is characterized in that include: A current network congestion degree calculation module is used to obtain a current round trip time corresponding to a current heartbeat of a target service, and determine a current network congestion degree based on the current round trip time; A heartbeat interval duration updating module, used to dynamically configure the updated heartbeat interval duration of the target service based on the current network congestion level; The determining of the current network congestion degree based on the current round-trip time includes: determining the request time factor corresponding to the current heartbeat according to the current round-trip time, average round-trip time, current request size and average request size corresponding to the target service; configuring a first weight coefficient and a second weight coefficient for the request time factor and a server load factor; determining the application scenario type corresponding to the target service, and determining the scenario priority factor corresponding to the application scenario type; combining the request time factor, the server load factor, the first weight coefficient, the second weight coefficient and the scenario priority factor to determine the current network congestion degree; the formula for determining the current network congestion degree is: z=((1-t)×a+f×b)×l / p; Among them, z is the current network congestion level, t is the request time factor, a is the first weight coefficient, f is the server load factor, b is the second weight coefficient, l is the longest heartbeat time interval preset for the target service, and p is the scenario priority factor.
8. The heartbeat control device according to claim 7, It is characterized in that The heartbeat interval duration updating module is used to compare the value of the current network congestion degree with the preset first interval duration and second interval duration values respectively; When the value of the current network congestion level is less than the first interval duration, the value of the first interval duration is configured as the update heartbeat interval duration of the target service; or, when the value of the current network congestion level is greater than the second interval duration, the value of the second interval duration is configured as the update heartbeat interval duration of the target service; Alternatively, when the value of the current network congestion level is greater than or equal to the first interval duration and less than or equal to the second interval duration, the value of the current network congestion level is configured as the update heartbeat interval duration of the target service.
9. The heartbeat control device according to claim 7, It is characterized in that The device also includes: A heartbeat request round-trip time comparison module is used to obtain the request round-trip time of each heartbeat of the target service within a preset statistical period; when the number of heartbeats whose request round-trip time is greater than the average round-trip time is greater than a first threshold, trigger the dynamic configuration of the heartbeat interval duration of the target service; or, when the number of heartbeats whose request round-trip time is less than the average round-trip time is less than a second threshold, trigger the dynamic configuration of the heartbeat interval duration of the target service.
10. The heartbeat control device according to claim 7 or 9, It is characterized in that The device also includes: The associated service processing module is used to determine the associated service corresponding to the target service based on a preset rule when the current network congestion level is greater than a third threshold; and configure a merged heartbeat packet for the target service and the corresponding associated service.
11. The heartbeat control device according to claim 7, It is characterized in that The current network congestion degree calculation module is used to determine the request time factor corresponding to the current heartbeat according to the current round-trip time corresponding to the target service and the average round-trip time; and configure the request time factor as the current network congestion degree.
12. The heartbeat control device according to claim 11, It is characterized in that The heartbeat interval duration updating module is used to configure the updated heartbeat interval duration of the target service in inverse proportion to the request time factor.
13. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the heartbeat control method according to any one of claims 1 to 6 is implemented.
14. An electronic device, It is characterized in that include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the heartbeat control method according to any one of claims 1 to 6 by executing the executable instructions.
Citation Information
Patent Citations
Network congestion information obtaining method and device
CN104780117A
Binary detection heartbeat interval system and method based on BP neural network prediction
CN112671633A
Multimedia data transmission control method and device, storage medium and electronic equipment
CN113271316A
