Server health check method, apparatus, device, and medium

By continuously receiving and analyzing server response data packets transmitted multiple times through load balancing devices, the problem of insufficient accuracy of health checks in existing technologies is solved, thereby improving the decision-making accuracy and service availability of the load balancing system.

CN122293540APending Publication Date: 2026-06-26HANGZHOU DPTECH TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU DPTECH TECH
Filing Date
2026-04-16
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing load balancing devices rely on the results of a single response data packet during health checks, which has low accuracy and can lead to misjudgments, affecting service availability.

Method used

The health check is treated as a continuous session. The load balancer continuously receives server response data packets that are transmitted in multiple parts and makes judgments based on the accumulated data packets, avoiding reliance on incomplete information from the first data packet.

Benefits of technology

It improves the accuracy of health check results, ensures the accuracy of load balancing system decisions and service availability, and is more tolerant of network latency and server response instability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122293540A_ABST
    Figure CN122293540A_ABST
Patent Text Reader

Abstract

This application provides a server health check method, apparatus, device, and medium. The method includes: according to a health check cycle, establishing a communication link between a load balancing device and the server to be checked via Transmission Control Protocol (TCP), sending probe packets to the server, and starting a response reception timer; receiving the first response data packet from the server, and analyzing the first response data packet according to matching rules to obtain the analysis result of the first response data packet; if the analysis result of the first response data packet does not meet the matching rules, continuously receiving response data packets from the server, and analyzing the accumulated received response data packets according to matching rules until the accumulated received response data packets meet the matching rules or the response reception timer reaches a preset reception duration, thereby determining the server's health check result. This treats a single health check as a continuous session, avoiding misjudgments caused by only reading partial response data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer network technology, and more specifically, to a server health check method, apparatus, device, and medium. Background Technology

[0002] With the continuous advancement of network technology, network traffic is showing a constantly increasing trend. A single server can no longer meet users' demands for high concurrency, high connection rates, and high processing speeds, and upgrading server hardware is relatively inefficient. Against this backdrop, server load balancing technology has emerged to improve business processing capacity and speed. Load balancing devices can detect the operating status of real servers and, based on this status, rationally distribute client traffic to one or more real servers. Therefore, accurately determining the server's operating status is of great guiding significance for the traffic scheduling of load balancing devices.

[0003] When determining the server's operational status through health checks, the load balancer sends a probe request to the server. Upon receiving the first response packet, it immediately disconnects and uses that response packet to determine the operational status. However, the response information relied upon for health checks is often incomplete, resulting in low accuracy and impacting the availability of the load balancer service. Summary of the Invention

[0004] In view of this, this application provides a server health check method, apparatus, device and medium that treats a single health check as a continuous session, continuously receives server response data packets transmitted in multiple parts, and makes a judgment based on the accumulated received response data packets, thereby effectively improving the accuracy of the health check results.

[0005] Specifically, this application is implemented through the following technical solution: According to a first aspect of this application, a server health check method is provided, the method comprising: According to the health check cycle, a probe message is sent to the server through the TCP connection between the load balancing device and the server to be checked, and the response reception timer is started. Receive the first response data packet from the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet; If the analysis result of the first response data packet is that it does not meet the matching rule, the server continues to receive response data packets, and the accumulated received response data packets are analyzed according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and the health check result of the server is determined.

[0006] In an optional implementation, before sending a probe message to the server via the Transmission Control Protocol (TCP) connection communication link between the load balancer and the server to be inspected, the method further includes: Detect whether a TCP connection has been established between the load balancing device and the server to be inspected; If a TCP connection has been established between the load balancing device and the server to be inspected, the established TCP connection communication link is reused. If no TCP connection is established between the load balancer and the server to be inspected, a TCP connection communication link is created between the load balancer and the server to be inspected.

[0007] In one optional implementation, the matching rules include normal keywords and abnormal keywords; the step of analyzing the first response data packet according to the matching rules to obtain the analysis result of the first response data packet includes: If the normal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and the content is correct; If the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and have incorrect content; If neither the normal keyword nor the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to be that it does not meet the matching rule.

[0008] In one optional implementation, the presence of the normal keyword in the first response data packet is detected by the following steps: Compare the character length of the first response data packet with the normal keyword length; If the character length of the first response data packet is greater than or equal to the normal keyword length, detect whether there are any characters in the first response data packet that are consistent with the normal keyword content; If a character in the first response data packet is identical to the normal keyword content, it is determined that the normal keyword exists in the first response data packet.

