CN111866074A - Method for detecting back-end server in load balancing system and load balancing system - Google Patents
Method for detecting back-end server in load balancing system and load balancing system Download PDFInfo
- Publication number
- CN111866074A CN111866074A CN202010544438.1A CN202010544438A CN111866074A CN 111866074 A CN111866074 A CN 111866074A CN 202010544438 A CN202010544438 A CN 202010544438A CN 111866074 A CN111866074 A CN 111866074A
- Authority
- CN
- China
- Prior art keywords
- end server
- data request
- load data
- load balancing
- server
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 70
- 230000004044 response Effects 0.000 claims abstract description 90
- 230000008569 process Effects 0.000 claims abstract description 20
- 230000007246 mechanism Effects 0.000 claims abstract description 12
- 230000002159 abnormal effect Effects 0.000 claims description 51
- 238000004590 computer program Methods 0.000 claims description 3
- 238000004891 communication Methods 0.000 description 18
- 238000010586 diagram Methods 0.000 description 17
- 238000001514 detection method Methods 0.000 description 14
- 238000012790 confirmation Methods 0.000 description 13
- 238000012545 processing Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 8
- 230000005540 biological transmission Effects 0.000 description 7
- 230000002829 reductive effect Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000005856 abnormality Effects 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000001902 propagating effect Effects 0.000 description 2
- 239000000523 sample Substances 0.000 description 2
- RYGMFSIKBFXOCR-UHFFFAOYSA-N Copper Chemical compound [Cu] RYGMFSIKBFXOCR-UHFFFAOYSA-N 0.000 description 1
- 229910052802 copper Inorganic materials 0.000 description 1
- 239000010949 copper Substances 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000000670 limiting effect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the disclosure discloses a method for detecting a back-end server in a load balancing system and the load balancing system, and relates to the field of cloud computing. The method comprises the following steps: establishing a TCP connection with a back-end server based on a handshake mechanism of a TCP protocol; in the process of establishing TCP connection, a preset load data request is carried in the last handshake signal sent to a back-end server; or after the TCP connection is successfully established, sending a preset load data request to the back-end server; if the correct response result of the back-end server to the load data request is received within the preset request timeout time, determining that the back-end server is in a normal state; and closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
Description
Technical Field
Embodiments of the present disclosure relate to communication technologies, and in particular, to a method for detecting a backend server in a load balancing system, a load balancing device, a load balancing system, and a computer-readable storage medium.
Background
Load Balance (Load Balance) is to Balance and distribute a Load (work task) to a plurality of operation units for operation, for example, ftp (file Transfer Protocol server), Web server, enterprise core application server, and other main task servers, so as to cooperatively complete the work task.
In the load balancing system, a plurality of back-end servers are connected through network equipment to form a server cluster, and each back-end server provides the same or similar network service. The load balancing equipment is responsible for distributing user requests in the server cluster according to the configured balancing strategy, providing services for users and maintaining the availability of the servers. If the back-end server in the server cluster is abnormal, the service is affected, and the service fault is caused. Therefore, it is necessary to detect the backend server in the load balancing system to remove the abnormal backend server in real time, so as to avoid the influence of the abnormal backend server on the service.
In the prior art, a three-way handshake mechanism based on a TCP (Transmission Control Protocol) Protocol is used to detect a backend server in a load balancing system, and this detection method can only determine whether the backend server is normal from connectivity, cannot detect an anomaly in an application layer of the backend server, and has a limited detection capability.
Disclosure of Invention
The embodiment of the present disclosure aims to provide a scheme for detecting a backend server in a load balancing system, so as to further probe an application program layer of the backend server on the basis of detecting connectivity between a load balancing device and the backend server, thereby improving the accuracy of detection.
According to a first aspect of embodiments of the present disclosure, there is provided a method for detecting a backend server in a load balancing system, which is applied to a load balancing device, and the method includes the following steps:
establishing a TCP connection with a back-end server based on a handshake mechanism of a TCP protocol;
in the process of establishing the TCP connection, a preset load data request is carried in a last handshake signal sent to the back-end server; or after the TCP connection is successfully established, sending a preset load data request to the back-end server;
if the correct response result of the back-end server to the load data request is received within the preset request timeout time, determining that the back-end server is in a normal state;
and closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
Optionally, the method further comprises:
If the response result of the back-end server to the load data request is not received within the preset request timeout time, determining that the load data request fails to respond;
and in the case of failed load data request response, re-sending the load data request to the back-end server.
Optionally, the method further comprises:
and under the condition that the frequency of the load data request response failure reaches a preset threshold value, determining that the back-end server is in an abnormal state.
Optionally, the method further comprises:
and if an error response result of the back-end server to the load data request is received, determining that the back-end server is in an abnormal state.
Optionally, the method further comprises:
removing the back-end server from the load balancing system if the back-end server is determined to be in an abnormal state.
According to a second aspect of the embodiments of the present disclosure, there is provided a load balancing device, including a connection establishing module, a load data request sending module, a determining module, and a connection closing module;
the connection establishing module is used for establishing TCP connection with a back-end server based on a handshake mechanism of a TCP protocol;
A load data request sending module, configured to carry a preset load data request in a last handshake signal sent to the back-end server in a process of establishing the TCP connection; or after the TCP connection is successfully established, sending a preset load data request to the back-end server;
the determining module is used for determining that the back-end server is in a normal state if a correct response result of the back-end server to the load data request is received within a preset request timeout period;
and the connection closing module is used for closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
Optionally, the determining module is further configured to determine that the load data request fails to respond if a response result of the back-end server to the load data request is not received within a preset request timeout period;
the load data request sending module is further configured to resend the load data request to the backend server when the load data request response fails.
Optionally, the determining module is further configured to determine that the back-end server is in an abnormal state when the number of times of response failure of the load data request reaches a preset threshold.
Optionally, the determining module is further configured to determine that the backend server is in an abnormal state if a response result of the backend server to the error of the load data request is received.
Optionally, the method further comprises: the module is removed and the module is removed,
the removing module is used for removing the back-end server from the load balancing system under the condition that the back-end server is determined to be in an abnormal state.
According to a third aspect of embodiments of the present disclosure, there is provided a load balancing apparatus, including a processor and a memory, where the memory stores computer instructions, and the computer instructions, when executed by the processor, perform a method for detecting a backend server in a load balancing system according to any one of the foregoing descriptions.
According to a fourth aspect of embodiments of the present disclosure, there is provided a load balancing system comprising a back-end server and a load balancing device as described in any one of the preceding claims.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, perform the method for detecting a backend server in a load balancing system according to any one of the preceding claims.
According to the method for detecting the back-end server in the load balancing system, on the basis of detecting the connectivity between the load balancing device and the back-end server, the application program layer of the back-end server is further detected, so that the back-end server with the abnormal application program layer is found, and the detection accuracy is improved.
Features of embodiments of the present disclosure and advantages thereof will become apparent from the following detailed description of exemplary embodiments thereof, which is to be read in connection with the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the disclosure and together with the description, serve to explain the principles of the embodiments of the disclosure.
FIG. 1 is a block diagram of the architecture of a load balancing system of an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure;
fig. 3 is a flowchart illustrating a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure;
fig. 4 is a flowchart illustrating a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure;
fig. 5 is a flowchart illustrating a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure;
Fig. 6 is a block diagram of a structure of a load balancing apparatus according to an embodiment of the present disclosure;
FIG. 7 is a block diagram of another configuration of a load balancing apparatus according to an embodiment of the present disclosure;
fig. 8 is a block diagram of the structure of a load balancing system according to an embodiment of the present disclosure.
Detailed Description
Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of parts and steps, numerical expressions, and numerical values set forth in these embodiments do not limit the scope of the embodiments of the present disclosure unless specifically stated otherwise.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the embodiments of the disclosure, their application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
< hardware configuration >
Fig. 1 is a block diagram of a load balancing system according to an embodiment of the present disclosure. As shown in fig. 1, the load balancing system includes a load balancing device 101 and a backend server 103, where the load balancing device 101 may be configured to detect whether the backend server 103 is normal or not, and dispatch task requests sent by devices at a user end to the plurality of backend servers 103. The backend server 103 may communicate with the load balancing device 101 through a network 102, which network 102 may be a wireless network.
Specific configurations of the load balancing device 101 may include, but are not limited to: processor 1011, memory 1012, interface 1013, communication device 1014, input device 1015, output device 1016. The processor 1011 may include, but is not limited to, a central processing unit CPU, a microprocessor MCU, or the like. The memory 1012 may include, but is not limited to, a ROM (read only memory), a RAM (random access memory), a nonvolatile memory such as a hard disk, and the like. Interface device 1013 may include, but is not limited to, a USB interface, a serial interface, a parallel interface, and the like. The communication device 1014 is capable of wired or wireless communication, for example, and may specifically include WiFi communication, bluetooth communication, 2G/3G/4G/5G communication, and the like. Input devices 1015 may include, but are not limited to, a keyboard, a mouse, a touch screen, and the like. Output device 1016 may include, but is not limited to, a display screen or the like. Although the load balancing device may also include a speaker, a microphone, and the like, these components are not relevant to the embodiments of the present disclosure and are omitted herein.
The backend server 103 may be in the form of a blade server, a rack server, or the like, or may be a server cluster deployed in the cloud. In some embodiments, each server may include hardware, software, or embedded logic components or a combination of two or more such components for performing the appropriate functions supported or implemented by the server. The load balancing device 101 may also be a computer.
Specific configurations of the backend server 103 may include, but are not limited to: processor 1031, memory 1032, interface device 1033, communication device 1034, input device 1035, and output device 1036. The processor 1031 may include, but is not limited to, a central processing unit CPU, a microprocessor MCU, and the like. The memory 1032 may include, but is not limited to, a ROM (read only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, and the like. Interface device 1033 may include, but is not limited to, a USB interface, a serial interface, a parallel interface, and the like. The communication device 1034 is capable of wired or wireless communication, for example, and specifically may include WiFi communication, bluetooth communication, 2G/3G/4G/5G communication, and the like. Input devices 1035 may include, but are not limited to, a keyboard, a mouse, a touch screen, and the like. Output devices 1036 include, but are not limited to, a display screen, or the like. Although the server may also include speakers, microphones, and the like, these components are not relevant to the embodiments of the present disclosure and are omitted herein.
In the embodiment of the present disclosure, the backend server 103 may interact with the load balancing device 101 to process the task request distributed by the load balancing device 101. The memory 1012 of the load balancing apparatus 101 is used to store instructions for controlling the processor 1011 to operate to execute the method for detecting the backend server in the load balancing system according to any one of the embodiments of the present disclosure.
The load balancing system shown in fig. 1 is merely illustrative and is in no way intended to suggest any limitation as to the embodiments of the disclosure, their application, or uses. It will be appreciated by those skilled in the art that although a number of arrangements of load balancing apparatus and back-end servers have been described above, embodiments of the present disclosure may relate to only some of these arrangements. For example, the load balancing apparatus may relate only to the processor, the memory, and the communication device, and the backend server may relate only to the processor, the memory, and the communication device.
Those skilled in the art can design instructions according to the scheme disclosed in the embodiment of the present disclosure, and how the instructions control the processor to operate is well known in the art, and will not be described in detail herein.
< method examples >
In the load balancing system, a plurality of back-end servers are connected through network equipment to form a server cluster, and each back-end server provides the same or similar network service. The load balancing equipment is responsible for distributing user requests in the server cluster according to the configured balancing strategy, providing services for users and maintaining the availability of the servers. If the back-end server in the server cluster is abnormal, the service is affected, and the service fault is caused. In order to solve the problem that an abnormal back-end server affects the service, the back-end server in the load balancing system needs to be detected.
For the above problems, in the prior art, a handshake mechanism based on a TCP protocol detects a backend server in a load balancing system, and this method can only determine whether the backend server is normally connected to the load balancing device from connectivity, and cannot detect an anomaly at an application layer of the backend server, so that the detection capability is limited. According to the method for detecting the back-end server in the load balancing system, on the basis of detecting the connectivity between the load balancing device and the back-end server, the application program layer of the back-end server is further detected, so that the back-end server with the abnormal application program layer is found, and the detection accuracy is improved.
Please refer to fig. 2, which is a flowchart illustrating a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure. The method for detecting a backend server in a load balancing system provided by the embodiment is implemented by a computer technology. The method for detecting the backend server in the load balancing system may be implemented by a load balancing device, which may be, for example, the load balancing device 101 shown in fig. 1.
As shown in fig. 2, a method for detecting a backend server in a load balancing system according to an embodiment of the present disclosure includes steps S202 to S206.
Step S202, establishing a TCP connection with a back-end server based on a handshaking mechanism of a TCP protocol.
TCP is a connection-oriented, reliable, byte-stream based transport-layer communication protocol. The establishment of the TCP connection requires a three-way handshake, which prevents the generation of a wrong connection.
Taking the TCP three-way handshake mechanism as an example, the process of the load balancing device to establish a TCP connection with the backend server may include steps S302-S306.
Step S302, the load balancing device creates a keep-alive socket, and sends a Synchronization (SYN) packet to the backend server.
And establishing a keep-alive socket between a transmission layer of the load balancing equipment and an application layer of the back-end server, and executing interactive operation between the load balancing equipment and the back-end server in a socket mode.
When the load balancing device establishes a TCP connection with the backend server, the synchronization packet may indicate that the load balancing device is ready to establish a connection. In the sync packet, when the identification position of the sync packet is 1, it indicates that it is a connection request segment.
Step S304, the load balancing device receives a synchronization acknowledgement (SYN, ACK) packet sent by the back-end server.
After receiving the synchronization packet sent by the load balancing device, the back-end server correspondingly feeds back an acknowledgement packet, and can judge whether the back-end server agrees to establish the TCP connection according to the identification position of the acknowledgement packet. For example, when the identification position of the synchronization packet in the synchronization acknowledgement packet of the response is 1 and the identification position of the acknowledgement packet is 1, it is considered that the backend server agrees to establish the connection. And under the condition that the identification position of the synchronization packet in the response synchronization confirmation packet is 1 and the identification position of the confirmation packet is 0, the back-end server is considered not to agree to establish the connection.
Step S306, sending an Acknowledgement (ACK) packet to the back-end server when the synchronization acknowledgement packet returned by the back-end server is valid.
And under the condition that the identification position of the synchronization packet in the responded synchronization confirmation packet is 1 and the identification position of the confirmation packet is 1, determining that the returned synchronization confirmation packet is valid, and considering that the back-end server agrees to establish connection with the load balancing equipment. At this time, the load balancing device returns an acknowledgement packet to the backend server again, indicating that the load balancing device establishes a TCP connection with the backend server. And under the condition that the synchronization confirmation packet returned by the back-end server is invalid, indicating that the load balancing equipment fails to establish TCP connection with the back-end server.
In this embodiment, by simulating a three-way handshake flow between the load balancing device and the backend server, it can be determined whether the load balancing device and the backend server successfully establish a communication connection, so that whether the backend server is in a normal state can be detected from connectivity.
According to the embodiment of the disclosure, whether the load balancing device and the back-end server successfully establish communication connection can be determined by simulating the three-way handshake process of the load balancing device and the back-end server, so that whether the back-end server is in a normal state can be detected from connectivity, the back-end server in an abnormal state in the load balancing system can be detected, and the influence of the back-end server in the abnormal state on services can be avoided.
Step S204, in the process of establishing TCP connection, a preset load data request is carried in the last handshake signal sent to the back-end server; or after the TCP connection is successfully established, sending a preset load data request to the back-end server.
The load balancing device may determine whether the back-end server is in a normal state according to a time when the back-end server responds to the load data request and a response result of the back-end server to the load request data. And under the condition that the time of the back-end server responding to the load data request is within the preset request timeout time and the response result of the back-end server to the load request data is correct, determining that the back-end server is in a normal state.
The load data request is a data request customized by a user, and the load data request may be adaptively modified according to service content in charge of the backend server, which is not limited in this embodiment of the present disclosure. The load data request may be used to probe an application layer of the backend server, and the application layer of the backend server responds to the load data request and returns a response result to the load balancing device. And judging whether the application program layer of the back-end server is normal or not according to a response result returned by the back-end server.
In one embodiment, after the load balancing device receives the synchronization acknowledgement packet sent by the back-end server, the load balancing device sends an acknowledgement packet with a preset load data request to the back-end server.
In one embodiment, after the load balancing device successfully establishes the TCP connection with the backend server, the load balancing device sends a preset load data request to the backend server.
Step S206, if the correct response result of the back-end server to the load data request is received within the preset request timeout time, the back-end server is determined to be in a normal state.
In one embodiment, the time at which the back-end server responds to the load data request may be recorded by starting a timer. That is, when the load balancing device sends a load data request to the back-end server, the time of the back-end server responding to the load data request is counted by starting the timer, so as to determine whether the time of the back-end server responding to the load data request meets the requirement. The preset request timeout time may be at least the time that the backend server can accept the load data request, but is not limited thereto, and may also be adaptively modified according to the different acceptance degrees of each user, and the embodiment of the present disclosure is not limited thereto.
In one embodiment, whether the response result of the back-end server to the load data request is correct or not may be determined by comparing the response result of the back-end server with a preset expected result. Under the condition that the response result of the back-end server is consistent with a preset expected result, the back-end server is considered to obtain a correct response result in response to the load data request; and under the condition that the response result of the back-end server is inconsistent with the preset expected result, the back-end server is considered to obtain an error response result in response to the load data request. The preset expected result is a result of an expected response of the backend server to the load data request.
For example, the load balancing device sends a load data request of a news web page link to the back-end server, and if the back-end server responds to the news web page link within 100ms of the request timeout time to acquire a corresponding news web page, the load balancing device receives a correct response result of the back-end server to the load data request within the preset request timeout time.
And step S208, closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
And under the condition that the back-end server is detected to be in a normal state, closing the TCP connection so as to disconnect the load balancing equipment from the back-end server, thereby reducing the load of the back-end server and avoiding unnecessary resource waste.
In one embodiment, the load balancing device sends a Reset (RST) packet to the back-end server, which is used to force the TCP connection to close to free up the resources of the back-end server.
In one embodiment, the disconnection of the TCP connection needs to go through a four-way handshake, and this way of disconnection can avoid data transmission errors, so as to prevent the problem that the TCP connection cannot be normally closed and resources are continuously occupied.
Taking the TCP four-way handshake mechanism as an example, the process of the load balancing device disconnecting the TCP connection with the backend server may include steps S402-S408.
Step S402, the load balancing apparatus sends a termination (FIN) packet to the backend server. The termination packet may indicate that the task is completed and requires the disconnection.
Step S404, after receiving the termination packet sent by the load balancing device, the back-end server returns a confirmation packet to the load balancing device.
Step S406, after the load balancing device receives the acknowledgement packet returned by the back-end server, the back-end server sends a termination packet to the load balancing device.
Step S408, after receiving the termination packet returned by the back-end server, the load balancing device returns a confirmation packet to the back-end server again. Indicating that the load balancing equipment disconnects the TCP from the back-end server.
In one embodiment, in the process of establishing the TCP connection, a preset load data request is carried in the last handshake signal sent to the backend server; or, after the TCP connection is successfully established, sending a preset load data request to the back-end server, and then, the method for detecting the back-end server in the load balancing system may further include: steps S502-S504.
Step S502, if the response result of the back-end server to the load data request is not received within the preset request timeout time, determining that the response of the load data request fails.
Step S504 is to resend the load data request to the backend server if the load data request response fails.
In one embodiment, the time at which the back-end server responds to the load data request may be recorded by starting a timer. That is, when the load balancing device sends a load data request to the back-end server, the time of the back-end server responding to the load data request is counted by starting a timer, so that corresponding processing is performed when the time of the back-end server responding to the load data request exceeds a preset request timeout time.
The preset request timeout time may be at least the time that the backend server can accept the load data request, but is not limited thereto, and may also be adaptively modified according to the different acceptance degrees of each user, and the embodiment of the present disclosure is not limited thereto.
According to the embodiment of the disclosure, in the preset request timeout period, the response result of the back-end server to the load data request is not received, which indicates that the response of the load data request fails, and the load data request may be sent to the back-end server again for re-detection. Therefore, the feedback delay of the response result caused by other factors can be avoided, the back-end server is mistaken for the abnormality, and the false detection rate can be reduced.
In an embodiment, in the case of failure of load data request response, the method for detecting a backend server in the load balancing system may further include: step S602.
Step S602, determining that the back-end server is in an abnormal state when the number of times of load data request response failures reaches a preset threshold.
Specifically, the failure of the load data request response may be that no response result of the backend server to the load data request is received within a preset request timeout time.
The preset threshold is an upper limit of the number of times the load balancing device is allowed to send load data requests to the back-end server. The preset threshold may be set according to engineering experience, and the embodiment of the disclosure is not limited thereto.
According to the embodiment of the disclosure, the load balancing device may determine whether the back-end server is in a normal state according to the number of times of failure of response of the load data request. And under the condition that the frequency of load data request response failure reaches a preset threshold value, determining that the back-end server is in an abnormal state. Therefore, the failure of load data request response caused by other factors can be avoided, the phenomenon that the back-end server is abnormal is mistaken, and the false detection rate can be reduced.
In one embodiment, in the process of establishing the TCP connection, a preset load data request is carried in the last handshake signal sent to the backend server; or, after the TCP connection is successfully established, sending a preset load data request to the back-end server, and then, the method for detecting the back-end server in the load balancing system may further include: step S702.
Step S702, if the wrong response result of the back-end server to the load data request is received, the back-end server is determined to be in an abnormal state.
The load balancing device may determine whether the back-end server is in an abnormal state according to a time when the back-end server responds to the load data request and a response result of the back-end server to the load request data. And determining that the back-end server is in an abnormal state under the conditions that the time of the back-end server responding to the load data request is within the preset request timeout time and the response result of the back-end server to the load request data is wrong.
In one embodiment, whether the response result of the back-end server to the load data request is correct or not may be determined by comparing the response result of the back-end server with a preset expected result. Under the condition that the response result of the back-end server is consistent with a preset expected result, the back-end server is considered to obtain a correct response result in response to the load data request; and under the condition that the response result of the back-end server is inconsistent with the preset expected result, the back-end server is considered to obtain an error response result in response to the load data request. The preset expected result is a result of an expected response of the backend server to the load data request.
For example, the load balancing device sends a load data request of a news web page link to the back-end server, and if a web page error obtained by the back-end server in response to the load data request indicates that the load balancing device receives an error response result of the back-end server to the load data request within a preset request timeout period.
According to the embodiment of the disclosure, under the condition that the wrong response result of the back-end server to the load data request is received, the back-end server is determined to be in an abnormal state, so that the load balancing equipment can remove the abnormal back-end server in time, and the influence of the abnormal back-end server on the service is avoided.
In an embodiment, in a case that it is determined that the backend server is in an abnormal state, the method for detecting the backend server in the load balancing system may further include: step S802.
And S802, removing the back-end server from the load balancing system under the condition that the back-end server is determined to be in an abnormal state.
The back-end server in the load balancing system is abnormal, which affects the service and causes service failure. And under the condition that the back-end server is determined to be abnormal, the abnormal back-end server is removed immediately, so that the influence of the abnormal back-end server on the service is avoided.
< example one >
Taking the example that the last handshake signal sent to the backend server carries the preset load data request in the process of establishing the TCP connection, the method for detecting the backend server in the load balancing system, as shown in fig. 3, may include steps S3020 to S3120.
Step S3020, the load balancing device creates a keep-alive socket and sends a synchronization packet to the backend server.
Step S3040, the back-end server sends a synchronization acknowledgement packet back to the load balancing device.
Step S3060, when the synchronization confirmation packet returned by the backend server is valid, a confirmation packet with a load data request is returned to the backend server.
And step S3080, if the request is within the preset request timeout time, receiving a response result of the back-end server to the load data request.
And step S3100, determining whether the back-end server is in a normal state or not according to a response result of the back-end server to the load data request.
And S3120, when the back-end server is in normal state, sending reset packet to the back-end server, and closing TCP connection.
< example two >
Taking the example of sending a preset load data request to the backend server after the TCP connection is successfully established, the method for detecting the backend server in the load balancing system, as shown in fig. 4, may include steps S4020 to S4140.
Step S4020, the load balancing device creates a keep-alive socket and sends a synchronization packet to the backend server.
Step S4040, the back-end server returns a synchronization confirmation packet to the load balancing device.
In step S4060, when the synchronization confirmation packet returned from the back-end server is valid, a return confirmation packet is sent to the back-end server.
Step S4080, the load balancing device sends a preset load data request to the backend server.
Step S4100, if the request is within the preset request timeout period, receiving a response result of the back-end server to the load data request.
Step S4120, determining whether the back-end server is in a normal state according to a response result of the back-end server to the load data request.
Step S4140, in the case where the back-end server is in a normal state, sends a reset packet to the back-end server, and closes the TCP connection.
< example III >
The method for detecting a backend server in the load balancing system, as shown in fig. 5, may include steps S5020-S5220.
Step S5020, a handshake mechanism based on a TCP protocol establishes TCP connection with a back-end server.
Step S5040, sending a predetermined load data request to the backend server.
Step S5060, determining whether a response result of the back-end server to the load data request is received within a preset time; if yes, go to step S5080; otherwise, the process advances to step S5140.
Step S5080, determining whether the received response result is a correct response result; if yes, go to step S5100; otherwise, the process advances to step S5200.
Step S5100, determining that the back-end server is in a normal state.
Step S5120, close the TCP connection.
Step S5140, determining that the load data request response fails.
Step S5160, determining whether the number of times of load data request response failures reaches a preset threshold; if yes, go to step S5200; otherwise, the process advances to step S5180.
In step S5180, the load data request is retransmitted to the backend server, and the process returns to step S5060.
Step S5200, determining that the back-end server is in an abnormal state.
And step S5220, removing the back-end server from the load balancing system.
According to the method for detecting the back-end server in the load balancing system, under the condition that the load balancing device establishes TCP connection with the back-end server, the load balancing device sends a load data request to the back-end server, whether the back-end server is normal or not can be judged according to the response result of the back-end server to the load data request, on the basis of detecting the connectivity of the load balancing device and the back-end server, the application program layer of the back-end server is further detected, the back-end server with the abnormal application program layer is further found, and the detection accuracy is improved.
< first embodiment of the apparatus >
Referring to fig. 6, in an embodiment of the present disclosure, a load balancing device 60 is further provided, where the load balancing device 60 may be configured to detect whether a backend server is normal, and dispatch a task request sent by a device at a user end to a plurality of backend servers. As shown in fig. 6, which is a block diagram of a load balancing apparatus 60 according to an embodiment of the present disclosure, the load balancing apparatus 60 may include a connection establishing module 61, a load data request sending module 62, a determining module 63, and a connection closing module 64.
The establish connection module 61 may be configured to establish a TCP connection with the backend server based on a handshake mechanism of a TCP protocol.
The load data request sending module 62 may be configured to carry a preset load data request in a last handshake signal sent to the backend server in the process of establishing the TCP connection.
The load data request sending module 62 may also be configured to send a preset load data request to the backend server after the TCP connection is successfully established.
The determining module 63 may be configured to determine that the backend server is in a normal state if a correct response result of the backend server to the load data request is received within a preset request timeout period.
The close connection module 64 may be configured to close the TCP connection when the backend server is in a normal state.
The load balancing device provided by the embodiment of the disclosure further detects the application program layer of the back-end server on the basis of detecting the connectivity between the load balancing device and the back-end server, so as to find the back-end server with the abnormal application program layer and improve the detection accuracy.
In one embodiment, the determining module 63 may be further configured to determine that the load data request response fails if a response result of the backend server to the load data request is not received within a preset request timeout time.
The load data request sending module 62 may also be configured to resend the load data request to the back-end server in case of a failure in the load data request response.
According to the embodiment of the disclosure, in the preset request timeout period, the response result of the back-end server to the load data request is not received, which indicates that the response of the load data request fails, and the load data request may be sent to the back-end server again for re-detection. Therefore, the feedback delay of the response result caused by other factors can be avoided, the back-end server is mistaken for the abnormality, and the false detection rate can be reduced.
In one embodiment, the determining module 63 may be further configured to determine that the backend server is in an abnormal state when the number of times of load data request response failures reaches a preset threshold.
According to the embodiment of the disclosure, the load balancing device may determine whether the back-end server is in a normal state according to the number of times of failure of response of the load data request. And under the condition that the frequency of load data request response failure reaches a preset threshold value, determining that the back-end server is in an abnormal state. Therefore, the failure of load data request response caused by other factors can be avoided, the phenomenon that the back-end server is abnormal is mistaken, and the false detection rate can be reduced.
In one embodiment, the determining module 63 may be further configured to determine that the backend server is in an abnormal state if an erroneous response result of the backend server to the load data request is received.
According to the embodiment of the disclosure, under the condition that the wrong response result of the back-end server to the load data request is received, the back-end server is determined to be in an abnormal state, so that the load balancing equipment can remove the abnormal back-end server in time, and the influence of the abnormal back-end server on the service is avoided.
In one embodiment, the load balancing apparatus 60 further comprises a removal module 65.
The removal module 65 may be configured to remove the back-end server from the load balancing system if the back-end server is determined to be in an abnormal state.
According to the embodiment of the disclosure, the back-end server in the load balancing system is abnormal, which affects the service and causes service failure. And under the condition that the back-end server is determined to be abnormal, the abnormal back-end server is removed immediately, so that the influence of the abnormal back-end server on the service is avoided.
< example II of the apparatus >
Referring to fig. 7, an embodiment of the present disclosure further provides a load balancing device 70, where the load balancing device 70 may be configured to detect whether the backend servers are normal, and dispatch task requests sent by the device at the user end to a plurality of backend servers. As shown in fig. 7, which is a block diagram of a load balancing apparatus 70 according to an embodiment of the present disclosure, the load balancing apparatus 70 may include a processor 71 and a memory 72.
The memory 72 is used for storing a computer program, and the computer program is executed by the processor 71 to implement the method for detecting the backend server in the load balancing system disclosed in any of the foregoing embodiments.
< third apparatus example >
Referring to fig. 8, an embodiment of the present disclosure also provides a load balancing system 80, which includes a load balancing device 81 and a plurality of backend servers 82. The load balancing device 81 may be used to detect whether the backend servers 82 are normal, and to dispatch task requests sent by devices on the user side to the plurality of backend servers 82. The back-end server 82 may interact with the load balancing device 81 to process task requests distributed by the load balancing device 81. The load balancing system 80 may be a load balancing system as shown in fig. 1.
In one embodiment, the load balancing device 81 may be the load balancing device 60 shown in fig. 6 or the load balancing device 70 shown in fig. 7.
< computer-readable storage Medium >
Embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, perform the method for detecting a backend server in a load balancing system according to any one of the foregoing embodiments.
Embodiments of the present disclosure may be systems, devices, methods, and/or computer instruction products. The computer instruction product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of embodiments of the disclosure.
The computer readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a Static Random Access Memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, a mechanical coding device, such as punch cards or in-groove projection structures having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or electrical signals transmitted through electrical wires.
The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or to an external computer or external storage device via a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in the respective computing/processing device.
The computer instruction instructions for carrying out operations for embodiments of the present disclosure may be assembly instructions, Instruction Set Architecture (ISA) instructions, machine related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, the electronic circuitry may execute computer-readable program instructions to implement aspects of embodiments of the present disclosure by utilizing state information of the computer-readable program instructions to personalize the electronic circuitry, such as a programmable logic circuit, a Field Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA).
Aspects of embodiments of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer instruction products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, devices, methods and computer instruction products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, by software, and by a combination of software and hardware are equivalent.
Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope of the described embodiments. The terminology used herein is chosen in order to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Claims (13)
1. A method for detecting a back-end server in a load balancing system is applied to a load balancing device, and the method comprises the following steps:
establishing a TCP connection with a back-end server based on a handshake mechanism of a TCP protocol;
in the process of establishing the TCP connection, a preset load data request is carried in a last handshake signal sent to the back-end server; or after the TCP connection is successfully established, sending a preset load data request to the back-end server;
if the correct response result of the back-end server to the load data request is received within the preset request timeout time, determining that the back-end server is in a normal state;
And closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
2. The method of claim 1, further comprising:
if the response result of the back-end server to the load data request is not received within the preset request timeout time, determining that the load data request fails to respond;
and in the case of failed load data request response, re-sending the load data request to the back-end server.
3. The method of claim 2, further comprising:
and under the condition that the frequency of the load data request response failure reaches a preset threshold value, determining that the back-end server is in an abnormal state.
4. The method of claim 1, further comprising:
and if an error response result of the back-end server to the load data request is received, determining that the back-end server is in an abnormal state.
5. The method of claim 1, further comprising:
removing the back-end server from the load balancing system if the back-end server is determined to be in an abnormal state.
6. A load balancing device is characterized by comprising a connection establishing module, a load data request sending module, a determining module and a connection closing module;
The connection establishing module is used for establishing TCP connection with a back-end server based on a handshake mechanism of a TCP protocol;
a load data request sending module, configured to carry a preset load data request in a last handshake signal sent to the back-end server in a process of establishing the TCP connection; or after the TCP connection is successfully established, sending a preset load data request to the back-end server;
the determining module is used for determining that the back-end server is in a normal state if a correct response result of the back-end server to the load data request is received within a preset request timeout period;
and the connection closing module is used for closing the TCP connection under the condition that the back-end server is determined to be in a normal state.
7. The device according to claim 6, wherein the determining module is further configured to determine that the load data request response fails if a response result of the backend server to the load data request is not received within a preset request timeout period;
the load data request sending module is further configured to resend the load data request to the backend server when the load data request response fails.
8. The device of claim 7, wherein the determining module is further configured to determine that the backend server is in an abnormal state when the number of times of load data request response failures reaches a preset threshold.
9. The apparatus of claim 6, the determining module further configured to determine that the backend server is in an abnormal state if an erroneous response result of the backend server to the load data request is received.
10. The apparatus of claim 6, further comprising: the module is removed and the module is removed,
the removing module is used for removing the back-end server from the load balancing system under the condition that the back-end server is determined to be in an abnormal state.
11. A load balancing device comprising a processor and a memory for storing a computer program which, when executed by the processor, implements the method of any one of claims 1 to 5.
12. A load balancing system comprising a back-end server and a load balancing device according to any one of claims 6 to 10.
13. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, perform the method of any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010544438.1A CN111866074A (en) | 2020-06-15 | 2020-06-15 | Method for detecting back-end server in load balancing system and load balancing system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010544438.1A CN111866074A (en) | 2020-06-15 | 2020-06-15 | Method for detecting back-end server in load balancing system and load balancing system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111866074A true CN111866074A (en) | 2020-10-30 |
Family
ID=72987388
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010544438.1A Pending CN111866074A (en) | 2020-06-15 | 2020-06-15 | Method for detecting back-end server in load balancing system and load balancing system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111866074A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114615310A (en) * | 2022-03-01 | 2022-06-10 | 天翼安全科技有限公司 | Method and device for maintaining TCP connection and electronic equipment |
CN115134227A (en) * | 2022-06-17 | 2022-09-30 | 京东科技信息技术有限公司 | Method and apparatus for maintaining server |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103139247A (en) * | 2011-11-28 | 2013-06-05 | 百度在线网络技术(北京)有限公司 | Keep-alive method, system and device for rear-end server in load balancing system |
CN105939201A (en) * | 2015-07-13 | 2016-09-14 | 杭州迪普科技有限公司 | Method and device for checking state of server |
CN106254542A (en) * | 2016-09-27 | 2016-12-21 | 杭州迪普科技有限公司 | The method and device that a kind of flowing of access controls |
CN107181636A (en) * | 2016-03-10 | 2017-09-19 | 阿里巴巴集团控股有限公司 | Health examination method and device in a kind of SiteServer LBS |
CN109274707A (en) * | 2017-07-18 | 2019-01-25 | 阿里巴巴集团控股有限公司 | A kind of load dispatching method and device |
CN109660626A (en) * | 2018-12-29 | 2019-04-19 | 天翼电子商务有限公司 | A kind of load-balancing method, system and load balancing monitoring client |
-
2020
- 2020-06-15 CN CN202010544438.1A patent/CN111866074A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103139247A (en) * | 2011-11-28 | 2013-06-05 | 百度在线网络技术(北京)有限公司 | Keep-alive method, system and device for rear-end server in load balancing system |
CN105939201A (en) * | 2015-07-13 | 2016-09-14 | 杭州迪普科技有限公司 | Method and device for checking state of server |
CN107181636A (en) * | 2016-03-10 | 2017-09-19 | 阿里巴巴集团控股有限公司 | Health examination method and device in a kind of SiteServer LBS |
CN106254542A (en) * | 2016-09-27 | 2016-12-21 | 杭州迪普科技有限公司 | The method and device that a kind of flowing of access controls |
CN109274707A (en) * | 2017-07-18 | 2019-01-25 | 阿里巴巴集团控股有限公司 | A kind of load dispatching method and device |
CN109660626A (en) * | 2018-12-29 | 2019-04-19 | 天翼电子商务有限公司 | A kind of load-balancing method, system and load balancing monitoring client |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114615310A (en) * | 2022-03-01 | 2022-06-10 | 天翼安全科技有限公司 | Method and device for maintaining TCP connection and electronic equipment |
CN115134227A (en) * | 2022-06-17 | 2022-09-30 | 京东科技信息技术有限公司 | Method and apparatus for maintaining server |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104601799A (en) | Data transmission method and mobile terminal | |
EP3490304B1 (en) | Method for identifying access point and hotspot, and related products | |
KR20190030367A (en) | Electronic device for processing a message and operating method thereof | |
WO2018040877A1 (en) | Recovery method and system for password keyboard usb communication abnormality | |
KR102558475B1 (en) | Method for network state identification and electronic device thereof | |
CN106897095A (en) | The multiple method of application program hot repair, device and readable storage medium storing program for executing | |
CN111866074A (en) | Method for detecting back-end server in load balancing system and load balancing system | |
CN110247897B (en) | System login method, device, gateway and computer readable storage medium | |
CN111866083A (en) | Equipment debugging system and method, equipment to be debugged, remote debugging equipment and transfer server | |
CN105549995B (en) | Audio equipment upgrading method and device | |
US20090319699A1 (en) | Preventing Loss of Access to a Storage System During a Concurrent Code Load | |
CN111031576A (en) | Upgrading method of TWS wireless earphone and wireless audio equipment | |
CN111131409A (en) | Request responding method, device and related equipment | |
CN108289165B (en) | Method and device for realizing camera control based on mobile phone and terminal equipment | |
CN114172946B (en) | Request result sending method, device, electronic equipment and computer readable medium | |
CN110995780A (en) | API calling method and device, storage medium and electronic equipment | |
CN113535020B (en) | Method, apparatus, device, medium and product for generating application icons | |
CN104717680A (en) | Wireless connection test method and device | |
KR101680736B1 (en) | Process for checking status of network device | |
CN115103005A (en) | Request response method and device, electronic equipment and storage medium | |
CN103329155A (en) | Relay device, ATM system, information relay method, and program | |
CN114257632A (en) | Disconnection reconnection method and device, electronic equipment and readable storage medium | |
CN114553676A (en) | Message processing method, platform, electronic equipment and storage medium | |
CN108111431A (en) | Business datum sending method and device | |
CN117294745B (en) | Network connection state information sending method, device, electronic equipment and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201030 |
|
RJ01 | Rejection of invention patent application after publication |