Connection table management method and device based on NUMA architecture
By dividing the memory into multiple nodes under the NUMA architecture and managing connection table entries based on 5-tuple information, the problem of CPU accessing memory at different nodes at different rates is solved, the allocation and management of connection table resources are optimized, system performance is improved and avoidance New creation fails when memory is tight.
Patent Information
- Application Number
- CN202410747729.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology fails to effectively manage the different rates at which the CPU accesses the memory of different nodes under the NUMA architecture. As a result, the connection table management method cannot be optimized according to the CPU access rate, causing the creation and aging of the connection table to frequently affect system performance, and when memory is tight. This may cause the connection table specifications to be unused and the new connection table to fail to be created.
Adopting a connection table management method based on NUMA architecture, by dividing the memory into multiple NUMA nodes, hashing the 5-tuple information of the traffic to obtain the connection table entries, and using the age field stored in the connection handle to determine the validity of the connection to avoid frequent memory applications and release, and record the pre-application connection table memory size of each NUMA node to optimize the allocation and management of connection table resources.
It effectively solves the impact of connection table creation and aging on system performance, avoids security issues due to connection table pointer failure, and avoids creation failures caused by unused connection table specifications when memory is tight, improving system stability and performance. .
Smart Images

Figure CN118606221A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and specifically relates to a method and device for connection table management based on NUMA architecture. Background Art
[0002] The non-uniform memory access architecture has become the mainstream architecture of modern multi-core servers due to its high memory bandwidth and good scalability. Servers based on the NUMA architecture are widely deployed in existing large data centers. Under the NUMA architecture, the CPU and memory are divided into multiple NUMA nodes, and each CPU can access all the memory. However, the CPU has the smallest delay when accessing the memory of the local NUMA node, and the delay of accessing the memory of the remote NUMA node increases with the distance. The current mainstream connection table management methods basically use cache, connection pool or connection linked list to manage the connection table. The current mainstream connection table management methods do not take into account the different speeds at which the CPU accesses the memory of different nodes under the NUMA architecture, and do not design corresponding connection table management methods based on the CPU access speed. In this regard, we propose a method and device for connection table management based on the NUMA architecture. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention provides a method and device for connection table management based on NUMA architecture to solve the above technical problems.
[0004] To achieve the above object, the present invention provides the following technical solution: a method for connection table management based on NUMA architecture, the management steps are:
[0005] S1. After the network device is started, the memory is divided into N NUMA nodes according to the configuration and associated with the processor;
[0006] S2. Calculate the connection table memory size that needs to be pre-applied for each NUMA node according to the connection table specification session_quota of the network device and the single connection table size session_size, and apply for the connection table memory on each NUMA node;
[0007] S3. After the device startup initialization is completed, the connection table resources and the starting address of the connection table resources of the network device are also initialized;
[0008] S4. After traffic enters the device, hashing is performed according to the five-tuple information of the traffic, and then the hash value and the number of link specifications of the corresponding NUMA node are taken as the memory for obtaining the connection table entry, and the connection table entry is established. The memory for obtaining the link table entry is stored in the connection table pre-applied in the respective NUMA nodes;
[0009] S5. After the traffic obtains the memory address of the connection table entry, the status flag of the corresponding connection table is immediately determined. If the status flag is valid, step S4 is re-executed to select a new connection table entry. If the status flag is invalid, the age of the connection table entry is increased by 1, and the status flag is set to valid, and the corresponding node information is recorded.
[0010] S6. After the connection table entry is obtained, a connection handle is established according to the connection table entry information, and the age field stored in the connection handle is used to determine the validity of the connection. If the connection is valid, the pointer to the connection table entry is obtained by converting the node_id and session_id fields stored in the connection handle to obtain the connection information.
[0011] Preferably, the division step in step S1 determines the number of NUMA nodes to be created according to the hardware configuration, and is completed through kernel parameters and BIOS settings when the system is started to allocate memory to each node.
[0012] Preferably, in step S2, the connection table memory size is: numa_session_size = session_size * session_quota / N. The method for calculating the connection table memory size that needs to be pre-applied for each NUMA node is to determine the data structure of the connection table by analyzing it, multiply the size of each connection item by the number of connections that need to be tracked at the same time, and obtain the total connection table memory requirement. Considering the NUMA architecture, it is determined to distribute the connection table on the NUMA node, and memory is allocated; wherein the starting address of the memory application is numa_session_address, and the starting address of each memory block is recorded as memory_area[i] = numa_session_address[i], wherein i represents the node of the i-th NUMA.
[0013] Preferably, the connection table structure in step S3 includes the connection age age, the connection state flag flag and the NUMA node information node to which the connection belongs.
[0014] Preferably, in step S4, a hashing step is performed on the quintuple information to predefine a quintuple, the quintuple including the source IP address, the destination IP address, the source port number, the destination port number and the transport layer protocol, an MD5 hash function is selected, the quintuple information is combined into a binary representation, hashed, connected into a long integer, and the combination is completed; the MD5 hash function is used to generate a 128-bit hash value, which is 32 hexadecimal digits.
[0015] Preferably, the connection handle in step S6 is another way to obtain the connection. The handle corresponds to the connection table entry. The connection handle includes the age of the connection table entry and the session_id of the connection, wherein part of the session_id information records the node information of NUMA and part records the offset of the pre-application connection table of the session in the corresponding NUMA.
[0016] Preferably, the step of determining the validity of the connection in step S6 first obtains the NUMA node information and offset of the corresponding connection based on the session_id information recorded in the connection handle, finds the corresponding connection pointer based on the memory_area[i] address information recorded during initialization, and obtains the age information recorded in the connection table entry. If the age information recorded in the connection table entry is equal to the age information recorded in the connection handle and the connection status is valid, it means that the connection is valid, and the pointer to the connection table entry is obtained.
[0017] Preferably, the flag method for determining the connection table status in step S5 predefines a variable flag, sets the flag value according to the actual status of the connection table in different parts of the program, uses an if statement to determine the flag value, and executes a corresponding operation.
[0018] Preferably, in step S6, an environment handle is pre-allocated, the allocated environment handle is used to create a connection handle, the handle is used to allocate one or more statement handles to execute SQL statements, and after executing the SQL statements, the returned status code is checked to determine whether the operation is successful.
[0019] Preferably, when the network device is started, each NUMA node pre-applies for a large memory for use as a connection table.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] Compared with the prior art, the present invention can effectively solve the problem that the connection table specifications may not be fully used up and the new connection table may fail to be created when the memory is tight, and effectively alleviate the problem that the frequent application and release of memory due to the creation and aging of the connection table seriously affects the system performance, and at the same time solve some security problems caused by the invalidation of the connection table pointer in the new technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a process framework diagram of the management steps of the present invention. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] The present invention provides a technical solution: a method for managing a connection table based on a NUMA architecture, wherein the management steps are:
[0025] S1. After the network device is started, the memory is divided into N NUMA nodes according to the configuration and associated with the processor;
[0026] S2. Calculate the connection table memory size that needs to be pre-applied for each NUMA node according to the connection table specification session_quota of the network device and the single connection table size session_size, and apply for the connection table memory on each NUMA node;
[0027] S3. After the device startup initialization is completed, the connection table resources and the starting address of the connection table resources of the network device are also initialized;
[0028] S4. After traffic enters the device, hashing is performed according to the five-tuple information of the traffic, and then the hash value and the number of link specifications of the corresponding NUMA node are taken as the memory for obtaining the connection table entry, and the connection table entry is established. The memory for obtaining the link table entry is stored in the connection table pre-applied in the respective NUMA nodes;
[0029] S5. After the traffic obtains the memory address of the connection table entry, the status flag of the corresponding connection table is immediately determined. If the status flag is valid, step S4 is re-executed to select a new connection table entry. If the status flag is invalid, the age of the connection table entry is increased by 1, and the status flag is set to valid, and the corresponding node information is recorded.
[0030] S6. After the connection table entry is obtained, a connection handle is established according to the connection table entry information, and the age field stored in the connection handle is used to determine the validity of the connection. If the connection is valid, the pointer to the connection table entry is obtained by converting the node_id and session_id fields stored in the connection handle to obtain the connection information.
[0031] Furthermore, the division step in step S1 determines the number of NUMA nodes to be created based on the hardware configuration, which is accomplished through kernel parameters and BIOS settings when the system is started to allocate memory to each node.
[0032] Furthermore, in step S2, the memory size of the connection table is: numa_session_size = session_size * session_quota / N. The method for calculating the memory size of the connection table that needs to be pre-applied for each NUMA node is to determine the data structure of the connection table by analyzing it, multiply the size of each connection item by the number of connections that need to be tracked at the same time, and obtain the total connection table memory requirement. Considering the NUMA architecture, it is determined to distribute the connection table on the NUMA node and allocate memory; the starting address of the memory application is numa_session_address, and the starting address of each memory block is recorded as memory_area[i] = numa_session_address[i], where i represents the node of the i-th NUMA.
[0033] Furthermore, in step S3, the connection table structure includes the connection age age, the connection state flag flag and the NUMA node information node to which the connection belongs.
[0034] Furthermore, in step S4, the five-tuple information is hashed to predefine the five-tuple, which includes the source IP address, the destination IP address, the source port number, the destination port number and the transport layer protocol, and the MD5 hash function is selected to combine the five-tuple information into a binary representation, hash it, and concatenate it into a long integer to complete the combination; the MD5 hash function is used to generate a 128-bit hash value, which is 32 hexadecimal digits;
[0035] For example, if the value is session_count, the memory address of the connection table entry is:
[0036] p_session=memory_area[i]+session_count*session_size.
[0037] Furthermore, the connection handle in step S6 is another way to obtain the connection. The handle corresponds to the connection table entry. The connection handle includes the age of the connection table entry and the session_id of the connection. Part of the session_id information records the node information of the NUMA and part records the offset of the pre-application connection table of the session in the corresponding NUMA.
[0038] For example, in a 32-bit session_id, the upper 16 bits record the node information, and the lower 16 bits record the offset of the pre-application connection table of the session in the corresponding NUMA;
[0039] For example, in a firewall, some security detection engines will intercept traffic for security analysis. Since the security engine's interception time for traffic is unknown, the connection table entry may have aged. At this time, the connection pointer of the corresponding traffic is invalid. Therefore, it is impossible to determine the validity of the corresponding traffic connection. However, due to the way the connection handle is generated, the connection handle can be used normally in this case, and the age field stored in the connection handle can be used to determine the validity of the connection. If the connection is valid, the node_id and session_id fields stored in the connection handle can be converted to obtain the pointer to the connection table entry and further obtain the connection information.
[0040] Furthermore, in step S6, the step of determining the validity of the connection first obtains the NUMA node information and offset of the corresponding connection based on the session_id information recorded in the connection handle, finds the corresponding connection pointer based on the memory_area[i] address information recorded during initialization, and obtains the age information recorded in the connection table entry. If the age information recorded in the connection table entry is equal to the age information recorded in the connection handle and the connection status is valid, it means that the connection is valid, and the pointer to the connection table entry is obtained;
[0041] If the connection table entry ages or performs a deletion operation, you only need to invalidate the status flag of the connection table entry without performing a real memory deletion operation. Similarly, when a new connection is created, there is no need to perform a memory allocation operation. You only need to make a validity judgment on the status flag in the pre-applied connection table structure.
[0042] Furthermore, in step S5, the flag method for determining the state of the connection table predefines the variable flag, sets the flag value according to the actual state of the connection table in different parts of the program, uses an if statement to determine the flag value, and executes corresponding operations.
[0043] Furthermore, in step S6, an environment handle is pre-allocated, the allocated environment handle is used to create a connection handle, and the handle is used to allocate one or more statement handles to execute SQL statements. After executing the SQL statements, the returned status code is checked to determine whether the operation is successful.
[0044] Furthermore, when the network device is started, each NUMA node will pre-apply for a large memory block for the connection table;
[0045] Secondly, the memory size of the connection table requested by each NUMA node is determined by the number of NUMA nodes of the device, the connection table specifications, and the structure size of the connection table;
[0046] Finally, the starting address of the connection table memory pre-applied for each NUMA node is recorded.
[0047] Example 1
[0048] A method for managing a connection table based on a NUMA architecture, the management steps are:
[0049] S1. After the network device is started, the memory is divided into N NUMA nodes according to the configuration and associated with the processor;
[0050] S2. Calculate the connection table memory size that needs to be pre-applied for each NUMA node according to the connection table specification session_quota of the network device and the single connection table size session_size, and apply for the connection table memory on each NUMA node;
[0051] S3. After the device startup initialization is completed, the connection table resources and the starting address of the connection table resources of the network device are also initialized;
[0052] S4. After traffic enters the device, hashing is performed according to the five-tuple information of the traffic, and then the hash value and the number of link specifications of the corresponding NUMA node are taken as the memory for obtaining the connection table entry, and the connection table entry is established. The memory for obtaining the link table entry is stored in the connection table pre-applied in the respective NUMA nodes;
[0053] S5. After the traffic obtains the memory address of the connection table entry, the status flag of the corresponding connection table is immediately determined. If the status flag is valid, step S4 is re-executed to select a new connection table entry. If the status flag is invalid, the age of the connection table entry is increased by 1, and the status flag is set to valid, and the corresponding node information is recorded.
[0054] S6. After the connection table entry is obtained, a connection handle is established according to the connection table entry information, and the age field stored in the connection handle is used to determine the validity of the connection. If the connection is valid, the pointer to the connection table entry is obtained by converting the node_id and session_id fields stored in the connection handle to obtain the connection information.
[0055] Comparative Example 1
[0056] The connection table management method of the NUMA architecture also adopts the design concept based on the SMP architecture to manage the connection table resources in the NUMA architecture. The connection table resources are not divided into multiple resource blocks for management according to the characteristics of the NUMA architecture. At the same time, the creation and aging of the connection table resources are managed by ordinary memory application and release methods.
[0057] Comparative Example 2
[0058] The connection table management method of the NUMA architecture manages the connection table resources based on the NUMA architecture, and divides the connection table resources into multiple NUMA nodes. Although the CPU of each NUMA node can access all the memories, the CPU has the smallest delay when accessing the memory of the local NUMA node. The delay of accessing the memory of the remote node increases with the increase of the distance. However, the creation and aging of the connection table resources are managed by ordinary memory application and release.
[0059] Comparative Example 1 has three technical defects: first, the connection table resources are not managed in blocks according to the characteristics of the NUMA architecture, which will cause the CPU to access the connection table. The latency is extended and the performance is reduced; second, the memory is frequently applied and released for the creation and aging of the connection table resources, which will seriously affect the performance of the system; third, in the case of tight memory, the connection table specifications may not be fully used and the new connection table may fail to be created;
[0060] Comparative Example 2 has two technical defects: first, the creation and aging of connection table resources are managed by ordinary memory application and release, which will seriously affect the performance of the system; second, in the case of tight memory, the connection table specifications may not be used up and the creation of a new connection table may fail;
[0061] According to the analysis of the current prior art, Example 1 finds that the current mainstream connection table management technology under the NUMA architecture, especially the creation and aging of the connection table, will seriously affect the performance of the system. This can effectively alleviate the problem in the prior art that the creation and aging of the connection table will seriously affect the performance of the system and completely solve the problem that in the case of tight memory, the connection table specifications may not be used up and the table entry establishment may fail due to memory application failure.
[0062] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0063] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for connection table management based on NUMA architecture, characterized in that: The management steps are: S1. After the network device is started, the memory is divided into N NUMA nodes according to the configuration and associated with the processor; S2. Calculate the connection table memory size that needs to be pre-applied for each NUMA node according to the connection table specification session_quota of the network device and the single connection table size session_size, and apply for the connection table memory on each NUMA node; S3. After the device startup initialization is completed, the connection table resources and the starting address of the connection table resources of the network device are also initialized; S4. After traffic enters the device, hashing is performed according to the five-tuple information of the traffic, and then the hash value and the number of link specifications of the corresponding NUMA node are taken as the memory for obtaining the connection table entry, and the connection table entry is established. The memory for obtaining the link table entry is stored in the connection table pre-applied in the respective NUMA nodes; S5. After the traffic obtains the memory address of the connection table entry, the status flag of the corresponding connection table is immediately determined. If the status flag is valid, step S4 is re-executed to select a new connection table entry. If the status flag is invalid, the age of the connection table entry is increased by 1, and the status flag is set to valid, and the corresponding node information is recorded. S6. After the connection table entry is obtained, a connection handle is established according to the connection table entry information, and the age field stored in the connection handle is used to determine the validity of the connection. If the connection is valid, the pointer to the connection table entry is obtained by converting the node_id and session_id fields stored in the connection handle to obtain the connection information.
2. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: The division step in step S1 determines the number of NUMA nodes to be created based on the hardware configuration, which is completed through the kernel parameters and BIOS settings when the system is started to allocate memory to each node.
3. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: In step S2, the connection table memory size is: numa_session_size = session_size * session_quota / N. The method for calculating the connection table memory size that needs to be pre-applied for each NUMA node is to determine the data structure of the connection table by analyzing it, multiply the size of each connection item by the number of connections that need to be tracked at the same time, and obtain the total connection table memory requirement. Considering the NUMA architecture, it is determined that the connection table is distributed on the NUMA nodes, and memory is allocated; The starting address of the memory application is numa_session_address, and the starting address of each memory block is recorded as memory_area[i]=numa_session_address[i], where i represents the node of the i-th NUMA.
4. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: In step S3, the connection table structure includes the connection age, the connection status flag, and the NUMA node information node to which the connection belongs.
5. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: In step S4, the five-tuple information is hashed in advance to define the five-tuple, which includes the source IP address, the destination IP address, the source port number, the destination port number and the transport layer protocol. The MD5 hash function is selected to combine the five-tuple information into a binary representation, hash it, and concatenate it into a long integer to complete the combination. The MD5 hash function is used to generate a 128-bit hash value, which is 32 hexadecimal digits.
6. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: The connection handle in step S6 is another way to obtain the connection. The handle corresponds to the connection table entry. The connection handle includes the age of the connection table entry and the session_id of the connection. Part of the session_id information records the node information of NUMA and part records the offset of the pre-application connection table of the session in the corresponding NUMA.
7. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: The step of determining the validity of the connection in step S6 first obtains the NUMA node information and offset of the corresponding connection based on the session_id information recorded in the connection handle, finds the corresponding connection pointer based on the memory_area[i] address information recorded during initialization, and obtains the age information recorded in the connection table entry. If the age information recorded in the connection table entry is equal to the age information recorded in the connection handle and the connection status is valid, it means that the connection is valid, and the pointer to the connection table entry is obtained.
8. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: In step S5, the flag method for determining the state of the connection table predefines the variable flag. In different parts of the program, the flag value is set according to the actual state of the connection table, and the flag value is determined using an if statement to perform corresponding operations.
9. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: In step S6, an environment handle is pre-allocated, and the allocated environment handle is used to create a connection handle. The handle is used to allocate one or more statement handles to execute SQL statements. After executing the SQL statement, the returned status code is checked to determine whether the operation is successful.
10. The method and device for connection table management based on NUMA architecture according to claim 1, characterized in that: When the network device is started, each NUMA node will pre-apply for a large memory for use as a connection table.