[0009] In one optional implementation, the preset reception duration is longer than the health check interval indicated by the health check cycle; the method further includes: If, at the end of the current health check cycle, the accumulated received response data packets do not meet the matching rules and the response reception time has not reached the preset reception time, a probe message will be sent to the server again through the TCP connection communication link between the load balancer and the server to be checked in the next health check interval, and the response reception time will continue to be counted.

[0010] In one optional implementation, determining the health check result of the server includes: If the cumulative received response data packets meet the matching rules and the content is correct, the health check result of the server is determined to be normal. If the cumulative received response data packets meet the matching rules but the content is incorrect, or if the response reception time reaches the preset reception time, the health check result of the server is determined to be abnormal.

[0011] In one optional implementation, after determining the health check result of the server, the method further includes: Close the TCP connection between the load balancer and the server.

[0012] According to a second aspect of this application, a server health check device is provided, applied to a load balancing device, the device comprising: The message sending module is used to send probe messages to the server through the TCP connection communication link between the load balancing device and the server to be checked according to the health check cycle, and start the response reception timer. The first analysis module is used to receive the first response data packet from the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet; The second analysis module is used to continuously receive response data packets from the server if the analysis result of the first response data packet does not meet the matching rule, and analyze the accumulated received response data packets according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and determine the health check result of the server.

[0013] According to a third aspect of this application, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the server health check method described in the first aspect above.

[0014] According to a fourth aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the server health check method described in the first aspect above.

[0015] The server health check method, apparatus, device, and medium provided in this application, based on the TCP streaming characteristics, treat a single health check as a continuous session. It continuously receives server response data packets transmitted in multiple batches and makes judgments based on the accumulated received response data packets, rather than relying solely on the first data packet. This avoids misjudgments caused by only reading partial response data, effectively improving the accuracy of health check results. This, in turn, helps improve the accuracy of load balancing system decisions and ensures the availability of load balancing services. Furthermore, because it does not make immediate judgments based on single data packet delays or minor transmission differences, but rather conducts a more comprehensive evaluation through continuous sessions, it can better tolerate network latency jitter, slow server response, or abnormal data packet fragmentation, thereby improving robustness and practicality under complex conditions in real production environments.

[0016] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this disclosure.

[0017] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating a server health check method according to an exemplary embodiment of this application; Figure 2 This is a schematic diagram illustrating an exemplary embodiment of the present application of a process for analyzing response data packets; Figure 3 This is a schematic diagram illustrating a server health check process according to an exemplary embodiment of this application; Figure 4 This is a schematic diagram of a server health check device shown in an exemplary embodiment of this application; Figure 5 This is a schematic diagram of the structure of a computer device shown in an exemplary embodiment of this application. Detailed Implementation

[0019] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0020] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0021] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0022] To facilitate understanding of the technical solutions disclosed herein, the technical terms used in the embodiments of this disclosure will be explained first.

[0023] Load balancing: Load balancing is a core network clustering technology. Its core objective is to intelligently distribute incoming business traffic from a unified entry point to multiple backend servers or computing nodes based on preset algorithms (such as round-robin, weighted least connections, etc.). Server load balancing is mainly divided into Layer 4 load balancing and Layer 7 load balancing, depending on the layer of messages processed. Layer 4 load balancing forwards traffic based on network layer (IP) and transport layer (TCP / UDP) information (such as IP addresses and port numbers), without parsing or processing application layer message content. Layer 7 load balancing can deeply parse the headers and even content of application layer protocols (such as HTTP, HTTPS, RTSP, etc.), and can make more granular traffic distribution decisions based on specific information such as URLs, cookies, and message types.

[0024] Health checks: Health checks are a crucial supporting mechanism in load balancing systems, used to proactively monitor the operational status and service availability of backend servers. The load balancer periodically sends probe requests (such as TCP connection attempts) to servers and dynamically determines the server's health based on the response results (such as whether a connection was established and the returned HTTP status code). This mechanism forms the foundation of service resilience: once a server is detected as abnormal, the load balancer automatically removes it from the pool of available servers, and subsequent traffic will no longer be allocated to that failed node; when the server recovers and passes the health check, it will be automatically reintroduced into the server pool and resume handling traffic. This effectively avoids service unavailability due to a single point of failure, significantly improving the overall fault tolerance and continuity of the business.

