Timeout setting method, device, equipment and storage medium
By dynamically adjusting the timeout period in the Raft consensus algorithm, the availability problem of Raft clusters in multi-regional network environments is solved, achieving higher availability and lower latency.
Patent Information
- Application Number
- CN202410445400.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-12
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-04-12
AI Technical Summary
In the Raft consensus algorithm, the uncertainty of networks in different regions (high latency, random jitter, etc.) leads to an increase in request failure rate and latency, which affects the availability of the distributed system and user experience.
By dynamically adjusting the heartbeat timeout, election timeout, and data transmission timeout, and using exponential growth or decline algorithms and average adjustments based on the signal success rate and data transmission success rate within the target statistical period, the timeout settings are optimized.
It reduces frequent elections and data retransmissions, lowers data request failure rates and latency, and improves the availability of Raft clusters under multi-regional unstable network conditions.
Smart Images

Figure CN118474049B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of server technology, and in particular to a method, apparatus, device, and storage medium for setting timeout. Background Technology
[0002] A distributed system is a system consisting of a group of computer nodes that communicate over a network and coordinate their work to accomplish a common task. To improve availability, distributed systems typically introduce replicas, which can prevent service interruptions when some nodes fail. However, this also creates the requirement to maintain data consistency, which necessitates the use of consistency algorithms.
[0003] Among consensus algorithms, the Raft consensus algorithm is widely used in distributed systems due to its good understandability and ease of engineering implementation. Raft is an asymmetric consensus algorithm for distributed systems, dividing node roles into leader, followers, and candidate leaders. The leader maintains connections with each replica by periodically broadcasting heartbeat messages. When it receives a data message submitted by a client, the leader broadcasts the received data message to other nodes. After receiving responses from more than half of the nodes, it returns a write success message to the writing client. Followers are responsible for receiving and responding to data messages forwarded by the leader. If more than a certain number of candidate leaders do not receive a heartbeat message within a defined timeout period, an election state is entered. The cluster cannot respond to client requests until a new leader is elected. Data messages are transmitted via network links, and nodes set a timeout for transmitted messages. If no response is received from the other end after the timeout expires, message transmission is re-initiated.
[0004] The current Raft consensus algorithm includes preset timeout parameters such as heartbeat timeout, election timeout, and transmission timeout, which remain fixed during system operation. This setup ensures relatively stable operation in single-region data center scenarios with relatively stable network environments. However, when different replicas of a Raft cluster are distributed across data centers in different regions, the significant uncertainties in the networks between regions (high latency, random jitter, etc.) can trigger availability issues such as increased request failure rates and latency. Specifically, due to the fixed heartbeat timeout setting, when the leader broadcasts heartbeat information to other nodes in different regions, the uncertainty of the network environment can cause nodes in some regions to fail to respond within the specified timeout period due to network jitter and increased latency. This prevents the leader from receiving a heartbeat response within the predetermined timeout period, leading to frequent election states. Furthermore, the varying performance of nodes within the cluster can also cause problems. Once the voting process begins, the uncertainty of network environments across regions leads to a fixed timeout setting that is lower than the actual network communication latency. This significantly reduces the success rate of processing voting information, thus prolonging the election process. Ultimately, the inability to elect a valid leader for an extended period results in continuous failures of data write requests from clients, drastically reducing availability and causing a poor user experience. Similarly, the uncertainty of network environments across regions and the fixed timeout setting cause timeouts when leaders broadcast data to certain regions, leading to retransmissions that time out. This results in a significant increase in write latency or even failures, and network resources are underutilized due to meaningless retries. Summary of the Invention
[0005] The purpose of this invention is to provide a timeout setting method, apparatus, device, and storage medium to solve availability problems such as increased request failure rate and increased latency caused by the significant uncertainties (high latency, random jitter, etc.) in existing timeout setting methods across different regions. The specific technical solution is as follows:
[0006] In a first aspect of the present invention, a method for setting a timeout period is provided, characterized in that the method includes:
[0007] The success rate of obtaining broadcast heartbeat signals within the target statistical period;
[0008] If the success rate of broadcasting heartbeat signals within the target statistical period is greater than a first preset value, the initial heartbeat timeout time set for heartbeat signals, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information are obtained within the target statistical period.
[0009] The target heartbeat timeout and target election timeout within the target statistical period are determined according to the initial heartbeat timeout.
[0010] If the difference between the success rate of the broadcast data transmission and the preset expected value is greater than the second preset value, the initial data transmission timeout time will be increased / decreased exponentially to generate the target data transmission timeout time.
[0011] If the difference between the success rate of the broadcast data transmission information and the preset expected value is less than the second preset value, the historical data transmission timeout time set in the previous cycle is obtained, and the average of the historical data transmission timeout time and the initial data transmission timeout time is used as the target data transmission timeout time.
[0012] Optionally, before obtaining the success rate of broadcast heartbeat signals within the target statistical period, the method further includes:
[0013] The leader node in a distributed system is determined using a target consensus algorithm.
[0014] Set a preset expected value for data transmission success rate and a first preset expected value for heartbeat signal broadcast success rate;
[0015] The time is divided into time windows of equal size, where each time window corresponds to a statistical period;
[0016] Select any statistical period as the target statistical period, and broadcast the heartbeat signal and data transmission information through the leader node;
[0017] Obtain at least one historical heartbeat timeout, historical election timeout, and historical data transmission timeout from the current leader node to other nodes;
[0018] Filter out the target historical heartbeat timeout, target historical election timeout, and target historical data transmission timeout from the historical heartbeat timeout, historical election timeout, and historical data transmission timeout that appear most frequently;
[0019] The target historical heartbeat timeout is set as the first heartbeat timeout, the target historical election timeout is set as the initial election timeout, and the target historical data transmission timeout is set as the initial data transmission timeout.
[0020] Optionally, before obtaining the initial heartbeat timeout time set for the heartbeat signal, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period, when the success rate of broadcasting the heartbeat signal within the target statistical period is determined to be greater than a first preset value, the following steps are included:
[0021] If the success rate of broadcasting heartbeat signals within the target statistical period is less than a first preset value and the difference between the success rate of broadcasting heartbeat signals within the target statistical period and the first preset expected value is greater than a third preset value, the first heartbeat timeout time will be increased exponentially to generate a second heartbeat timeout time.
[0022] If the success rate of broadcasting heartbeat signals within the target statistical period is less than a first preset value and the difference between the success rate of broadcasting heartbeat signals within the target statistical period and the first preset expected value is less than a third preset value, the third heartbeat timeout time set in the previous period is obtained, and the average of the third heartbeat timeout time and the first heartbeat timeout time is taken as the second heartbeat timeout time.
[0023] Optionally, after taking the average of the third heartbeat timeout time and the first heartbeat timeout time as the second heartbeat timeout time, the method further includes:
[0024] The success rate of the broadcast heartbeat signal update within the target statistical period is obtained according to the second heartbeat timeout time.
[0025] Set a first error value for the first preset expected value of the success rate of heartbeat signal broadcasting;
[0026] A first expected upper limit value for the success rate of heartbeat signal broadcasting is generated by using the first error value and the first preset expected value;
[0027] If the success rate of the broadcast heartbeat signal update is determined to be between the first preset expected value and the first expected upper limit value, then the second heartbeat is determined as the initial heartbeat timeout time set for the heartbeat signal within the target statistical period.
[0028] Optionally, the step of generating a target data transmission timeout by exponentially increasing / decreasing the initial data transmission timeout when the difference between the success rate of the broadcast data transmission information and the preset expected value is greater than a second preset value includes:
[0029] If the difference between the success rate of the broadcast data transmission information and the preset expected value is greater than the second preset value, the success rate of the broadcast data transmission information is compared with the preset expected value.
[0030] If the success rate of the broadcast data transmission is determined to be less than the preset expected value, twice the initial data transmission timeout time is determined as the target data transmission timeout time.
[0031] If the success rate of the broadcast data transmission is determined to be greater than the preset expected value, half of the initial data transmission timeout is determined as the target data transmission timeout.
[0032] Optionally, after determining that the difference between the success rate of the broadcast data transmission information and the preset expected value is less than a second preset value, obtaining the historical data transmission timeout time set in the previous period, and using the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time, the method further includes:
[0033] Success rate of obtaining broadcast data transmission information in the next cycle;
[0034] Set a second error value for the preset expected value of data transmission success rate;
[0035] A second expected upper limit value for data transmission success rate is generated by using the second error value and the preset expected value;
[0036] If the success rate of broadcast data transmission in the next cycle is determined to be between the preset expected value and the second expected upper limit value, then the data transmission timeout time set in the next cycle is determined as the optimal data transmission timeout time.
[0037] Optionally, before determining the target heartbeat timeout and target election timeout within the target statistical period according to the initial heartbeat timeout, the method further includes:
[0038] Obtain log data information within the target statistical period;
[0039] The successfully transmitted broadcast data information is determined by the log data information, and the response delay of the successfully transmitted broadcast data information is obtained.
[0040] The average response delay of broadcast data transmission information within the target statistical period is determined by the response delay.
[0041] In a second aspect of the invention, a timeout setting device is also provided, characterized in that it comprises:
[0042] The first acquisition module is used to acquire the success rate of broadcast heartbeat signals within the target statistical period;
[0043] The second acquisition module is used to acquire, when the success rate of broadcasting heartbeat signals within the target statistical period is greater than a first preset value, the initial heartbeat timeout time set for heartbeat signals, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period;
[0044] The first determining module is used to determine the target heartbeat timeout time and the target election timeout time within the target statistical period according to the initial heartbeat timeout time;
[0045] The first generation module is used to generate a target data transmission timeout by exponentially increasing / decreasing the initial data transmission timeout when the difference between the success rate of the broadcast data transmission information and the preset expected value is greater than a second preset value.
[0046] The third acquisition module is used to acquire the historical data transmission timeout time set in the previous cycle when the difference between the success rate of the broadcast data transmission information and the preset expected value is less than the second preset value, and to take the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time.
[0047] In a third aspect of the present invention, a communication device is also provided, comprising: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor;
[0048] The processor is used to read the program in the memory to execute any of the timeout setting methods described above.
[0049] In a fourth aspect of the invention, a computer-readable storage medium is also provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform any of the timeout setting methods described above.
[0050] The timeout setting method provided in this invention obtains the success rate of broadcast heartbeat signals within a target statistical period. When the success rate of broadcast heartbeat signals within the target statistical period is determined to be greater than a first preset value, the method obtains the initial heartbeat timeout set for the heartbeat signal, the initial data transmission timeout set for data transmission, and the success rate of broadcast data transmission within the target statistical period. By judging the success rate of the heartbeat signal, the method avoids the problem that a low success rate of the heartbeat signal leads to a low success rate of data transmission due to elections within the target statistical period, rendering the data transmission rate unreliable. The method determines the target heartbeat timeout and target election timeout within the target statistical period based on the initial heartbeat timeout. This setting avoids the problem of frequent entry into election states and excessively long election success times due to excessively short heartbeat and election timeouts, resulting in a poor user experience. Furthermore, when the difference between the success rate of broadcast data transmission and the preset expected value is determined to be greater than a second preset value... The initial data transmission timeout is increased / decreased exponentially to generate a target data transmission timeout. If the difference between the success rate of broadcast data transmission and the preset expected value is less than a second preset value, the historical data transmission timeout set in the previous cycle is obtained, and the average of the historical data transmission timeout and the initial data transmission timeout is used as the target data transmission timeout. When the difference from the preset expected value is large, an exponential timeout adjustment algorithm is used; when it is close to the preset expected value, a binary method is used for adjustment. This allows the corresponding adjustment to have rapid convergence capabilities, facilitating faster achievement of the user's desired effect. In this embodiment, through a rapidly converging dynamic adjustment algorithm, timeout parameters such as heartbeat timeout, election timeout, and transmission timeout are dynamically adjusted, reducing the problem of frequent elections and data retransmissions caused by unreasonable timeout value settings. This significantly reduces the data request failure rate and request latency, improving the availability of the Raft cluster under unstable network conditions in multiple regions. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0052] Figure 1 This is a schematic diagram of the state transition of the Raft state machine in a timeout setting method provided by an embodiment of the present invention;
[0053] Figure 2 A flowchart illustrating the steps of a timeout setting method provided in an embodiment of the present invention;
[0054] Figure 3 for Figure 2 The flowchart shown is a step 104 of a timeout setting method provided in an embodiment of the present invention;
[0055] Figure 4 A flowchart illustrating the steps of another timeout setting method provided in an embodiment of the present invention;
[0056] Figure 5 A flowchart illustrating the steps of another timeout setting method provided in an embodiment of the present invention;
[0057] Figure 6 This is a schematic diagram of the structure of a timeout setting device provided in an embodiment of the present invention;
[0058] Figure 7 This is a schematic diagram of the structure of a communication device provided in an embodiment of the present invention. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details are presented in the various embodiments of the present invention to facilitate a better understanding of this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for ease of description and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined with and referenced by each other without contradiction.
[0060] This invention addresses the low availability of data clusters based on the Raft distributed consensus algorithm by proposing a timeout setting method that can significantly improve cluster availability. The Raft distributed consensus algorithm is an asymmetric role consensus algorithm in distributed systems, dividing node roles into leaders, followers, and candidate leaders. A typical Raft state machine is as follows: Figure 1 As shown, node states switch between leader, follower, and alternate leader. In a Raft cluster, the leader node maintains connections with other nodes (follower nodes) by periodically broadcasting heartbeat messages. When it receives a message submitted by a client, the leader node broadcasts the received message to other nodes (follower nodes). After receiving responses from more than half of the nodes, it returns a write success message to the writing client. If the leader node crashes, it switches to the follower state. During Raft operation, if other nodes (follower nodes) do not receive a heartbeat message within the defined timeout period, they enter the election state and switch to the alternate leader node. When more than half of the nodes enter the election state, a new leader node needs to be re-elected. If an alternate leader node obtains more than half of the votes, it becomes the leader node. During this process, the cluster cannot respond to client requests. After the election, the alternate leader nodes that were not selected switch back to follower nodes.
[0061] In engineering practices related to the Raft algorithm, timeout parameters such as election timeout and transmission timeout are preset and remain unchanged during system operation. This leads to high write failure rates due to frequent re-elections caused by fixed timeout parameters and high write latency due to frequent data transmission timeouts when deploying Raft in multi-regional, uncertain network environments. Therefore, this invention proposes a method for dynamically adjusting the timeout time in the Raft algorithm, referring to... Figure 2 The diagram illustrates a flowchart of a timeout setting method provided by an embodiment of the present invention. The method may include:
[0062] Step 101: Obtain the success rate of broadcast heartbeat signals within the target statistical period.
[0063] The timeout parameters that need to be adjusted in this embodiment of the invention include heartbeat timeout, election timeout, and data transmission timeout. If the heartbeat signal is normal, no election will be conducted, and data transmission will not be affected. Therefore, it is necessary to first determine whether the success rate of the heartbeat signal is normal. Only if it is normal will subsequent data information be collected. If it is not normal, it is unnecessary to collect data, thereby reducing the calculation of meaningless data and saving resources.
[0064] It should be noted that to statistically analyze the success rate of broadcast heartbeat signals, it is necessary to first determine the leader node, broadcast heartbeat signals through the leader node, determine the statistical period, and set initial heartbeat timeout, initial election timeout, and initial data transmission timeout. This ensures that heartbeats not received from follower nodes after the initial heartbeat timeout are considered failed heartbeats. The specific setup process includes:
[0065] The leader node in a distributed system is determined using a target consensus algorithm.
[0066] Set a preset expected value for data transmission success rate and a first preset expected value for heartbeat signal broadcast success rate;
[0067] The time is divided into time windows of equal size, where each time window corresponds to a statistical period;
[0068] Select any statistical period as the target statistical period, and broadcast the heartbeat signal and data transmission information through the leader node;
[0069] Obtain at least one historical heartbeat timeout from the current leader node to other nodes, historical election timeout, and historical data transmission timeout;
[0070] Filter out the target historical heartbeat timeout, target historical election timeout, and target historical data transmission timeout from the historical heartbeat timeout, historical election timeout, and historical data transmission timeout;
[0071] Set the target historical heartbeat timeout to the first heartbeat timeout, set the target historical election timeout to the initial election timeout, and set the target historical data transmission timeout to the initial data transmission timeout.
[0072] The target consensus algorithm refers to the Raft algorithm, which divides time into windows of equal size. It is based on statistical information benchmarks from adjacent time periods. The target's historical heartbeat timeout can also be determined by combining statistical success rate. The specific implementation steps include:
[0073] Obtain historical heartbeat timeouts within a target time period, wherein the target time period includes at least one historical heartbeat timeout.
[0074] Select a number of first historical heartbeat timeout times with a success rate greater than a first preset value from the historical heartbeat timeout times;
[0075] Count the number of times different heartbeat timeout times occur in a number of the first historical heartbeat timeout times;
[0076] The first historical heartbeat timeout corresponding to the timeout that occurs most frequently is taken as the target historical heartbeat timeout.
[0077] By using both success rate and frequency of occurrence as criteria, the timeout for the acquired target historical heartbeat can be made as close as possible to the optimal setting, reducing the number of adjustments and improving service efficiency. Similarly, the timeout for target historical election and the timeout for target historical data transmission can be determined in the same way. It should be noted that information from adjacent historical periods is used as the main basis for adjustments in the current period. This mechanism is based on the fact that the network environment (such as latency) is basically the same over several consecutive time windows.
[0078] Furthermore, as mentioned above, it's necessary to first determine if the success rate of the heartbeat signal is normal. Only if it is normal will subsequent data be collected. If it's abnormal, data collection is unnecessary; instead, the heartbeat timeout period needs to be adjusted first. The specific process for judgment and adjustment is as follows:
[0079] If the success rate of broadcast heartbeat signal within the target statistical period is less than the first preset value and the difference between the success rate of broadcast heartbeat signal within the target statistical period and the first preset expected value is greater than the third preset value, the first heartbeat timeout time will be increased exponentially to generate the second heartbeat timeout time.
[0080] If the success rate of broadcast heartbeat signal within the target statistical period is less than the first preset value and the difference between the success rate of broadcast heartbeat signal within the target statistical period and the first preset expected value is less than the third preset value, the third heartbeat timeout time set in the previous period is obtained, and the average of the third heartbeat timeout time and the first heartbeat timeout time is taken as the second heartbeat timeout time.
[0081] For example, if the first preset value is set to 60%, and the statistical success rate of the broadcast heartbeat signal is 50%, since 50% < 60%, the success rate of the heartbeat signal is considered abnormal. A subsequent election process is needed, and data transmission is affected. Therefore, the success rate of data transmission at this point is not statistically analyzed. Instead, the first heartbeat timeout is adjusted to 4 seconds. A first preset expected value is set for the heartbeat signal, where the first preset expected value is higher than the first preset value, but the difference is not significant. Here, the first preset expected value can be set to 63%, and the third preset value to 10%. In this case, the difference between the success rate of the broadcast heartbeat signal and the first preset expected value is 63% - 5%. 0% = 13%, which is greater than 10%. Therefore, the first heartbeat timeout is increased exponentially, 4 × 2 = 8 seconds, resulting in a second heartbeat timeout of 8 seconds. If the statistical success rate of the broadcast heartbeat signal is 58%, since 58% < 60%, the success rate is considered abnormal, and an election process is needed. Data transmission is affected at this point, so the success rate of data transmission is not statistically analyzed. Instead, the first heartbeat timeout is adjusted to 4 seconds. Since 63% - 58% = 5%, which is less than 10%, the third heartbeat timeout set in the previous cycle is 6 seconds. Taking the average (4 + 6) / 2 = 5 seconds, the second heartbeat timeout is 5 seconds. It should be noted that the above values are not fixed and can be adjusted according to actual conditions. This invention does not impose specific limitations on these values.
[0082] By adjusting the heartbeat timeout, we can achieve rapid convergence to the optimal heartbeat timeout, while reducing the problem of frequent election entries caused by unreasonable timeout values.
[0083] Furthermore, after obtaining the second heartbeat timeout, the system will continue to determine whether the updated heartbeat timeout setting is appropriate. If it is not appropriate, adjustments will be made according to the above scheme until it is determined that the second heartbeat definitely meets the convergence condition. The optimal heartbeat timeout is then determined and set as the initial heartbeat timeout for the heartbeat signal within the target statistical period. The specific setting process includes:
[0084] The success rate of the broadcast heartbeat signal update within the target statistical period is obtained based on the second heartbeat timeout time.
[0085] Set a first error value for the first preset expected value of the success rate of heartbeat signal broadcasting;
[0086] A first expected upper limit value for the success rate of heartbeat signal broadcasting is generated by using a first error value and a first preset expected value.
[0087] If the success rate of the broadcast heartbeat signal update is determined to be between the first preset expected value and the first expected upper limit value, then the second heartbeat is determined as the initial heartbeat timeout time set for the heartbeat signal within the target statistical period.
[0088] The above-mentioned convergence criteria for the heartbeat timeout have been set. Once the convergence criteria are met, there is no need to adjust the heartbeat timeout. It can also ensure that the initial heartbeat timeout can maximize the protection of the heartbeat signal from transmission failure due to uncertainties in the network environment between regions, such as network jitter and latency increases between regions.
[0089] Step 102: If the success rate of broadcasting the heartbeat signal within the target statistical period is greater than the first preset value, obtain the initial heartbeat timeout time set for the heartbeat signal, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period.
[0090] In this embodiment of the invention, after determining that the success rate of broadcasting the heartbeat signal within the target statistical period is greater than the first preset value, it is assumed that there is no impact on data transmission failure due to entering the election state within the target statistical period, and then the success rate of broadcasting data transmission information is obtained.
[0091] Step 103: Determine the target heartbeat timeout and target election timeout within the target statistical period based on the initial heartbeat timeout.
[0092] In this embodiment of the invention, it has been determined that the success rate of the heartbeat signal within the target statistical period is greater than the first preset value. Therefore, the initial heartbeat timeout time set at this time is consistent with the current network state, and can be determined as the target heartbeat timeout time. Furthermore, because the heartbeat messages of the Raft leader node will trigger an election state after several failed message transmissions; and because the voting messages during Raft voting elections, a reasonable setting will increase the voting success rate and speed up the election completion time, the target election timeout time can be set to be consistent with the target heartbeat timeout time.
[0093] It should be noted that, in addition to calculating the success rate of leader node broadcast data transmission and the success rate of broadcast heartbeat signals, this embodiment of the invention also calculates the average response latency of broadcast data transmission using log data, specifically including:
[0094] Obtain log data information within the target statistical period;
[0095] The successfully transmitted broadcast data information is determined by the log data information, and the response delay of the successfully transmitted broadcast data information is obtained;
[0096] The average response delay of broadcast data transmission within the target statistical period is determined by the response delay.
[0097] Step 104: If the difference between the success rate of broadcast data transmission and the preset expected value is greater than the second preset value, the initial data transmission timeout time is increased / decreased exponentially to generate the target data transmission timeout time.
[0098] In this embodiment of the invention, the preset expected value is determined by the service's quality requirements. If the service requires high quality, the preset expected value is set higher (e.g., 99.9%); if the service requires only acceptable quality, the preset expected value can be set lower (e.g., 65%). This invention does not impose specific limitations here. The difference between the success rate of broadcast data transmission and the preset expected value can be either greater than or less than the difference between the success rate of broadcast data transmission and the preset expected value. However, regardless of the difference, as long as this difference is greater than the second preset value, it is considered that the initial data transmission timeout is far from the optimal data transmission timeout. In this case, the target data transmission timeout is generated by rapidly converging according to exponential growth / decline.
[0099] Step 105: If the difference between the success rate of broadcast data transmission and the preset expected value is less than the second preset value, obtain the historical data transmission timeout time set in the previous cycle, and take the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time.
[0100] In this embodiment of the invention, when the difference between the success rate of broadcast data transmission information and the preset expected value is less than the second preset value, it is determined that the initial data transmission timeout is close to the optimal data transmission timeout. At this time, the historical data transmission timeout set in the previous cycle is obtained, and then the initial data transmission timeout is adjusted by a binary progressive method (average calculation), that is, (historical data transmission timeout + initial data transmission timeout) / 2 = target data transmission timeout.
[0101] The timeout setting method provided in this invention obtains the success rate of broadcast heartbeat signals within a target statistical period. When the success rate of broadcast heartbeat signals within the target statistical period is determined to be greater than a first preset value, the method obtains the initial heartbeat timeout set for the heartbeat signal, the initial data transmission timeout set for data transmission, and the success rate of broadcast data transmission within the target statistical period. By judging the success rate of the heartbeat signal, the method avoids the problem that a low success rate of the heartbeat signal leads to a low success rate of data transmission due to elections within the target statistical period, rendering the data transmission rate unreliable. The method determines the target heartbeat timeout and target election timeout within the target statistical period based on the initial heartbeat timeout. This setting avoids the problem of frequent entry into election states and excessively long election success times due to excessively short heartbeat and election timeouts, resulting in a poor user experience. Furthermore, when the difference between the success rate of broadcast data transmission and the preset expected value is determined to be greater than a second preset value... The initial data transmission timeout is increased / decreased exponentially to generate a target data transmission timeout. If the difference between the success rate of broadcast data transmission and the preset expected value is less than a second preset value, the historical data transmission timeout set in the previous cycle is obtained, and the average of the historical data transmission timeout and the initial data transmission timeout is used as the target data transmission timeout. When the difference from the preset expected value is large, an exponential timeout adjustment algorithm is used; when it is close to the preset expected value, a binary method is used for adjustment. This allows the corresponding adjustment to have rapid convergence capabilities, facilitating faster achievement of the user's desired effect. In this embodiment, through a rapidly converging dynamic adjustment algorithm, timeout parameters such as heartbeat timeout, election timeout, and transmission timeout are dynamically adjusted, reducing the problem of frequent elections and data retransmissions caused by unreasonable timeout value settings. This significantly reduces the data request failure rate and request latency, improving the availability of the Raft cluster under unstable network conditions in multiple regions.
[0102] Reference Figure 3 , showed Figure 2 The flowchart shown in the embodiment of the present invention illustrates step 104 of a timeout setting method. The method may include:
[0103] Step 1041: If the difference between the success rate of broadcast data transmission and the preset expected value is greater than the second preset value, compare the success rate of broadcast data transmission with the preset expected value.
[0104] In this embodiment of the invention, the difference between the success rate of broadcast data transmission and the preset expected value can be either greater than or less than the preset expected value. Different magnitudes require different subsequent adjustment methods, so they need to be compared first.
[0105] Step 1042: If the success rate of broadcast data transmission is less than the preset expected value, twice the initial data transmission timeout is determined as the target data transmission timeout.
[0106] In this embodiment of the invention, when the success rate of broadcast data transmission is less than the preset expected value, it is considered that the success rate of broadcast data transmission needs to be improved. Therefore, the initial data transmission timeout needs to be increased. Since the difference is greater than the second preset value, the initial data transmission timeout is increased in an exponentially rapid manner. That is, twice the initial data transmission timeout is determined as the target data transmission timeout.
[0107] For example, the preset expected value is set to 80%, the second preset value to 10%, and the initial data transmission timeout is 5 seconds. The success rate of broadcast data transmission is statistically calculated to be 65%. Since 80% - 65% = 15% > 10%, the target data transmission timeout is 5 × 2 = 10 seconds. It should be noted that the above values can be adjusted according to actual needs; this invention does not impose specific limitations on them.
[0108] Step 1043: If the success rate of broadcast data transmission is determined to be greater than the preset expected value, half of the initial data transmission timeout is determined as the target data transmission timeout.
[0109] In this embodiment of the invention, when the success rate of broadcast data transmission is greater than the preset expected value, it indicates that the set initial data transmission timeout is too large. Therefore, we try to adjust the timeout to a lower value. Since the difference is greater than the second preset value, we use an exponentially rapid reduction method to reduce the initial data transmission timeout, that is, half of the initial data transmission timeout is determined as the target data transmission timeout.
[0110] For example, setting the preset expectation value to 80%, the second preset value to 10%, and the initial data transmission timeout to 5 seconds, the success rate of broadcast data transmission is statistically 92%. Since 92% - 80% = 12% > 10%, the target data transmission timeout is 5 × 2 = 10 seconds. It should be noted that the above values can be adjusted according to actual needs; this invention does not impose specific limitations. Furthermore, because some services have strict quality requirements, the preset expectation value may be higher. In this case, the difference between the success rate of broadcast data transmission and the preset expectation value cannot exceed the second preset value. In such cases, the preset expectation value adjusted to a lower timeout value and the preset expectation value adjusted to a higher timeout value can be set to different values.
[0111] Based on the above judgment, when the success rate of broadcast data transmission is significantly lower or higher than the preset expected value, an exponential growth / decrease method can be adopted, so that the relevant algorithm can quickly converge to a near-optimal value under unstable network conditions between regions.
[0112] In summary, the adjustment process for each cycle in the embodiments of the present invention is as follows: Figure 4 As shown, the Raft state is initialized, then time intervals are divided, statistical values are initialized, and then the success rate of data transmission is statistically analyzed. If the difference between the success rate of data transmission and the preset expected value is greater than the second preset value, the target data transmission timeout is set to data transmission timeout * 2 or data transmission timeout / 2. If the difference between the success rate of data transmission and the preset expected value is less than the second preset value, the target data transmission timeout is set to (historical data transmission timeout + initial data transmission timeout) / 2.
[0113] Reference Figure 5 The diagram illustrates a flowchart of another timeout setting method provided by an embodiment of the present invention. The method may include:
[0114] Step 201: Obtain the success rate of broadcast heartbeat signals within the target statistical period.
[0115] Step 202: If the success rate of broadcasting the heartbeat signal within the target statistical period is greater than the first preset value, obtain the initial heartbeat timeout time set for the heartbeat signal, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period.
[0116] Step 203: Determine the target heartbeat timeout and target election timeout within the target statistical period according to the initial heartbeat timeout.
[0117] Step 204: If the difference between the success rate of broadcast data transmission and the preset expected value is greater than the second preset value, the initial data transmission timeout time is increased / decreased exponentially to generate the target data transmission timeout time.
[0118] Step 205: If the difference between the success rate of broadcast data transmission and the preset expected value is less than the second preset value, obtain the historical data transmission timeout time set in the previous cycle, and take the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time.
[0119] The above steps 201 to 205 refer to the discussion of steps 101 to 105 mentioned above, and will not be repeated here.
[0120] Step 206: Obtain the success rate of broadcast data transmission information in the next cycle.
[0121] After an adjustment, this embodiment of the invention also needs to determine the adjusted target data transmission timeout to see if it has reached the optimal level, and in order to obtain the success rate of broadcast data transmission information in the next cycle.
[0122] Step 207: Set a second error value for the preset expected value of data transmission success rate.
[0123] The second error value in this embodiment of the invention is an error value that can be changed within the business allowable range, and the preset expected value is usually not too large. It can be 1%, 2% or 0.5%, and the invention does not make specific limitations here.
[0124] Step 208: Generate a second expected upper limit value for the data transmission success rate using the second error value and the preset expected value.
[0125] In this embodiment of the invention, the second expected upper limit value is based on the preset expected value plus the product of the second error value and the preset expected value. For example, if the second error value is 1%, then the second expected upper limit value = preset expected value × (1 + 1%).
[0126] Step 209: If the success rate of broadcast data transmission in the next cycle is determined to be between the preset expected value and the second expected upper limit value, then the data transmission timeout time set in the next cycle is determined as the optimal data transmission timeout time.
[0127] The convergence condition set in this embodiment of the invention is [preset expected value, second expected upper limit value]. When the success rate of broadcast data transmission is within this condition range (i.e., preset expected value ≤ success rate of broadcast data transmission ≤ second expected upper limit value), the data transmission timeout is considered to have converged to a value close to the optimal value, and the data transmission timeout at this time is determined as the optimal data transmission timeout.
[0128] The above steps first set the convergence condition, and then determine whether the success rate of broadcast data transmission meets the convergence condition based on the convergence condition, and then determine the optimal data transmission timeout. Through a series of settings, the optimal data transmission timeout can be accurately determined.
[0129] It should be noted that the dynamic timeout adjustment mechanism and process mentioned in this invention can be used for general backend data service timeout control and management. It has universality in quickly converging to the optimal value of the corresponding environment, and can improve the success rate of call requests in cross-regional call scenarios and improve service quality.
[0130] Reference Figure 6The diagram shows a structural schematic of a timeout setting device provided in an embodiment of the present invention. Figure 6 As shown, the device may include:
[0131] The first acquisition module 301 is used to acquire the success rate of broadcast heartbeat signals within the target statistical period.
[0132] The second acquisition module 302 is used to acquire the initial heartbeat timeout time set for the heartbeat signal, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period, provided that the success rate of broadcasting the heartbeat signal within the target statistical period is greater than a first preset value.
[0133] The first determining module 303 is used to determine the target heartbeat timeout and target election timeout within the target statistical period according to the initial heartbeat timeout.
[0134] The first generation module 304 is used to generate a target data transmission timeout by exponentially increasing / decreasing the initial data transmission timeout when the difference between the success rate of broadcast data transmission and the preset expected value is greater than a second preset value.
[0135] The third acquisition module 305 is used to acquire the historical data transmission timeout time set in the previous cycle when the difference between the success rate of broadcast data transmission information and the preset expected value is less than the second preset value, and to use the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time.
[0136] Optionally, the timeout setting device also includes:
[0137] The second determination module is used to determine the leader node in the distributed system through the target consensus algorithm.
[0138] The first setting module is used to set the preset expected value for data transmission success rate and the first preset expected value for heartbeat signal broadcast success rate.
[0139] The window segmentation module is used to divide time into time windows of equal size, where each time window corresponds to a statistical period.
[0140] The broadcast module is used to select any statistical period as the target statistical period and broadcast heartbeat signals and data transmission information through the leader node.
[0141] The fourth acquisition module is used to acquire at least one historical heartbeat timeout, historical election timeout, and historical data transmission timeout from the current leader node to other nodes.
[0142] The filtering module is used to filter out the target historical heartbeat timeout, target historical election timeout, and target historical data transmission timeout from the historical heartbeat timeout, historical election timeout, and historical data transmission timeout.
[0143] The second setting module is used to set the target historical heartbeat timeout time to the first heartbeat timeout time, set the target historical election timeout time to the initial election timeout time, and set the target historical data transmission timeout time to the initial data transmission timeout time.
[0144] The second generation module is used to generate a second heartbeat timeout by exponentially increasing the first heartbeat timeout time when the success rate of broadcasting the heartbeat signal within the target statistical period is less than the first preset value and the difference between the success rate of broadcasting the heartbeat signal within the target statistical period and the first preset expected value is greater than the third preset value.
[0145] The fifth acquisition module is used to acquire the third heartbeat timeout time set in the previous period when the success rate of broadcasting heartbeat signals within the target statistical period is less than the first preset value and the difference between the success rate of broadcasting heartbeat signals within the target statistical period and the first preset expected value is less than the third preset value, and to take the average of the third heartbeat timeout time and the first heartbeat timeout time as the second heartbeat timeout time.
[0146] The update module is used to obtain the success rate of the broadcast heartbeat signal update within the target statistical period according to the second heartbeat timeout time.
[0147] The third setting module is used to set the first error value of the first preset expected value for the success rate of heartbeat signal broadcasting.
[0148] The third generation module is used to generate a first expected upper limit value for the success rate of heartbeat signal broadcasting based on the first error value and the first preset expected value.
[0149] The third determining module is used to determine the second heartbeat as the initial heartbeat timeout time set for the heartbeat signal within the target statistical period if the success rate after the broadcast heartbeat signal update is between the first preset expected value and the first expected upper limit value.
[0150] Optionally, the first generation module 304 specifically includes:
[0151] The comparison submodule is used to compare the success rate of broadcast data transmission with the preset expected value when the difference between the success rate of broadcast data transmission and the preset expected value is greater than a second preset value.
[0152] The first determining submodule is used to determine twice the initial data transmission timeout as the target data transmission timeout when the success rate of broadcast data transmission is less than the preset expected value.
[0153] The second determining submodule is used to determine half of the initial data transmission timeout as the target data transmission timeout when the success rate of broadcast data transmission is greater than the preset expected value.
[0154] Optionally, the timeout setting device also includes:
[0155] The sixth acquisition module is used to acquire the success rate of broadcast data transmission information in the next cycle.
[0156] The fourth setting module is used to set a second error value for the preset expected value of data transmission success rate.
[0157] The fourth generation module is used to generate a second expected upper limit value for the data transmission success rate based on the second error value and the preset expected value.
[0158] The fourth determining module is used to determine the data transmission timeout set in the next cycle as the optimal data transmission timeout if the success rate of broadcast data transmission in the next cycle is between the preset expected value and the second expected upper limit value.
[0159] The seventh acquisition module is used to acquire log data information within the target statistical period.
[0160] The eighth acquisition module is used to determine the successfully transmitted broadcast data information through log data information, and to obtain the response delay of the successfully transmitted broadcast data information.
[0161] The fifth determination module is used to determine the average response delay of broadcast data transmission information within the target statistical period by means of the response delay.
[0162] The timeout setting method provided in this invention obtains the success rate of broadcast heartbeat signals within a target statistical period. When the success rate of broadcast heartbeat signals within the target statistical period is determined to be greater than a first preset value, the method obtains the initial heartbeat timeout set for the heartbeat signal, the initial data transmission timeout set for data transmission, and the success rate of broadcast data transmission within the target statistical period. By judging the success rate of the heartbeat signal, the method avoids the problem that a low success rate of the heartbeat signal leads to a low success rate of data transmission due to elections within the target statistical period, rendering the data transmission rate unreliable. The method determines the target heartbeat timeout and target election timeout within the target statistical period based on the initial heartbeat timeout. This setting avoids the problem of frequent entry into election states and excessively long election success times due to excessively short heartbeat and election timeouts, resulting in a poor user experience. Furthermore, when the difference between the success rate of broadcast data transmission and the preset expected value is determined to be greater than a second preset value... The initial data transmission timeout is increased / decreased exponentially to generate a target data transmission timeout. If the difference between the success rate of broadcast data transmission and the preset expected value is less than a second preset value, the historical data transmission timeout set in the previous cycle is obtained, and the average of the historical data transmission timeout and the initial data transmission timeout is used as the target data transmission timeout. When the difference from the preset expected value is large, an exponential timeout adjustment algorithm is used; when it is close to the preset expected value, a binary method is used for adjustment. This allows the corresponding adjustment to have rapid convergence capabilities, facilitating faster achievement of the user's desired effect. In this embodiment, through a rapidly converging dynamic adjustment algorithm, timeout parameters such as heartbeat timeout, election timeout, and transmission timeout are dynamically adjusted, reducing the problem of frequent elections and data retransmissions caused by unreasonable timeout value settings. This significantly reduces the data request failure rate and request latency, improving the availability of the Raft cluster under unstable network conditions in multiple regions.
[0163] This invention also provides a communication device, such as... Figure 7 As shown, it includes a processor 401, a communication interface 402, a memory 403, and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0164] Memory 403 is used to store computer programs;
[0165] When processor 401 executes the program stored in memory 403, it performs the following steps:
[0166] The success rate of obtaining broadcast heartbeat signals within the target statistical period;
[0167] If the success rate of broadcasting heartbeat signals within the target statistical period is greater than a first preset value, the initial heartbeat timeout time set for heartbeat signals, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information are obtained within the target statistical period.
[0168] The target heartbeat timeout and target election timeout within the target statistical period are determined according to the initial heartbeat timeout.
[0169] If the difference between the success rate of the broadcast data transmission and the preset expected value is greater than the second preset value, the initial data transmission timeout time will be increased / decreased exponentially to generate the target data transmission timeout time.
[0170] If the difference between the success rate of the broadcast data transmission information and the preset expected value is less than the second preset value, the historical data transmission timeout time set in the previous cycle is obtained, and the average of the historical data transmission timeout time and the initial data transmission timeout time is used as the target data transmission timeout time.
[0171] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0172] The communication interface is used for communication between the aforementioned terminal and other devices.
[0173] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0174] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0175] The present invention also provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to execute the timeout setting method of the foregoing embodiments.
[0176] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0177] The algorithms and displays provided herein are not inherently related to any particular computer, virtual device, or other equipment. The structure required to construct such a device is readily apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0178] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0179] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this method of disclosure should not be construed as reflecting an intention that the claimed invention requires more features than expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0180] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0181] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0182] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0183] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0184] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0185] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0186] It should be noted that the various data-related processes in the embodiments of this application are carried out in compliance with the relevant data protection laws and policies of the country where the location is located, and with the authorization granted by the owner of the corresponding device.
Claims
1. A method for setting a timeout period, characterized in that, The method includes: The success rate of obtaining broadcast heartbeat signals within the target statistical period; If the success rate of broadcasting heartbeat signals within the target statistical period is greater than a first preset value, the initial heartbeat timeout time set for heartbeat signals, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information are obtained within the target statistical period. The target heartbeat timeout and target election timeout within the target statistical period are determined according to the initial heartbeat timeout. If the difference between the success rate of the broadcast data transmission and the preset expected value is greater than the second preset value, the initial data transmission timeout time will be increased / decreased exponentially to generate the target data transmission timeout time. If the difference between the success rate of the broadcast data transmission information and the preset expected value is less than the second preset value, the historical data transmission timeout time set in the previous cycle is obtained, and the average of the historical data transmission timeout time and the initial data transmission timeout time is used as the target data transmission timeout time.
2. The method according to claim 1, characterized in that, Before obtaining the success rate of broadcast heartbeat signals within the target statistical period, the method further includes: The leader node in a distributed system is determined using a target consensus algorithm. Set a preset expected value for data transmission success rate and a first preset expected value for heartbeat signal broadcast success rate; The time is divided into time windows of equal size, where each time window corresponds to a statistical period; Select any statistical period as the target statistical period, and broadcast the heartbeat signal and data transmission information through the leader node; Obtain at least one historical heartbeat timeout, historical election timeout, and historical data transmission timeout from the current leader node to other nodes; Filter out the target historical heartbeat timeout, target historical election timeout, and target historical data transmission timeout from the historical heartbeat timeout, historical election timeout, and historical data transmission timeout that appear most frequently; The target historical heartbeat timeout is set as the first heartbeat timeout, the target historical election timeout is set as the initial election timeout, and the target historical data transmission timeout is set as the initial data transmission timeout.
3. The method according to claim 2, characterized in that, Before obtaining the initial heartbeat timeout time set for the heartbeat signal, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period, when the success rate of broadcasting the heartbeat signal within the target statistical period is greater than a first preset value, the following steps are included: If the success rate of broadcasting heartbeat signals within the target statistical period is less than a first preset value and the difference between the success rate of broadcasting heartbeat signals within the target statistical period and the first preset expected value is greater than a third preset value, the first heartbeat timeout time will be increased exponentially to generate a second heartbeat timeout time. If the success rate of broadcasting heartbeat signals within the target statistical period is less than a first preset value and the difference between the success rate of broadcasting heartbeat signals within the target statistical period and the first preset expected value is less than a third preset value, the third heartbeat timeout time set in the previous period is obtained, and the average of the third heartbeat timeout time and the first heartbeat timeout time is taken as the second heartbeat timeout time.
4. The method according to claim 3, characterized in that, After taking the average of the third heartbeat timeout time and the first heartbeat timeout time as the second heartbeat timeout time, the method further includes: obtaining the success rate of the broadcast heartbeat signal update within the target statistical period according to the second heartbeat timeout time; Set a first error value for the first preset expected value of the success rate of heartbeat signal broadcasting; A first expected upper limit value for the success rate of heartbeat signal broadcasting is generated by using the first error value and the first preset expected value; If the success rate of the broadcast heartbeat signal update is determined to be between the first preset expected value and the first expected upper limit value, then the second heartbeat is determined as the initial heartbeat timeout time set for the heartbeat signal within the target statistical period.
5. The method according to claim 1, characterized in that, When the difference between the success rate of the broadcast data transmission and the preset expected value is greater than a second preset value, the initial data transmission timeout is increased / decreased exponentially to generate a target data transmission timeout, including: If the difference between the success rate of the broadcast data transmission information and the preset expected value is greater than the second preset value, the success rate of the broadcast data transmission information is compared with the preset expected value. If the success rate of the broadcast data transmission is determined to be less than the preset expected value, twice the initial data transmission timeout time is determined as the target data transmission timeout time. If the success rate of the broadcast data transmission is determined to be greater than the preset expected value, half of the initial data transmission timeout is determined as the target data transmission timeout.
6. The method according to claim 1, characterized in that, After determining that the difference between the success rate of the broadcast data transmission information and the preset expected value is less than a second preset value, the method further includes obtaining the historical data transmission timeout time set in the previous cycle, and using the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time. Success rate of obtaining broadcast data transmission information in the next cycle; Set a second error value for the preset expected value of data transmission success rate; A second expected upper limit value for data transmission success rate is generated by using the second error value and the preset expected value; If the success rate of broadcast data transmission in the next cycle is determined to be between the preset expected value and the second expected upper limit value, then the data transmission timeout time set in the next cycle is determined as the optimal data transmission timeout time.
7. The method according to claim 1, characterized in that, Before determining the target heartbeat timeout and target election timeout within the target statistical period according to the initial heartbeat timeout, the method further includes: Obtain log data information within the target statistical period; The successfully transmitted broadcast data information is determined by the log data information, and the response delay of the successfully transmitted broadcast data information is obtained. The average response time of broadcast data transmission information within the target statistical period is determined by the response delay. Time delay.
8. A timeout setting device, characterized in that, include: The first acquisition module is used to acquire the success rate of broadcast heartbeat signals within the target statistical period; The second acquisition module is used to acquire, when the success rate of broadcasting heartbeat signals within the target statistical period is greater than a first preset value, the initial heartbeat timeout time set for heartbeat signals, the initial data transmission timeout time set for data transmission, and the success rate of broadcasting data transmission information within the target statistical period; The first determining module is used to determine the target heartbeat timeout time and the target election timeout time within the target statistical period according to the initial heartbeat timeout time; The first generation module is used to generate a target data transmission timeout by exponentially increasing / decreasing the initial data transmission timeout when the difference between the success rate of the broadcast data transmission information and the preset expected value is greater than a second preset value. The third acquisition module is used to acquire the historical data transmission timeout time set in the previous cycle when the difference between the success rate of the broadcast data transmission information and the preset expected value is less than the second preset value, and to take the average of the historical data transmission timeout time and the initial data transmission timeout time as the target data transmission timeout time.
9. A communication device, characterized in that, include: A transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; The processor is configured to read a program from the memory to implement the steps in the timeout setting method as described in any one of claims 1-7.
10. A readable storage medium for storing a program, characterized in that, When the stored program is executed by the processor, it implements the steps in the timeout setting method as described in any one of claims 1-7.
Citation Information
Patent Citations
Transmitting control method and device for heartbeat signal
CN103518342A
Method and device for adjusting heartbeat period of communication between communication device and server
CN108574981A