Session keeping table processing method and load balancing equipment
By introducing a session-holding table processing method in distributed load balancing devices, the session-holding table entries are synchronized between different service CPUs, solving the problems of session-holding failure and table entries inconsistency, ensuring business continuity and new performance.
Patent Information
- Application Number
- CN202510110934.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-13
AI Technical Summary
In distributed load balancing devices, the synchronization problem of session maintaining table entries between different service CPUs results in session failure and it is difficult to ensure that session maintaining table entries consistency between service CPUs.
By introducing a processing method of a session holding table in the load balancing device, the first service CPU sends the table entry operation message to the target service CPU after performing the table entry operation of the session holding table, and the target service CPU synchronizes the local table entry operation, and propagates the synchronization result to other service CPUs to ensure that the session entry between each service CPU remains consistent.
It solves the problem of session retention in distributed load balancing devices, ensures the consistency of session entries between service CPUs, and is suitable for various retention algorithms, does not rely on I/O CPU shunt methods, and has no impact on the performance of new session creation.
Smart Images

Figure CN119996320A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method for processing a session retention table and a load balancing device. Background Art
[0002] The load balancing device maps the IP addresses of multiple real servers to the IP address of a virtual server. When the client's access reaches the load balancing device, the virtual server will select the service pool according to the configuration. The service pool schedules the real server according to the balancing algorithm and forwards the user's access request to the appropriate real server.
[0003] One of the important functions of load balancing devices is session persistence, which can forward client requests to the same backend server for processing based on different persistence algorithms such as source IP, destination IP, URL, cookie, etc. When there is no synchronization mechanism for session information between backend servers, the session persistence function of the load balancing device can ensure that the service will not be interrupted due to being forwarded to different backend servers one after another.
[0004] To implement the session persistence function, it is necessary to save the session persistence table entries on the load balancing device. For centralized devices, session persistence table entries are created and queried on the same service CPU (Service CPU, referred to as: SCPU), while the traffic of distributed devices is dispersed to different service CPUs for processing, and the creation and query of session persistence table entries are also dispersed to different service CPUs. If the traffic of the same client is successively assigned to different service CPUs for processing, the traffic initiated later will not be able to find the session persistence table entries previously created on other service CPUs when querying the service CPU locally, resulting in session persistence failure. Summary of the invention
[0005] The purpose of the present application is to provide a method for processing a session retention table and a load balancing device to solve the problem of session retention in a distributed load balancing device and ensure the consistency of session retention table entries of each business CPU. The method is generally applicable to various retention algorithms, is not dependent on the I / O CPU diversion method, and has no effect on the performance of new session creation.
[0006] In a first aspect, the present application provides a method for processing a session persistence table, which is applied to a load balancing device including multiple business CPUs, and the method includes: after the first business CPU performs a table entry operation on the session persistence table, the table entry operation message is sent to the target business CPU; wherein the table entry operation includes: creating a session persistence table entry, updating a session persistence table entry or deleting a session persistence table entry; the target business CPU performs local synchronization of the table entry operation of the session persistence table according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other business CPUs.
[0007] Furthermore, when the above-mentioned table entry operation is to create a session retention table entry, before the step of sending the table entry operation message to the target service CPU, it also includes: the first service CPU selects the target service CPU from all service CPUs.
[0008] Furthermore, the step of the first business CPU selecting a target business CPU from all business CPUs includes: the first business CPU obtains a hash value of a key of a session persistence table and the number of online business CPUs; performs an AND operation on the hash value of the key of the session persistence table and the value of the number of online business CPUs minus one to obtain a target value; and selects a business CPU whose ID value is the target value as the target business CPU.
[0009] Furthermore, the above-mentioned table item operation message includes: when creating a table item message, the target business CPU locally synchronizes the table item operation of the session persistence table according to the table item operation message, and synchronizes the table item operation of the session persistence table to other business CPUs, including: the target business CPU locally creates a session persistence table item according to the creation table item message, and broadcasts the creation table item message to other business CPUs, so that other business CPUs locally create a session persistence table item according to the creation table item message.
[0010] Furthermore, the above-mentioned table item operation message includes: when creating a table item message, before the target business CPU performs the step of synchronizing the table item operation of the session persistence table locally according to the table item operation message, it also includes: judging whether there is a session persistence table item with the same key locally; if so, sending a table item duplication prompt message to the first business CPU, so that the first business CPU corrects the local session persistence table item according to the table item duplication prompt message; if not, continuing to execute the step of synchronizing the table item operation of the session persistence table locally according to the table item operation message by the target business CPU.
[0011] Furthermore, the above-mentioned table item operation message includes: when updating the table item message, the target business CPU locally synchronizes the table item operation of the session persistence table according to the table item operation message, and synchronizes the table item operation of the session persistence table to other business CPUs, including: when the target business CPU receives the update table item message sent by other business CPUs except the target business CPU, it updates the session persistence table item and broadcasts the update table item message to notify all other business CPUs to update the session persistence table item.
[0012] Furthermore, the method further comprises: when traffic on the target service CPU triggers an entry update, directly broadcasting an update entry synchronization message to notify all other service CPUs to update the session retention entry.
[0013] Further, the above-mentioned table entry operation includes: when deleting a session retention table entry, the first service CPU sends a table entry operation message to the target service CPU after performing a table entry operation on the session retention table, including: when the first service CPU creates a new session, in the case where it is detected from the session retention table entry that the real server is offline, after deleting the local session retention table entry, a new session retention table entry is created, and a new table entry message is sent to the target service CPU;
[0014] The target business CPU performs local synchronization of the table entry operation of the session retention table according to the table entry operation message, and synchronizes the table entry operation of the session retention table to other business CPUs, including: the target business CPU detects that the real server corresponding to the local existing session retention table entry is in an offline state, uses the new session retention table entry carried in the new table entry creation message to overwrite the original table entry, and broadcasts it to other business CPUs to enable other business CPUs to synchronize the table entries.
[0015] Furthermore, the load balancing device further comprises a main control CPU; the method further comprises: when the main control CPU detects a change in resource configuration related to the session holding entry, the main control CPU sends a deletion entry message to each service CPU so that each service CPU deletes the session holding entry.
[0016] Furthermore, the above method also includes: when the target business CPU detects that the local session retention table has timed out, it actively broadcasts a query message to other business CPUs, so that other business CPUs query whether the corresponding session retention table entry has timed out; if a table entry timeout message is received from all other business CPUs, the local session retention table entry is deleted, and a table entry deletion message is broadcast to other business CPUs to delete the table entry; if a table entry has not timed out message is received from other business CPUs, the update time of the local session retention table entry is updated according to the remaining timeout time carried in the table entry has not timed out message.
[0017] Furthermore, the above method also includes: each time the sender sends a message to the receiver, if the receiver does not reply to the response message, the sender will retransmit the message again; wherein the receiver and the sender are any business CPU; and / or, when any business CPU is started or abnormally restarted, the SCPU that is started or abnormally restarted requests the business CPU in the online state to synchronize the entire session persistence table with itself, and continues the startup process after the synchronization of the session persistence table is completed.
[0018] In a second aspect, the present application further provides a load balancing device, in which a plurality of service CPUs are configured, and the load balancing device is used to execute the method described in the first aspect.
[0019] In the processing method of the session persistence table and the load balancing device provided by the present application, the method is applied to a load balancing device including multiple business CPUs. After the first business CPU performs table entry operations on the session persistence table, it sends a table entry operation message to the target business CPU; wherein the table entry operation includes: creating a session persistence table entry, updating a session persistence table entry, or deleting a session persistence table entry; the target business CPU performs table entry operation synchronization of the session persistence table locally according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other business CPUs. The present application implements the synchronization of the session persistence table between multiple business CPUs in a distributed load balancing device. Therefore, when the client initiates a re-access request, the corresponding session persistence table can be found from any business CPU, thereby solving the problem of session persistence in the distributed load balancing device. It is a diversion method that is generally applicable to various persistence algorithms and does not rely on the I / O CPU, and has no effect on the performance of new session creation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 A flowchart of a method for processing a session retention table provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of message types for a full-mesh process of a session persistence table provided in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of a target service CPU (owner SCPU) election algorithm provided in an embodiment of the present application;
[0024] Figure 4 A schematic diagram of a full-mesh process for creating a session retention table entry provided in an embodiment of the present application;
[0025] Figure 5 A schematic diagram of confirmation and retransmission of a synchronization message provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of a service CPU synchronization session retention table entry being started provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of a session persistence table processing system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The technical solution of the present application will be described clearly and completely below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0029] The existing technology includes the following processing methods for the session persistence problem of distributed load balancing, and the corresponding problems of each processing method are as follows:
[0030] (1) Divert traffic based on source IP, and divert traffic with the same source IP to the same service CPU (i.e., SCPU, which may also be referred to as this abbreviation below) for processing. Create and query session persistence table entries on the SCPU to implement the session persistence function. The load balancing device performs session persistence based on the service pool referenced by the virtual server, and generally supports different persistence algorithms such as source IP, destination IP, URL, and cookie. Diverting based on source IP can only solve the problem of source IP session persistence, but cannot solve the problem of other persistence algorithms such as destination IP, URL, and cookie, that is, there are restrictions on the diversion method.
[0031] (2) The session persistence table is distributed to each SCPU for storage and asynchronous query. When the distributed load balancing device creates a new session, it determines the SCPU where the session persistence table entry is stored through the consistent hash value, sends an asynchronous message to the SCPU to query the session persistence table entry, and caches the message at the same time. After receiving the response, it takes the message from the cache queue to continue the new creation process. A virtual server can reference multiple service pools, and session persistence is based on the service pool. Therefore, it may be necessary to query the session persistence table multiple times. Multiple asynchronous queries have a greater impact on the performance of session creation.
[0032] (3) Traffic is divided according to virtual servers, and the traffic belonging to the same virtual server is divided into the same SCPU for processing. The session retention table is created and queried on the SCPU to implement the session retention function. Traffic is divided by the I / OCPU according to the source and destination IP and port of the message to different SCPUs. When the IP and port overlap of virtual servers is high, the traffic of these virtual servers can only be divided into the same SCPU, and the SCPUs cannot be used evenly, resulting in a waste of some SCPU performance.
[0033] Based on this, the embodiment of the present application provides a method for processing a session persistence table and a load balancing device to solve the problem of session persistence in a distributed load balancing device. The method is applicable to various persistence algorithms, is independent of the I / O CPU, and has no effect on the performance of creating new sessions.
[0034] To facilitate understanding of this embodiment, a method for processing a session persistence table disclosed in an embodiment of the present application is first introduced in detail.
[0035] Figure 1 A flowchart of a method for processing a session holding table provided in an embodiment of the present application, the method for processing a session holding table can realize a full-mesh (full interconnection) of the session holding table; the method is applied to a load balancing device including multiple service CPUs, that is, a distributed load balancing device, and the method includes the following steps:
[0036] Step S102: After performing an entry operation on the session retention table, the first service CPU sends an entry operation message to the target service CPU; wherein the entry operation includes: creating a session retention entry, updating a session retention entry, or deleting a session retention entry.
[0037] The first service CPU may be any service CPU in the load balancing device. After performing any of the above-mentioned operations of creating a session retention entry, updating a session retention entry or deleting a session retention entry, the first service CPU will send an entry operation message to the target service CPU.
[0038] For example, the table entry operation of the session retention table is: creating a session retention table entry, and accordingly, the table entry operation message is: creating a table entry message.
[0039] For another example, the table entry operation of the session retention table is: updating the session retention table entry, and accordingly, the table entry operation message is: updating table entry message.
[0040] For another example, the table entry operation of the session retention table is: deleting the session retention table entry, and accordingly, the table entry operation message is: deleting the table entry message.
[0041] In a preferred manner, the target service CPU may also elect a service CPU through a preset algorithm.
[0042] In a possible implementation, the first service CPU may also be a target service CPU. In this case, after performing the table entry operation of the session holding table, the first service CPU directly synchronizes the table entry operation of the session holding table to other service CPUs.
[0043] Step S104: The target service CPU performs local synchronization of the entry operation of the session holding table according to the entry operation message, and synchronizes the entry operation of the session holding table to other service CPUs.
[0044] For example, after receiving the create entry message sent by the first service CPU, the target service CPU locally saves the above session persistence table and synchronizes the creation of the session persistence table to other service CPUs, that is, the other service CPUs also synchronize and save the above session persistence table. For the case of updating the entry message and deleting the entry message, the specific implementation process is similar and will not be repeated here.
[0045] In the processing method of the session retention table provided in the embodiment of the present application, when creating, updating or deleting the session retention table entry, each service CPU needs to synchronously create, update or delete the session retention table. That is, since in the embodiment of the present application, after any service CPU performs the table entry operation of the session retention table, it is synchronized from the target service CPU to other service CPUs, therefore, when the client initiates a re-access request, the corresponding session retention table can be found from any service CPU, thereby solving the problem of session retention of the distributed load balancing device. By synchronizing the table entry operation through the target service CPU, the consistency of the session retention table entries of each service CPU can be guaranteed, which is generally applicable to various retention algorithms, the diversion method that does not rely on the I / O CPU, and has no effect on the performance of session creation.
[0046] The embodiment of the present application also provides another method for processing a session retention table, which is implemented on the basis of the above embodiment; this embodiment focuses on describing the election process of the target service CPU and the specific synchronization process of multiple table entry operations.
[0047] In order to ensure the consistency of the table entries of each business CPU session, it is necessary to select a specific business CPU to manage the creation, update, and deletion of table entries. If the business CPU is not elected, and the business CPU that processes the traffic is directly responsible for synchronizing the creation, update, and deletion messages, there is a problem: Assume that business CPU1 and business CPU2 create new sessions at the same time, the business CPU1 balance algorithm selects real server x, and the business CPU2 balance algorithm selects real server y, and the key of the session maintenance table entry is the same. Both create maintenance table entries locally and broadcast them to other business CPUs. After business CPU2 receives the message sent by business CPU1, because there is already a table entry with the same key locally, the local creation fails, and the results on business CPU1 and business CPU2 are different. Business CPU3 successfully receives the message from business CPU1, but business CPU4 does not receive the message from business CPU1 but receives the message from business CPU2, and the maintenance table entries created by business CPU3 and business CPU4 are also different.
[0048] Therefore, it is necessary to elect a specific business CPU to be responsible for managing the creation, update, and deletion of table entries to ensure the consistency of the table entries.
[0049] That is, when the above-mentioned table operation is to create a session retention table entry, before the step of sending the table operation message to the target service CPU, the method further includes: the first service CPU selects the target service CPU from all service CPUs.
[0050] Among the multiple service CPUs of the distributed load balancing device, one service CPU is selected to be responsible for the synchronization of creating, updating, and deleting the session retention table. In the embodiment of the present application, the service CPU is referred to as the owner service CPU. In this embodiment, the service CPU role classification is shown in Table 1 below. To facilitate the description of the full-mesh process, the service CPU is divided into source SCPU, owner SCPU, and other SCPU, where the owner SCPU is the aforementioned target service CPU:
[0051] Table 1
[0052]
[0053] The full-mesh design for the session retention table is as follows Figure 2 The message passing framework shown is used to synchronize the creation, update, and deletion of the session persistence table in each service CPU. The sender, receiver, and transmission information of the message type of the session persistence table full-mesh process are shown in Table 2.
[0054] Table 2
[0055]
[0056] Since the business CPUs of distributed devices support hot-swap and fault restart, that is, any business CPU may be offline, the business CPU cannot be directly specified, and the online business CPU must be elected in real time. To ensure that the same key table items elect the same business CPU, the owner business CPU algorithm is as follows Figure 3 As shown:
[0057] To put it in words, the specific process is: the first business CPU obtains the hash value of the key of the session persistence table and the number of online business CPUs; the hash value of the key of the session persistence table is ANDed with the value of the number of online business CPUs minus one to obtain a target value; the business CPU whose ID value is the target value is used as the target business CPU, which ensures that the target SCPU is unique.
[0058] The following describes in detail the three situations of creating a session persistence table entry, updating a session persistence table entry, and deleting a session persistence table entry:
[0059] (1) Create a session persistence entry:
[0060] The above-mentioned table item operation message includes: when creating a table item message, the target business CPU locally synchronizes the table item operation of the session retention table according to the table item operation message, and synchronizes the table item operation of the session retention table to other business CPUs, including: the target business CPU locally creates a session retention table item according to the creation table item message, and broadcasts the creation table item message to other business CPUs, so that other business CPUs locally create a session retention table item according to the creation table item message.
[0061] Before the target business CPU performs the step of synchronizing the table entry operation of the session retention table locally according to the table entry operation message, it also includes: determining whether there is a session retention table entry with the same key locally; if so, sending a table entry duplication prompt message to the first business CPU, so that the first business CPU corrects the local session retention table entry according to the table entry duplication prompt message; if not, continuing to execute the step of synchronizing the table entry operation of the session retention table locally according to the table entry operation message by the target business CPU.
[0062] For specific implementation, see Figure 4As shown, after the traffic is diverted to the source SCPU (for example, SCPU1) via the I / O CPU, the source SCPU (that is, the first service CPU in the aforementioned embodiment) first creates a session retention table entry locally, and calculates the owner SCPU according to the election algorithm of the ownerSCPU (for example, the owner SCPU is SCPU2), where the owner SCPU is the target service CPU in the aforementioned embodiment; the Source SCP sends a CREATE message to notify the owner SCPU to create the table entry, and after the owner SCPU locally saves the table entry, the owner SCPU sends a CREATE_SYNC message to notify other SCPUs (for example, SCPU3 and SCPU4, etc.) to create the table entry, and the other SCPUs locally save the session retention table entry.
[0063] The owner SCPU is responsible for ensuring the uniqueness of table entries. When SCPU1 and SCPU2 are the source SCPUs and each processes a new creation, neither finds a session persistence table entry locally. The keys of the session persistence table entries created locally by both are the same and are sent to the owner SCPU3 at the same time. SCPU3 first receives and processes the message from SCPU1, creates a table entry locally and broadcasts it to other SCPUs. Then it receives and processes the message from SCPU2, and finds that there is already a table entry with the same key locally. It replies to SCPU2 with a message about the duplicate table entry and attaches information about the existing table entry. After receiving the reply, SCPU2 corrects the local table entry. After this process, the same table entry is created on each SCPU.
[0064] (2) Update the session retention table:
[0065] The above-mentioned table item operation message includes: when updating the table item message, the target business CPU locally synchronizes the table item operation of the session retention table according to the table item operation message, and synchronizes the table item operation of the session retention table to other business CPUs, including: when the target business CPU receives the update table item message sent by other business CPUs except the target business CPU, it updates the session retention table item and broadcasts the update table item message to notify all other business CPUs to update the session retention table item.
[0066] When other service CPUs detect a table entry update requirement according to a preset detection period, they may send a table entry update message to the target service CPU.
[0067] Furthermore, the method further comprises: when traffic on the target service CPU triggers an entry update, directly broadcasting an update entry synchronization message to notify all other service CPUs to update the session retention entry.
[0068] In specific implementation, since the session maintenance table entry has time validity and timeout, when new traffic finds the table entry, the update time of the table entry needs to be refreshed. If the traffic on the Source SCPU / Other SCPU triggers an update, a message is sent to notify the Owner SCPU to update, and the Owner SCPU broadcasts a REFRESH_SYNC message to notify all other SCPUs to update the table entry. When the traffic on the Owner SCPU triggers an update, the Owner SCPU directly broadcasts a REFRESH_SYNC message to notify all other SCPUs to update the table entry.
[0069] If every time traffic hits a session hold entry, the owner SCPU is notified and broadcast, which consumes a lot of CPU and distributed device internal bandwidth. To avoid this problem, the update is performed again when a certain time has passed since the last update. The update cycle is 1 / 8 of the session hold timeout period.
[0070] (3) Delete the session retention table entry:
[0071] The above-mentioned table entry operation includes: when deleting a session retention table entry, the first service CPU sends a table entry operation message to the target service CPU after performing a table entry operation on the session retention table, including: when the first service CPU creates a new session, in the case where it is detected from the session retention table entry that the real server is offline, after deleting the local session retention table, a new session retention table is created, and a new table entry message is sent to the target service CPU;
[0072] The target business CPU performs local synchronization of the table entry operation of the session persistence table according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other business CPUs, including: the target business CPU detects that the real server corresponding to the local existing session persistence table is in an offline state, uses the new session persistence table carried in the new table entry message to overwrite the original table entry, and broadcasts it to other business CPUs to enable other business CPUs to synchronize the table entries.
[0073] Furthermore, the load balancing device further comprises a CCPU (Control CPU); the method further comprises: when the control CPU detects a change in resource configuration related to the session retention entry, the control CPU sends a deletion entry message to each service CPU so that each service CPU deletes the session retention entry.
[0074] Here, the resources related to the session holding table entry may include virtual servers, service pools and real servers; resource configuration changes related to the session holding table entry may include, for example, the virtual server and / or service pool related to the session holding table entry being deleted, or the configuration of the real server being changed.
[0075] Furthermore, the above method also includes: when the target business CPU detects that the local session retention table has timed out, it actively broadcasts a query message to other business CPUs, so that other business CPUs query whether the corresponding session retention table entry has timed out; if a table entry timeout message is received from all other business CPUs, the local session retention table entry is deleted, and a table entry deletion message is broadcast to other business CPUs to delete the table entry; if a table entry has not timed out message is received from other business CPUs, the update time of the local session retention table is updated according to the remaining timeout time carried in the table entry has not timed out message.
[0076] The above three methods can be summarized as follows:
[0077] The session persistence table can be deleted in the following scenarios:
[0078] (1) The status of the real server switches to down, that is, offline;
[0079] (2) To delete a virtual server, service pool, or real server, you need to delete the corresponding session persistence table entry;
[0080] (3) The session retention table times out;
[0081] For scenario (1), when a new session is created, the sourceSCPU checks the session retention table and finds that the real server is offline. The sourceSCPU deletes the local entry, creates a new entry, and sends a CREATE message to notify the owner SCPU of the new entry. The ownerSCPU finds that the real server with the local entry is offline, and uses the entry information in the CREATE message to overwrite the old entry and broadcast it to other SCPUs.
[0082] For scenario (2), the master control CPU notifies each service CPU of the configuration change, and each service CPU deletes the session retention table entry.
[0083] For scenario (3), since the update cycle of the session persistence table entry is 1 / 8 of the timeout period, the update time on the owner SCPU may not be the latest. When the owner SCPU finds that the local table entry has timed out, it actively sends a QUERY_SYNC message to ask each SCPU whether the corresponding table entry has timed out. If all SCPUs have timed out, the owner SCPU deletes the local table entry and broadcasts a DELETE_SYNC message to notify other SCPUs to delete the table entry. If there is an SCPU that has not timed out, the owner SCPU updates the update time of the local session persistence table based on the remaining time.
[0084] In order to ensure that each SCPU creates, updates, and deletes session retention entries at the same time, thereby avoiding service problems caused by inconsistent session retention entries of two SCPUs, the embodiment of the present application designs a retransmission and confirmation mechanism for synchronization messages. If the receiver does not reply to the response message, the sender will retransmit the message again. Figure 5 As shown, taking the owner SCPU sending a CREATE_SYNC message to other SCPU as an example, the owner SCPU will maintain an array to record whether each other SCPU responds, and set a timer to check whether each other SCPU responds every 1 second. If there is no response, the owner SCPU will send a message to the SCPU again.
[0085] In some examples, the above method also includes: each time the sender sends a message to the receiver, if the receiver does not reply with a response message, the sender will retransmit the message again; wherein the receiver and the sender are any service CPU.
[0086] In a distributed scenario, it is common to expand the number of business CPUs or abnormally restart a business CPU. When a new business CPU is inserted into a distributed load balancing device, or a business CPU sends an abnormal restart, the session persistence table is real-time dynamic data and is stored in memory. The newly online business CPU lacks session persistence table data, which affects traffic processing.
[0087] The embodiment of the present application supports the newly launched service CPU to synchronize the session retention table data from the normally operating service CPU, thereby ensuring the correctness of processing session retention after the service CPU comes online.
[0088] In some examples, the above method also includes: when any service CPU is started or abnormally restarted, the SCPU that is started or abnormally restarted requests the online service CPU to fully synchronize the session persistence table with itself, and continues the startup process after the synchronization of the session persistence table is completed.
[0089] like Figure 6 As shown, the starting business CPU selects a business CPU in an online state, sends a message to notify the online business CPU to fully synchronize the session retention table to itself, and queries whether the synchronization is completed according to a preset detection period (for example, every second), and continues the subsequent startup process after completion.
[0090] For operators, finance, e-commerce and other businesses, distributed load balancing devices are usually required to support high-volume business requirements, and session persistence is also one of the basic requirements of such businesses. The full interconnection method of the session persistence table provided in the embodiment of the present application can be applied to such scenarios.
[0091] In summary, the method for processing the session persistence table provided in the embodiment of the present application solves the problem of distributed load balancing session persistence and ensures business continuity. The proposed method is independent of the persistence algorithm and is valid for all persistence algorithms. Compared with the technical solution of asynchronous query, it is simpler to implement and has higher new construction performance. Compared with the method of diverting traffic by virtual server, it is not affected by the IP configuration of the virtual server, and the traffic can be evenly distributed to each business CPU for processing, making full use of the performance of each business CPU. In addition, in the full-mesh synchronization process of this embodiment, all synchronization messages support retransmission and confirmation to ensure that the session persistence table entries of each business CPU are consistent. When the business CPU status of the distributed load balancing device changes, it can automatically synchronize the full session persistence table from the online business CPU. The newly online business CPU can also ensure the correctness of session persistence, giving full play to the performance advantages of distribution.
[0092] Based on the above method embodiments, the present application also provides a load balancing device configured with multiple service CPUs, and the load balancing device is used to execute the session retention table processing method provided in any one of the above embodiments.
[0093] The load balancing device provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the embodiment of the system, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0094] Figure 7 The schematic diagram of the processing system of the session retention table includes: a client, a load balancing device configured with multiple service CPUs and a real server, wherein the load balancing device is respectively connected to the client and the real server for communication.
[0095] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0096] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0097] The embodiments or examples of the present disclosure are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection of the present disclosure. In the absence of contradiction, each step in a certain embodiment or example can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.
[0098] Furthermore, the terms “first”, “second”, and “third” are used for descriptive purposes only and should not be understood as indicating or implying relative importance.
[0099] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for processing a session retention table, characterized in that: The method is applied to a load balancing device including multiple service CPUs, and the method includes: After performing an entry operation on the session retention table, the first service CPU sends an entry operation message to the target service CPU; wherein the entry operation includes: creating a session retention entry, updating a session retention entry, or deleting a session retention entry; The target service CPU locally synchronizes the table entry operation of the session holding table according to the table entry operation message, and synchronizes the table entry operation of the session holding table to other service CPUs.
2. The method according to claim 1, characterized in that When the table entry operation is to create a session retention table entry, before the step of sending the table entry operation message to the target service CPU, the step further includes: The first service CPU selects the target service CPU from all service CPUs; Preferably, the step of the first service CPU selecting the target service CPU from all service CPUs includes: The first service CPU obtains the hash value of the key of the session persistence table and the number of online service CPUs; Perform an AND operation on the hash value of the key of the session persistence table and the value of the number of online service CPUs minus one to obtain a target value; The service CPU whose ID value is the target value is used as the target service CPU.
3. The method according to claim 1, characterized in that The table entry operation message includes: when creating the table entry message, the target service CPU locally synchronizes the table entry operation of the session persistence table according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other service CPUs, including: The target service CPU locally creates a session holding table entry according to the create table entry message, and broadcasts the create table entry message to other service CPUs, so that other service CPUs locally create a session holding table entry according to the create table entry message.
4. The method according to claim 1, characterized in that: The table entry operation message includes: when creating the table entry message, before the target service CPU performs a step of synchronizing the table entry operation of the session holding table locally according to the table entry operation message, further including: Determine whether there is already a session persistence entry with the same key locally; If yes, sending a table entry duplication prompt message to the first service CPU, so that the first service CPU corrects the local session holding table entry according to the table entry duplication prompt message; If not, continue to execute the step of the target service CPU locally synchronizing the table entry operation of the session holding table according to the table entry operation message.
5. The method according to claim 1, characterized in that The table entry operation message includes: when updating the table entry message, the target service CPU locally synchronizes the table entry operation of the session persistence table according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other service CPUs, including: When the target service CPU receives the update entry message sent by other service CPUs except the target service CPU, the target service CPU updates the session holding entry and broadcasts the update entry message to notify all other service CPUs to update the session holding entry.
6. The method according to claim 5, characterized in that The method further comprises: When the traffic on the target service CPU triggers an entry update, a table entry update synchronization message is directly broadcast to notify all other service CPUs to update the session retention table entry.
7. The method according to claim 1, characterized in that The table entry operation includes: when deleting a session retention table entry, after the first service CPU performs the table entry operation of the session retention table, the step of sending the table entry operation message to the target service CPU includes: When the first service CPU creates a new session, if it detects from the session holding table that the real server is offline, after deleting the local session holding table entry, it creates a new session holding table entry and sends a new table entry message to the target service CPU; The target service CPU locally synchronizes the table entry operation of the session persistence table according to the table entry operation message, and synchronizes the table entry operation of the session persistence table to other service CPUs, including: The target service CPU detects that the real server corresponding to the existing local session holding table entry is offline, uses the new session holding table entry carried in the create new table entry message to overwrite the original table entry, and broadcasts it to other service CPUs to synchronize the table entries of other service CPUs.
8. The method according to claim 1, characterized in that The load balancing device also includes a main control CPU; the method also includes: When the main control CPU detects a change in resource configuration related to a session holding entry, it sends a deletion entry message to each service CPU, so that each service CPU deletes the session holding entry.
9. The method according to claim 1, characterized in that: The method further comprises: When the target service CPU detects that the local session holding table has timed out, it actively broadcasts a query message to other service CPUs, so that other service CPUs can query whether the corresponding session holding table entry has timed out; If the table entry timeout message is received from all other service CPUs, the local session retention table entry is deleted, and a table entry deletion message is broadcast to other service CPUs to delete the table entry; If a message indicating that the table entry has not timed out is received from another service CPU, the update time of the local session holding table entry is updated according to the remaining time of the timeout carried in the message indicating that the table entry has not timed out.
10. The method according to claim 1, characterized in that The method further comprises: Each time the sender sends a message to the receiver, if the receiver does not reply with a response message, the sender will retransmit the message; wherein the receiver and the sender are any service CPU; and / or, When any service CPU is started or abnormally restarted, the started or abnormally restarted SCPU requests the online service CPU to perform full synchronization of the session retention table to itself, and continues the startup process after the synchronization of the session retention table is completed.
11. A load balancing device, characterized in that: The load balancing device is configured with multiple service CPUs, and the load balancing device is used to execute the method according to any one of claims 1-10.