[0025] Transmission Control Protocol (TCP): TCP is a core protocol in the Internet Protocol suite (TCP / IP) at the transport layer. It provides a connection-oriented, reliable, byte-stream-based end-to-end communication service. It primarily establishes a connection through a "three-way handshake" to ensure reliable transmission and is widely used in scenarios requiring absolutely reliable data transmission, such as web browsing (HTTP / HTTPS), email (SMTP / POP), file transfer (FTP), and remote login.

[0026] Research has revealed that when determining server operational status through health checks, the load balancer sends a probe request to the server. Upon receiving the first response packet, it immediately disconnects and uses this first response packet to determine the operational status. However, because TCP is a streaming protocol and is affected by network latency, server processing differences, and kernel buffering mechanisms, a complete application-layer response may be split into multiple TCP packets transmitted asynchronously. This often results in the health checker only reading the first part of the response before being forcibly truncated, while subsequent packets containing crucial status information may still be transmitted over the network or temporarily stored in the server's buffer. Therefore, the response content upon which the health check is based is often incomplete. Judgments based on this incomplete information have low accuracy and may lead to misjudgments of server operational status, affecting the availability of the load balancer service.

[0027] Based on the above research, this application provides a server health check method, apparatus, device, and medium. According to the TCP streaming characteristics, a single health check is treated as a continuous session. By continuously receiving server response data packets transmitted in multiple parts, the health check is judged based on the accumulated received response data packets, rather than judging based solely on the first data packet. This avoids misjudgments caused by only reading partial response data, effectively improving the accuracy of health check results. This, in turn, helps improve the accuracy of load balancing system decisions and ensures the service availability of load balancing.

[0028] To facilitate understanding of this embodiment, a server health check method disclosed in this application will first be described in detail. The execution subject of the server health check method provided in this application embodiment is generally a load balancing device, which may be equipped with a health checker. In some possible implementations, the server health check method can be implemented by a processor calling computer-readable instructions stored in memory.

[0029] The following description, in conjunction with the accompanying drawings, illustrates a server health check method provided in an embodiment of this application.

[0030] See Figure 1 The diagram shown is a flowchart illustrating a server health check method according to an exemplary embodiment of this application. Figure 1 As shown in the figure, the server health check method provided in this embodiment includes steps S101 to S103, wherein: S101: According to the health check cycle, a probe message is sent to the server through the TCP connection communication link between the load balancing device and the server to be checked, and the response reception timer is started.

[0031] In this step, a health check cycle can be obtained, which indicates a health check time interval. According to the health check cycle, when the health check time interval is met, a health check is triggered on the server to be checked. A probe message is sent to the server via the TCP connection between the load balancer and the server to be checked.

[0032] The specific value of the health check interval can be determined according to the actual health check needs, and there is no limitation here. For example, the health check interval is 5 seconds.

[0033] Here, a probe message can be constructed based on the configured custom request content (such as an HTTP request string, a specific protocol instruction, etc.), and the probe message can be sent to the corresponding port of the server through a TCP connection communication link.

[0034] Here, after sending a probe message to the server, a response reception timer can be enabled to start the response reception timer and then enter a waiting state to wait for the response data packet from the server.

[0035] Optionally, the load balancing device can perform health checks on multiple servers simultaneously. The load balancing device can also perform memory partitioning, with the communication links with each server corresponding to different memory partitions on the load balancing device, in order to achieve independent session management and ensure session isolation and state independence with different servers.

[0036] In some possible implementations, before sending probe packets to the server via the Transmission Control Protocol (TCP) connection communication link between the load balancer and the server to be inspected, the method further includes: Detect whether a TCP connection has been established between the load balancing device and the server to be inspected; If a TCP connection has been established between the load balancing device and the server to be inspected, the established TCP connection communication link is reused. If no TCP connection is established between the load balancer and the server to be inspected, a TCP connection communication link is created between the load balancer and the server to be inspected.

[0037] In the traditional health check process, the load balancer sends a probe request to the server and immediately disconnects after receiving the first response packet. This means that when the next health check interval arrives, a new TCP connection needs to be created, resulting in repeated three-way handshakes. This increases the number of packets in the network and wastes device resources.

[0038] In this embodiment of the disclosure, when a check fails to produce a clear determination because the response data packet does not meet the matching rules, the load balancing device will not immediately disconnect the TCP connection, but will allow the TCP connection to be directly reused in the next health check interval to send a new probe message, thereby avoiding the overhead of repeated TCP three-way handshake and connection teardown.

