A link switching method, apparatus, electronic device and storage medium
By implementing the link switching method in the load balancing device, clearing the old connection of the abnormal link and switching to the normal link, the problem of traffic failure caused by the failure of abnormal link connection is solved, and normal traffic transmission and stable service operation is achieved.
Patent Information
- Application Number
- CN202211718509.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In the prior art, the connection on the abnormal link does not age, resulting in the same request still selecting the exception link to schedule traffic, resulting in the problem that the traffic cannot be sent.
Provide a link switching method, by receiving traffic to be sent, determine whether the old connection is hit, if it hits, determine whether the link corresponding to the old connection is abnormal, if it is abnormal, clear the old connection and switch the link to establish a new connection.
It solves the problem of traffic being unable to send due to the failure of connections on abnormal links. By quickly switching to the normal link, it ensures that traffic can be sent normally, reducing the service outage caused by old connections of load devices.
Smart Images

Figure CN116156572B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication technologies, and in particular, to a link switching method, apparatus, electronic device, and storage medium. Background Art
[0002] In order to avoid the network availability risk caused by operator network failures and solve the network access problems caused by insufficient network bandwidth, enterprises often lease multiple operator networks (such as Telecom, Netcom, etc.) and use professional load balancing devices to perform load balancing among multiple links through link load balancing technology, and reasonably utilize the network resources of multiple operators. The routing basis of link load balancing technology is algorithms and link status, and abnormal links will not participate in routing, which can ensure the stability of the link to a certain extent.
[0003] Although the link status in the link load routing stage can be determined through health checks, even if a link is determined to be abnormal, since the connections on the abnormal link need aging time to age, the abnormal link will still be hit by traffic during the aging time, and at this time, the situation where traffic cannot be sent will inevitably occur. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a link switching method, apparatus, electronic device, and storage medium. If a link is abnormal, it will be switched to a normal link, solving the problem that the same request still selects the abnormal link to schedule traffic due to the non-aging of the connections on the abnormal link, resulting in the inability to send traffic.
[0005] The embodiments of this application provide a link switching method, which is applied to a load balancing device. The method includes:
[0006] Receiving traffic to be sent;
[0007] Determining whether the traffic to be sent hits an old connection;
[0008] If so, determining whether the link corresponding to the old connection is abnormal;
[0009] If it is abnormal, clearing the old connection and switching the link to establish a new connection.
[0010] In the above implementation process, deleting the old connection makes the traffic scheduling no longer affected by the old connection; and quickly switching to the normal link, thereby reducing the situation where the load device still schedules traffic to the abnormal link due to the old connection, resulting in service interruption, and solving the problem that the same request still selects the abnormal link to schedule traffic due to the non-aging of the connections on the abnormal link, resulting in the inability to send traffic.
[0011] Further, after the step of determining whether the link corresponding to the old connection is abnormal, the method further includes:
[0012] If the link corresponding to the old connection is normal, send the traffic to be sent through the old connection.
[0013] In the above implementation process, if the link where the old connection is located is normal, the old connection can continue to be used for sending, without the need to re-select a link, improving the processing efficiency.
[0014] Further, clearing the old connection and switching the link to establish a new connection includes:
[0015] Re-select an outbound link in a normal state;
[0016] Create a new connection based on the outbound link;
[0017] Send the traffic to be sent through the new connection.
[0018] In the above implementation process, if the old connection is abnormal, re-select the outbound link, establish a new connection, and through fast link switching, the traffic scheduling is no longer affected by the old connection.
[0019] Further, creating a new connection based on the outbound link includes:
[0020] Mark the outbound link information in the new connection.
[0021] In the above implementation process, marking the outbound link information on the new connection, that is, which link the new connection specifically goes out from, is convenient for subsequent use in handling abnormal old connections.
[0022] Further, after the step of determining whether the traffic to be sent hits the old connection, the method further includes:
[0023] If it is not the old connection, select an outbound link in a normal state;
[0024] Create a new connection based on the outbound link;
[0025] Send the traffic to be sent through the new connection.
[0026] In the above implementation process, if the old connection is not hit, an outbound link in a normal state can be selected and a new connection can be established for sending to handle the service normally.
[0027] The embodiment of the present application further provides a link switching device, and the device includes:
[0028] A receiving module, configured to receive traffic to be sent;
[0029] A connection determination module, configured to determine whether the traffic to be sent hits the old connection;
[0030] An exception judgment module, configured to judge whether the link corresponding to the old connection is abnormal if so;
[0031] A link switching module, configured to clear the old connection and switch the link if the link is abnormal, so as to establish a new connection.
[0032] In the above implementation process, deleting the old connection enables traffic scheduling to be no longer affected by the old connection; and quickly switching to the normal link, thereby reducing the situation that the load device still schedules traffic to the abnormal link due to the old connection, resulting in unconnected services, and solving the problem that the existing method cannot send traffic because the connection on the abnormal link does not age, and the same request will still select the abnormal link to schedule traffic.
[0033] Further, the device further includes:
[0034] An old connection sending module, configured to send the traffic to be sent through the old connection if the link corresponding to the old connection is normal.
[0035] In the above implementation process, if the link where the old connection is located is normal, the old connection can continue to be used for sending, without the need to re-select the link, improving the processing efficiency.
[0036] Further, the link switching module includes:
[0037] A link selection module, configured to re-select an outbound link in a normal state;
[0038] A new connection establishment module, configured to create a new connection based on the outbound link;
[0039] A new connection sending module, configured to send the traffic to be sent through the new connection.
[0040] In the above implementation process, if the old connection is abnormal, re-select the outbound link, establish a new connection, and by quickly switching the link, traffic scheduling is no longer affected by the old connection.
[0041] An embodiment of the present application further provides an electronic device, which includes a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the link switching method described in any one of the above.
[0042] An embodiment of the present application further provides a readable storage medium, in which computer program instructions are stored. When the computer program instructions are read and run by a processor, the link switching method described in any one of the above is executed. Description of the Drawings
[0043] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0044] Figure 1 Flowchart of a link switching method provided by an embodiment of the present application;
[0045] Figure 2 Schematic diagram of the service network provided by an embodiment of the present application;
[0046] Figure 3 Specific flowchart of traffic processing provided by an embodiment of the present application;
[0047] Figure 4 Specific flowchart of clearing the old connection and switching the link to establish a new connection provided by an embodiment of the present application;
[0048] Figure 5 Flowchart of the outbound link processing in the normal state provided by an embodiment of the present application;
[0049] Figure 6 Structural block diagram of a link switching device provided by an embodiment of the present application;
[0050] Figure 7 Structural block diagram of another link switching device provided by an embodiment of the present application.
[0051] Icon:
[0052] 100 - receiving module; 200 - connection judgment module; 210 - normal link sending module; 300 - exception judgment module; 310 - old connection sending module; 400 - link switching module; 401 - link selection module; 402 - new connection establishment module; 403 - new connection sending module. Detailed implementation manners
[0053] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application.
[0054] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0055] Embodiment 1
[0056] Please refer to Figure 1 , Figure 1 which is a flowchart of a link switching method provided by an embodiment of the present application. This method is applied to a load balancing device. For example, as Figure 2 shown, it is a schematic diagram of a service network. This method can be used as an extended function of link health check in link load balancing. Therefore, the network is a standard link load balancing network, and the load balancing device is deployed at the network exit, and the link load balancing and the fast switching function of traffic after link exception can be enabled.
[0057] In the existing method, the old connection does not match the load policy, and the traffic directly goes out according to the connection information. For the old connection, the device can only wait for the connection to age or passively refresh the connection, which takes a long time. Especially for requests without a retransmission mechanism, if the connection never ages, it is impossible to select a normal link all the time. This method enables fast traffic switching after a link exception in the link load scenario, and realizes the function of quickly switching the traffic of the abnormal link to the normal link when a certain link is abnormal. The method specifically includes the following steps:
[0058] Step S100: Receive the traffic to be sent;
[0059] Step S200: Determine whether the traffic to be sent hits an old connection;
[0060] Step S300: If so, determine whether the link corresponding to the old connection is abnormal;
[0061] Step S400: If abnormal, clear the old connection and switch the link to establish a new connection.
[0062] Deleting the old connection makes the traffic scheduling no longer affected by the old connection; and quickly switching to the normal link, thereby reducing the situation that the load device still schedules traffic to the abnormal link due to the old connection, resulting in service interruption, and solving the problem that the existing method still selects the abnormal link to schedule traffic for the same request due to the non-aging of the connection on the abnormal link, resulting in the inability to send traffic.
[0063] This method is based on the health check determining that the link is abnormal, so theoretically it can be combined with any link health check. When the health check determines that the link is abnormal, the program will automatically delete the connection of this user on the link load balancing module on the abnormal link, so that the subsequent requests of this user can be quickly scheduled to other normal links without affecting the traffic of other users.
[0064] An old connection, different from a new connection, is a connection that already exists on the load balancing device, that is, a connection that has not aged since a certain new connection was established. The reason for not aging may be that there is still data transmission in the connection or it has not reached the aging time, etc.
[0065] The default processing of existing load balancing devices for old connections is that traffic preferentially uses old connections. If there are no old connections, new connections follow the load balancing policy, that is, old connections do not hit the load balancing policy. This application modifies the traffic processing flow of the load balancing device, incorporates old connections into the matching logic of the load balancing policy, and performs processing such as clearing abnormal old connections and quickly switching links, as Figure 3 shown, is the specific traffic processing flow chart.
[0066] When traffic hits the link load, check whether the connection of this traffic has been established, that is, whether the traffic hits an old connection. If it does not hit an old connection, this traffic first selects an outbound link, creates a new connection, marks the outbound link information in the connection (for subsequent old connection exception handling), and then goes out normally.
[0067] If it hits an old connection, determine whether the link recorded in the old connection is abnormal. For example, when performing a health check on the link, when the link has a problem, the link status will be set to abnormal through the health check. If it is abnormal, clear the old connection corresponding to this traffic, and then follow the processing flow of not hitting an old connection (re-select an outbound link). If the link recorded in the old connection is normal, directly go out through the old connection and do not select another link.
[0068] After the step of determining whether the link corresponding to the old connection is abnormal, the method further includes:
[0069] If the link corresponding to the old connection is normal, send the traffic to be sent from the old connection.
[0070] As Figure 4 shown, is the specific flow chart for clearing the old connection and switching the link to establish a new connection. Step S400 may specifically include the following steps:
[0071] Step S401: Re-select an outbound link in a normal state;
[0072] Step S402: Create a new connection based on the outbound link;
[0073] When creating a new connection, it is also necessary to mark the outbound link information in the new connection.
[0074] When the load balancing device receives traffic, it will establish a connection, and multiple connections form a complete session connection table. The connection includes five-tuple information (source IP, destination IP, source port, destination port, protocol) and multiple basic attributes. On this basis, this application also adds a connection attribute, the outbound link information of the link load module in the load balancing device, that is, it identifies which link in the link load balancing module this connection goes out through.
[0075] The marked outbound link information can be used in subsequent handling of old connection exceptions (see the description near step S400 in the handling logic for hitting old connection exceptions in the above text). The abnormal link no longer processes the old connection but re - routes.
[0076] Step S403: The traffic to be sent is sent through the new connection.
[0077] Re - select a normal link to ensure the normal operation of the service, and the link switching process will not affect the connections of other users and the development of normal services.
[0078] As Figure 5 shown, it is a flowchart for processing the outbound link in the normal state. After the step of determining whether the traffic to be sent hits an old connection, the method further includes:
[0079] Step S211: If it is not an old connection, select an outbound link in the normal state;
[0080] Step S212: Create a new connection based on the outbound link;
[0081] Step S213: The traffic to be sent is sent through the new connection.
[0082] If it is not an old connection, an outbound link in the normal state can be selected, a new connection can be created, and the outbound link information can be marked in the connection so that the traffic can be sent out normally.
[0083] This method expands the health check function, realizes the automatic deletion operation of the connection of the abnormal link triggered by traffic, makes the traffic scheduling no longer affected by the old connection, and quickly switches to the normal link, thus reducing the situation where the load - balancing device still schedules traffic to the abnormal link due to the old connection, resulting in service interruption, and ensuring the normal development of the service.
[0084] By modifying the existing traffic matching logic of the load - balancing device, special processing is performed on the old connection. When a certain link fails, by judging whether the traffic hits the mark (there is a connection table on the device, and the traffic with the same five - tuple as the device connection table sent by the client is an old connection), the specific old connection of the abnormal link is quickly deleted, and a normal link is re - selected, so as to ensure the normal operation of the service. Since only specific old connections are processed, it does not affect the connections of other users either.
[0085] Embodiment 2
[0086] The embodiment of the present application provides a link switching device. As Figure 6 shown, it is a structural block diagram of a link switching device, which is applied to the load - balancing device described in Embodiment 1. The device includes but is not limited to:
[0087] A receiving module 100, configured to receive traffic to be sent;
[0088] A connection determination module 200, configured to determine whether the traffic to be sent hits an old connection;
[0089] An exception determination module 300, configured to, if so, determine whether the link corresponding to the old connection is abnormal;
[0090] A link switching module 400, configured to, if the link is abnormal, clear the old connection and switch the link to establish a new connection.
[0091] Delete the old connection, so that traffic scheduling is no longer affected by the old connection; and quickly switch to the normal link, thereby reducing the situation that the load device still schedules traffic to the abnormal link due to the old connection, resulting in service interruption, and solving the problem that the existing method cannot send traffic because the connection on the abnormal link does not age, and the same request will still select the abnormal link to schedule traffic.
[0092] Since the above process is based on the health check determining that the link is abnormal, it can theoretically be combined with any link health check. When the health check determines that the link is abnormal, the program will automatically delete the connection of this user on the link load balancing module on the abnormal link, so that the subsequent requests of this user can be quickly scheduled to other normal links without affecting the traffic of other users.
[0093] The old connection, different from the new connection, is an existing connection on the load balancing device, that is, a connection that has not aged since a certain new connection was established. The reason for not aging may be that there is still data transmission in the connection or the aging time has not arrived, etc.
[0094] The default processing of the existing load balancing device for the old connection is that traffic preferentially goes through the old connection. If there is no old connection, a new connection is created to follow the load balancing policy, that is, the old connection will not hit the load balancing policy. This application modifies the traffic processing flow of the load balancing device, incorporates the old connection into the matching logic of the load balancing policy, and performs processing such as clearing the abnormal old connection and quickly switching the link.
[0095] When the traffic hits the link load, check whether the connection of this traffic has been established, that is, whether the traffic hits the old connection. If it does not hit the old connection, this traffic first selects an outgoing link, creates a new connection, marks the outgoing link information in the connection (for subsequent old connection exception handling) and then goes out normally.
[0096] If it hits the old connection, determine whether the link recorded in the old connection is abnormal. If it is abnormal, clear the old connection corresponding to this traffic, and then follow the processing flow when not hitting the old connection (re-select the link to go out). If the link recorded in the old connection is normal, directly go out through the old connection without selecting another link.
[0097] As Figure 7 shown, it is a structural block diagram of another link switching device. Based on Figure 6 , the device further includes:
[0098] An old connection sending module 310, which is used to send the traffic to be sent through the old connection if the link corresponding to the old connection is normal.
[0099] If the link where the old connection is located is normal, the old connection can continue to be used for sending without reselecting the link, improving the processing efficiency and the utilization rate of the link.
[0100] The link switching module 400 includes but is not limited to:
[0101] A link selection module 401, which is used to reselect an outgoing link in a normal state;
[0102] A new connection establishment module 402, which is used to create a new connection based on the outgoing link;
[0103] Mark the outgoing link information in the new connection, so that the new connection includes not only the five-tuple information but also the outgoing link information for use in subsequent processing of abnormal old connections.
[0104] A new connection sending module 403, which is used to send the traffic to be sent through the new connection.
[0105] If the old connection is abnormal, reselect the outgoing link, establish a new connection, and through fast link switching, make the traffic scheduling no longer affected by the old connection.
[0106] Reselect the normal link to ensure the normal operation of the service, and the link switching process will not affect the connections of other users and the normal development of the service.
[0107] The device further includes a normal link sending module 210, and the normal link sending module 210 is used for:
[0108] If it is not an old connection, select an outgoing link in a normal state;
[0109] Create a new connection based on the outgoing link;
[0110] Send the traffic to be sent through the new connection.
[0111] If it is not an old connection, an outgoing link in a normal state can be selected, a new connection can be created, and the outgoing link information can be marked in the connection so that the traffic can be sent out normally.
[0112] This method expands the health check function and realizes the automatic deletion operation of the connection of the abnormal link triggered by traffic, so that the traffic scheduling is no longer affected by the old connection and quickly switches to the normal link, thereby reducing the situation that the load balancing device still schedules traffic to the abnormal link due to the old connection, resulting in unconnected services, and ensuring the normal development of services.
[0113] By modifying the existing traffic matching logic of the load balancing device, special processing is performed on the old connection. When a certain link fails, by judging whether the traffic hits the mark, the specific old connection of the abnormal link is quickly deleted, and the normal link is reselected, so as to ensure the normal operation of the service. Since only specific old connections are processed, it does not affect the connections of other users either.
[0114] By deleting the old connection, this device makes the traffic scheduling no longer affected by the old connection; and quickly switches to the normal link, thereby reducing the situation that the load device still schedules traffic to the abnormal link due to the old connection, resulting in unconnected services, and solving the problem that the existing method still selects the abnormal link to schedule traffic for the same request due to the non-aging of the connection on the abnormal link, resulting in the inability to send traffic.
[0115] The embodiment of the present application also provides an electronic device, which includes a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the link switching method described in Embodiment 1.
[0116] The embodiment of the present application also provides a readable storage medium, in which computer program instructions are stored. When the computer program instructions are read and run by a processor, the link switching method described in Embodiment 1 is executed.
[0117] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0118] In addition, each functional module in various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0119] If the described functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0120] The above are only the embodiments of the present application and are not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0121] As described above, these are only the specific implementation manners of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, and all of them should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0122] It should be noted that in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.
Claims
1. A link switching method, characterized in that, Applied to a load balancing device, the method includes: Receiving traffic to be sent; Judging whether the traffic to be sent hits an old connection; If so, judging whether the link corresponding to the old connection is abnormal; If abnormal, clearing the old connection and switching the link to establish a new connection.
2. The link switching method according to claim 1, wherein After the step of judging whether the link corresponding to the old connection is abnormal, the method further includes: If the link corresponding to the old connection is normal, sending the traffic to be sent from the old connection.
3. The link switching method according to claim 1, wherein The clearing the old connection and switching the link to establish a new connection includes: Re-selecting an outbound link in a normal state; Creating a new connection based on the outbound link; Sending the traffic to be sent through the new connection.
4. The link switching method according to claim 3, wherein The creating a new connection based on the outbound link includes: Marking outbound link information in the new connection.
5. The link switching method according to claim 1, wherein After the step of judging whether the traffic to be sent hits an old connection, the method further includes: If it is not an old connection, selecting an outbound link in a normal state; Creating a new connection based on the outbound link; Sending the traffic to be sent through the new connection.
6. A link switching device, characterized in that, The device includes: A receiving module, configured to receive traffic to be sent; A connection judging module, configured to judge whether the traffic to be sent hits an old connection; An abnormality judging module, configured to, if so, judge whether the link corresponding to the old connection is abnormal; A link switching module, configured to, if the link is abnormal, clear the old connection and switch the link to establish a new connection.
7. The link switching device according to claim 6, wherein The device further includes: An old connection sending module, configured to, if the link corresponding to the old connection is normal, send the traffic to be sent from the old connection.
8. The link switching device according to claim 6, wherein The link switching module includes: A link selecting module, configured to re-select an outbound link in a normal state; A new connection establishing module, configured to create a new connection based on the outbound link; A new connection sending module, configured to send the traffic to be sent through the new connection.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory is used for storing a computer program, and the processor runs the computer program to enable the electronic device to execute the link switching method according to any one of claims 1 to 5.
10. A readable storage medium, characterized in that, Computer program instructions are stored in the readable storage medium, and when the computer program instructions are read and run by a processor, the link switching method according to any one of claims 1 to 5 is executed.
Citation Information
Patent Citations
Method and device for distributing links for mobile terminal
CN114423043A
Network payment system and terminal thereof
CN201820265U