[0039] Here, before sending a probe message to the server, it is possible to first check whether a TCP connection has been established between the load balancer and the server to be checked. Specifically, the TCP connection communication link between the load balancer and the server to be checked can be marked with a status flag. If a TCP connection has been established, it is marked as valid; if no TCP connection has been established, it is marked as closed.

[0040] If the current flag is "valid," it indicates that a TCP connection has been established between the load balancer and the server under inspection. The established TCP connection is then reused for this probe message transmission. If the current flag is "closed," it indicates that a TCP connection has not been established between the load balancer and the server under inspection. The TCP three-way handshake process is then followed to recreate the TCP connection between the load balancer and the server under inspection, and the status of this TCP connection is tracked and maintained.

[0041] In this way, when sending probe packets to the server, existing TCP connection communication links that have not been disconnected are reused first to reduce the overhead of repeatedly establishing connections. This helps to reduce the number of packets in the network and reduce the resource consumption of the server and load balancing equipment when handling connection establishment and destruction, such as CPU, memory and port consumption. This significantly optimizes the overhead under high-frequency health checks, reduces the waste of equipment resources, effectively saves network and computing resources, and improves processing efficiency.

[0042] S102: Receive the first response data packet from the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet.

[0043] In this step, response data packets from the server arrive at the load balancer's health checker sequentially. Due to the characteristics of TCP streaming and the uncertainty of the network environment, response data often arrives in multiple stages. Upon receiving the first response data packet from the server, it can be analyzed according to matching rules to obtain the analysis results.

[0044] The analysis results include those that satisfy the matching rules and have correct content, those that satisfy the matching rules but have incorrect content, or those that do not satisfy the matching rules.

[0045] In some possible implementations, the matching rules include normal keywords and abnormal keywords; the step of analyzing the first response data packet according to the matching rules to obtain the analysis result of the first response data packet includes: If the normal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and the content is correct; If the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and have incorrect content; If neither the normal keyword nor the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to be that it does not meet the matching rule.

[0046] In the above steps, it can be determined whether the first response data packet contains the normal keyword or the abnormal keyword. If the first response data packet contains the normal keyword, it can be determined that the analysis result of the first response data packet satisfies the matching rule and the content is correct. If the first response data packet contains the abnormal keyword, it can be determined that the analysis result of the first response data packet satisfies the matching rule but the content is incorrect. If the first response data packet does not contain either the normal keyword or the abnormal keyword, it can be determined that the analysis result of the first response data packet does not satisfy the matching rule.

[0047] Optionally, the presence of the normal keyword in the first response data packet can be detected first. If the normal keyword is not present in the first response data packet, the presence of the abnormal keyword in the first response data packet can then be detected.

[0048] Alternatively, the system may first detect whether the abnormal keyword exists in the first response data packet. If the abnormal keyword does not exist in the first response data packet, the system may then detect whether the normal keyword exists in the first response data packet.

[0049] In this way, by setting matching rules that include normal and abnormal keywords, keyword matching analysis can be performed on the first response data packet, which can quickly distinguish between three situations: correct response content, incorrect response content, and keyword mismatch. This enables a rapid and accurate determination of the server response. It can quickly obtain the check results when the response content is clearly normal or abnormal, and it can also provide a basis for the continuous accumulation and analysis of subsequent response data packets when the corresponding keyword is not identified, thus improving the accuracy and efficiency of health checks.

[0050] In some possible implementations, the presence of the normal keyword in the first response data packet is detected by the following steps: Compare the character length of the first response data packet with the normal keyword length; If the character length of the first response data packet is greater than or equal to the normal keyword length, detect whether there are any characters in the first response data packet that are consistent with the normal keyword content; If a character in the first response data packet is identical to the normal keyword content, it is determined that the normal keyword exists in the first response data packet.

[0051] In the above steps, the character length of the first response data packet can be compared with the length of the normal keyword. If the character length of the first response data packet is less than the length of the normal keyword, it indicates that the normal keyword does not exist in the first response data packet. If the character length of the first response data packet is greater than or equal to the length of the normal keyword, it indicates that the normal keyword may exist in the first response data packet, and then it is detected whether there are any characters in the first response data packet that are consistent with the content of the normal keyword. Here, consistency includes text consistency and protocol format consistency. If there are characters in the first response data packet that are consistent with the content of the normal keyword, it can be determined that the normal keyword exists in the first response data packet. If there are no characters in the first response data packet that are consistent with the content of the normal keyword, it can be determined that the normal keyword does not exist in the first response data packet.

[0052] By first comparing the character length of the response data packet with that of the normal keyword, and then performing content consistency checks when the character length is greater than or equal to the length of the normal keyword, it is possible to efficiently and accurately determine whether there is a normal keyword in the first response data packet, avoid invalid content matching operations, reduce redundant data processing, and help improve the efficiency of normal keyword detection.

[0053] Here, the step of detecting whether the abnormal keyword exists in the first response data packet is similar to the step of detecting whether the normal keyword exists in the first response data packet. It also involves comparing the length first and then comparing the content. For a detailed description, please refer to the foregoing embodiments, which will not be repeated here.

[0054] S103: If the analysis result of the first response data packet is that it does not meet the matching rule, the server continues to receive response data packets, and the accumulated received response data packets are analyzed according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and the server's health check result is determined.

[0055] In this step, if the analysis result of the first response data packet satisfies the matching rule, the health check result of the server can be determined, that is, the server status can be judged. If the analysis result of the first response data packet does not satisfy the matching rule, response data packets fed back by the server are continuously received, and the accumulated received response data packets are analyzed according to the matching rule.

[0056] For example, if the analysis result of the first response data packet is that it does not meet the matching rule, a second response data packet can be received. The accumulated received response data packets are then analyzed according to the matching rule, and this analysis includes the first and second response data packets. If the analysis result of the accumulated received response data packets is that it meets the matching rule, the health check result of the server can be determined. If the analysis result of the accumulated received response data packets is that it does not meet the matching rule, a third response data packet can be received. The accumulated received response data packets are then analyzed according to the matching rule, and this analysis includes the first, second, and third response data packets.

[0057] The system continuously receives and analyzes response data packets until the accumulated received response data packets meet the matching rules or the response reception time reaches the preset reception time, and then determines the health check result of the server.

[0058] The specific value of the preset reception duration can be determined according to the actual health check needs, and there is no limitation here. For example, the preset reception duration is 16 seconds.

[0059] Optionally, the load balancing device may set up a session buffer to store accumulated received response data packets.

[0060] Here, the step of analyzing the accumulated received response data packets according to the matching rules is similar to the step of analyzing the first response data packet according to the matching rules. For a detailed description, please refer to the aforementioned embodiments, which will not be repeated here.

[0061] To more clearly illustrate the process of analyzing response packets, see [link to documentation]. Figure 2 This is a schematic diagram illustrating an exemplary embodiment of the present application, showing a process for analyzing a response data packet. In this example, the target response data packet is the first response data packet or a cumulative collection of received response data packets. This example describes the process of first detecting whether the normal keyword exists in the target response data packet, and then detecting whether the abnormal keyword exists in the target response data packet. Figure 2As shown, the character length of the target response data packet is compared with the length of the normal keyword to determine if the character length of the target response data packet is less than the length of the normal keyword. If the character length of the target response data packet is less than the length of the normal keyword, it is determined that the target response data packet does not contain the normal keyword. If the character length of the target response data packet is not less than the length of the normal keyword, it is determined whether there are any characters in the target response data packet that match the content of the normal keyword. If there are characters in the target response data packet that match the content of the normal keyword, it is determined that the target response data packet contains the normal keyword, and thus it can be determined that the analysis result of the target response data packet satisfies the matching rules and the content is correct. If there are no characters in the target response data packet that match the content of the normal keyword, it is determined that the target response data packet does not contain the normal keyword.

[0062] If it is determined that there are no normal keywords in the target response data packet, the character length of the target response data packet is compared with the length of the abnormal keyword to determine if the character length of the target response data packet is less than the length of the abnormal keyword. If the character length of the target response data packet is less than the length of the abnormal keyword, it is determined that there are no abnormal keywords in the target response data packet; in this case, there are no normal keywords and no abnormal keywords in the target response data packet. If the character length of the target response data packet is not less than the length of the abnormal keyword, it is determined whether there are any characters in the target response data packet that match the content of the abnormal keyword. If there are any characters in the target response data packet that match the content of the abnormal keyword, it is determined that there are abnormal keywords in the target response data packet, and thus the analysis result of the target response data packet can be determined to satisfy the matching rule but the content is incorrect. If there are no characters in the target response data packet that match the content of the abnormal keyword, it is determined that there are no abnormal keywords in the target response data packet; in this case, there are no normal keywords and no abnormal keywords in the target response data packet. If there are no normal keywords and no abnormal keywords in the target response data packet, the analysis result of the target response data packet is determined to not satisfy the matching rule. For a detailed description, please refer to the aforementioned embodiments, which will not be repeated here.

[0063] In some possible implementations, the preset reception duration is longer than the health check interval indicated by the health check cycle.

[0064] Here, the response reception time and the health check interval time are two independent timers. If they expire simultaneously, i.e., if the preset reception duration is equal to the health check interval indicated by the health check cycle, they may not be distinguishable, leading to misjudgment. If the preset reception duration is less than the health check interval indicated by the health check cycle, the health check may be insufficient, affecting the accuracy of the check results. In this embodiment, setting the preset reception duration to be greater than the health check interval indicated by the health check cycle helps ensure the integrity of the health check process and sufficient basis for judgment, thereby improving the reliability and accuracy of the health check results.

[0065] In some possible implementations, the method further includes: If, at the end of the current health check cycle, the accumulated received response data packets do not meet the matching rules and the response reception time has not reached the preset reception time, a probe message will be sent to the server again through the TCP connection communication link between the load balancer and the server to be checked in the next health check interval, and the response reception time will continue to be counted.

[0066] In this step, if the accumulated received response data packets do not meet the matching rules and the response reception time has not reached the preset reception time when the current health check cycle ends, the TCP connection between the load balancer and the server will not be closed. In the next health check interval, the established TCP connection communication link between the load balancer and the server can be reused to resend probe packets to the server and continue to perform response reception time. That is, response reception time is continuously performed in the above process without restarting the response reception time.

[0067] It is understood that the health check result of the server is only obtained when the matching rules are met or the response reception time reaches the preset reception time, and is not necessarily obtained at the end of a health check cycle.

[0068] In this way, when the current health check cycle ends but the response reception timer has not expired and the accumulated response data packets still do not meet the matching rules, the established TCP connection communication link can be reused in the next health check interval to resend probe packets and continue timing. This reduces the latency and resource consumption caused by repeated handshakes. At the same time, it can continuously and coherently detect the server status without interrupting the health check logic, avoiding direct judgment of abnormality due to incomplete reception of responses in a single cycle, and improving the accuracy of health check results.

[0069] In some possible implementations, determining the health check result of the server includes: If the cumulative received response data packets meet the matching rules and the content is correct, the health check result of the server is determined to be normal. If the cumulative received response data packets meet the matching rules but the content is incorrect, or if the response reception time reaches the preset reception time, the health check result of the server is determined to be abnormal.

[0070] In this way, this technical solution distinguishes and judges the server health check results based on whether the accumulated received response data packets meet the matching rules and have correct content, and whether the preset reception time has been reached. It can accurately determine that the server is normal when the response data with correct content is obtained, and accurately determine that the server is abnormal when the response content is incorrect or the timeout fails to meet the matching rules. This makes the logic of health check result judgment clear and the standards explicit, further improving the accuracy and reliability of server status judgment.

[0071] Optionally, if the server's health check result is normal, the server is considered available, and traffic data will be sent to the server during the next load balancing service. For example, a previously used server can continue to be used, or a previously deactivated server can be restored to use. If the server's health check result is abnormal, the server is considered unavailable, and traffic data will not be sent to the server during the next load balancing service. For example, a previously deactivated server can remain deactivated, or a previously used server can be deactivated.

[0072] In practical applications, after sending all response data packets, the server will proactively close the TCP connection with the load balancer.

[0073] In some possible implementations, after determining the health check results of the server, the method further includes: Close the TCP connection between the load balancer and the server.

[0074] In this step, the TCP connection with the server is closed only after the health check result of the server is obtained. Thus, a single health check can be a continuous session spanning at least one health check interval. During this session, the TCP connection between the load balancer and the server remains open, rather than being immediately disconnected after each data analysis. This effectively avoids the overhead of repeated TCP three-way handshakes and connection teardowns, improves the efficiency of health check execution, and ensures session continuity and the accuracy of check results.

[0075] For a clearer illustration of the server health check process, see [link to documentation]. Figure 3 This is a schematic diagram illustrating a server health check process, as shown in an exemplary embodiment of this application. Figure 3 As shown, when the health check interval is met, it checks whether a TCP connection has been established between the load balancer and the server to be checked. If a TCP connection has been established, the established TCP connection communication link is reused. If no TCP connection has been established, a TCP connection communication link is created between the load balancer and the server to be checked. Probe packets are sent to the server through the TCP connection communication link between the load balancer and the server to be checked. Response data packets from the server are continuously received, and the accumulated received response data packets are analyzed incrementally according to matching rules to check whether the accumulated received response data packets meet the matching rules, until the accumulated received response data packets meet the matching rules or the response reception time reaches the preset reception time, at which point the server's health check result is determined. For a detailed description, please refer to the aforementioned embodiment; it will not be repeated here.

[0076] The server health check method provided in this application, based on the streaming characteristics of TCP, treats a single health check as a continuous session. It continuously receives server response data packets transmitted in multiple transmissions and makes judgments based on the accumulated received response data packets, rather than relying solely on the first data packet. This avoids misjudgments caused by reading only partial response data, effectively improving the accuracy of health check results. This, in turn, helps improve the accuracy of load balancing system decisions and ensures the availability of load balancing services. Furthermore, since it does not make immediate judgments based on the delay or minor transmission differences of a single data packet, but rather conducts a more comprehensive evaluation through a continuous session, it can better tolerate network latency jitter, slow server response, or abnormal data packet fragmentation, thereby improving robustness and practicality under complex conditions in real production environments.

[0077] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0078] Corresponding to the embodiments of the aforementioned server health check method, this application also provides embodiments of a server health check apparatus.

[0079] Please see Figure 4 This is a schematic diagram illustrating a server health check device according to an exemplary embodiment of this application. This server health check device is applied to load balancing equipment, such as... Figure 4 As shown in the illustration, the server health check device 400 provided in this application embodiment includes: The message sending module 401 is used to send probe messages to the server through the TCP connection communication link between the load balancing device and the server to be checked according to the health check cycle, and start the response receiving timer. The first analysis module 402 is used to receive the first response data packet fed back by the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet; The second analysis module 403 is used to continuously receive response data packets from the server if the analysis result of the first response data packet does not meet the matching rule, and analyze the accumulated received response data packets according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and determine the health check result of the server.

[0080] In some possible implementations, the message sending module 401 is further configured to: Detect whether a TCP connection has been established between the load balancing device and the server to be inspected; If a TCP connection has been established between the load balancing device and the server to be inspected, the established TCP connection communication link is reused. If no TCP connection is established between the load balancer and the server to be inspected, a TCP connection communication link is created between the load balancer and the server to be inspected.

[0081] In some possible implementations, the matching rules include normal keywords and abnormal keywords; when the first analysis module 402 analyzes the first response data packet according to the matching rules to obtain the analysis result of the first response data packet, it is specifically used for: If the normal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and the content is correct; If the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and have incorrect content; If neither the normal keyword nor the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to be that it does not meet the matching rule.

[0082] In some possible implementations, the first analysis module 402 detects whether the normal keyword exists in the first response data packet through the following steps: Compare the character length of the first response data packet with the normal keyword length; If the character length of the first response data packet is greater than or equal to the normal keyword length, detect whether there are any characters in the first response data packet that are consistent with the normal keyword content; If a character in the first response data packet is identical to the normal keyword content, it is determined that the normal keyword exists in the first response data packet.

[0083] In some possible implementations, the preset reception duration is greater than the health check interval indicated by the health check cycle; the second analysis module 403 is further configured to: If, at the end of the current health check cycle, the accumulated received response data packets do not meet the matching rules and the response reception time has not reached the preset reception time, a probe message will be sent to the server again through the TCP connection communication link between the load balancer and the server to be checked in the next health check interval, and the response reception time will continue to be counted.

[0084] In some possible implementations, the second analysis module 403, when determining the health check results of the server, is specifically used for: If the cumulative received response data packets meet the matching rules and the content is correct, the health check result of the server is determined to be normal. If the cumulative received response data packets meet the matching rules but the content is incorrect, or if the response reception time reaches the preset reception time, the health check result of the server is determined to be abnormal.

[0085] In some possible implementations, the server health check device 400 further includes a connection closure module 404, which is specifically used for: Close the TCP connection between the load balancer and the server.

[0086] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.

[0087] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0088] Based on the same technical concept, this application also provides a computer device 500, which includes a load balancing device, as described above. Figure 5 The diagram shown is a schematic representation of the structure of a computer device according to an exemplary embodiment of this application, comprising: The processor 510, memory 520, and bus 530 are included. The memory 520 is used to store execution instructions and includes main memory 521 and external memory 522. The main memory 521, also known as internal memory, is used to temporarily store the operation data in the processor 510 and the data exchanged with external memory 522 such as hard disk. The processor 510 exchanges data with external memory 522 through main memory 521.

[0089] In this embodiment, the memory 520 is specifically used to store application code that executes the solution of this application, and its execution is controlled by the processor 510. That is, when the computer device 500 is running, the processor 510 communicates with the memory 520 through the bus 530, or the processor 510 communicates with the memory 520 through other means, so that the processor 510 executes the application code stored in the memory 520, and then performs the steps of the server health check method described in any of the foregoing embodiments.

[0090] The memory 520 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0091] Processor 510 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.

[0092] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the computer device 500. In other embodiments of this application, the computer device 500 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0093] This disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the server health check method described in the above-described method embodiments. The storage medium can be either volatile or non-volatile computer-readable storage.

[0094] This disclosure also provides a computer program product storing a computer program. When the computer program is run by a processor, it executes the steps of the server health check method provided in any of the above embodiments of this disclosure. For details, please refer to the above method embodiments, which will not be repeated here.

[0095] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium, which can be a volatile or non-volatile computer-readable storage medium. In another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0096] Furthermore, embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing apparatus or for controlling the operation of a data processing apparatus. Alternatively or additionally, program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.

[0097] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.

[0098] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.

[0099] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. Processors and memory may be supplemented by or incorporated into dedicated logic circuitry.

[0100] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.

[0101] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

[0102] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.

[0103] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A server health check method, characterized in that, Applied to load balancing devices, the method includes: According to the health check cycle, a probe message is sent to the server through the TCP connection between the load balancing device and the server to be checked, and the response reception timer is started. Receive the first response data packet from the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet; If the analysis result of the first response data packet is that it does not meet the matching rule, the server continues to receive response data packets, and the accumulated received response data packets are analyzed according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and the health check result of the server is determined.

2. The method according to claim 1, characterized in that, Before sending probe packets to the server via the Transmission Control Protocol (TCP) connection communication link between the load balancing device and the server to be inspected, the method further includes: Detect whether a TCP connection has been established between the load balancing device and the server to be inspected; If a TCP connection has been established between the load balancing device and the server to be inspected, the established TCP connection communication link is reused. If no TCP connection is established between the load balancer and the server to be inspected, a TCP connection communication link is created between the load balancer and the server to be inspected.

3. The method according to claim 1, characterized in that, The matching rules include normal keywords and abnormal keywords; the analysis of the first response data packet according to the matching rules to obtain the analysis result of the first response data packet includes: If the normal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and the content is correct; If the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to satisfy the matching rule and have incorrect content; If neither the normal keyword nor the abnormal keyword exists in the first response data packet, the analysis result of the first response data packet is determined to be that it does not meet the matching rule.

4. The method according to claim 3, characterized in that, The following steps are used to detect whether the normal keyword exists in the first response data packet: Compare the character length of the first response data packet with the normal keyword length; If the character length of the first response data packet is greater than or equal to the normal keyword length, detect whether there are any characters in the first response data packet that are consistent with the normal keyword content; If a character in the first response data packet is identical to the normal keyword content, it is determined that the normal keyword exists in the first response data packet.

5. The method according to claim 1, characterized in that, The preset reception duration is greater than the health check time interval indicated by the health check cycle; the method further includes: If, at the end of the current health check cycle, the accumulated received response data packets do not meet the matching rules and the response reception time has not reached the preset reception time, a probe message will be sent to the server again through the TCP connection communication link between the load balancer and the server to be checked in the next health check interval, and the response reception time will continue to be counted.

6. The method according to claim 1, characterized in that, Determining the health check result of the server includes: If the cumulative received response data packets meet the matching rules and the content is correct, the health check result of the server is determined to be normal; If the cumulative received response data packets meet the matching rules but the content is incorrect, or if the response reception time reaches the preset reception time, the health check result of the server is determined to be abnormal.

7. The method according to claim 1, characterized in that, After determining the health check results of the server, the method further includes: Close the TCP connection between the load balancer and the server.

8. A server health check device, characterized in that, Applied to load balancing equipment, the device includes: The message sending module is used to send probe messages to the server through the TCP connection communication link between the load balancing device and the server to be checked according to the health check cycle, and start the response reception timer. The first analysis module is used to receive the first response data packet from the server, and analyze the first response data packet according to the matching rules to obtain the analysis result of the first response data packet; The second analysis module is used to continuously receive response data packets from the server if the analysis result of the first response data packet does not meet the matching rule, and analyze the accumulated received response data packets according to the matching rule until the accumulated received response data packets meet the matching rule or the response reception time reaches the preset reception time, and determine the health check result of the server.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the server health check method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the server health check method according to any one of claims 1 to 7.