A network card allocation method, apparatus and electronic device
By dividing network interface cards (NICs) into different priority sets based on their affinity with services under a NUMA architecture and then sorting and selecting them, the memory access latency problem caused by improper NIC allocation is solved, thereby improving network communication efficiency and system performance.
Patent Information
- Application Number
- CN202412000435.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-31
AI Technical Summary
In the prior art, the selection of network interface cards (NICs) has not fully considered the multi-layered affinity relationship under the non-uniform memory access (NUMA) architecture, resulting in network services being assigned to unsuitable NICs, increasing memory access latency, and reducing the efficiency of system network communication.
By determining whether the target network interface card (NIC) is compatible with the access node and processor slot where the target service resides, NICs are divided into sets with different priorities, and then prioritized according to affinity to select the most suitable NIC for allocation.
It reduces memory access latency across NUMA nodes or slots, improves network communication efficiency, avoids resource waste and performance bottlenecks, and ensures optimal matching between services and network cards.
Smart Images

Figure CN119728432B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of information technology, and in particular to a network interface card (NIC) allocation method, apparatus, and electronic device. Background Technology
[0002] With the rapid development of information technology, data centers and high-performance computing (HPC) systems are increasingly demanding higher requirements for computing performance, network communication efficiency, and resource utilization. Modern server architectures widely adopt Non-Unified Memory Access (NUMA) architectures to improve the performance of multiprocessor systems.
[0003] In related technologies, network interface card (NIC) selection mostly adopts a simple polling or random strategy to determine resource allocation, which fails to fully consider the multi-layered affinity relationship between NUMA architecture services and NICs. This results in network services being assigned to unsuitable NICs, increasing memory access latency and reducing the overall network communication efficiency of the system. Summary of the Invention
[0004] This disclosure provides a network card allocation method, apparatus, and electronic device, aiming to solve the problems existing in the background art.
[0005] To solve the above-mentioned technical problems, this disclosure is implemented as follows:
[0006] In a first aspect, embodiments of this disclosure provide a network interface card (NIC) allocation method, the method comprising:
[0007] Determine whether the target network interface card (NIC) is compatible with the access node and / or processor socket where the target service is located, and based on the determination result, update the target NIC to the first NIC set, the second NIC set, or the third NIC set. The second NIC set includes NICs compatible with the processor socket where the target service is located, and the third NIC set includes NICs compatible with the access node where the target service is located.
[0008] From the first set of network interface cards (NICs), the second set of NICs, and the third set of NICs, the NIC with the highest priority is selected as the NIC to be allocated for the target service. Among them, the NICs in the first set of NICs have the lowest priority, and the NICs in the third set of NICs have the highest priority.
[0009] Optionally, determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0010] Check the pre-configured network card selection mode of the target network card, including the polling mode;
[0011] When the network interface card (NIC) selection mode is polling mode, it is determined that the target NIC is not compatible with the access node and processor slot where the target service is located, and the target NIC is updated to the first NIC set.
[0012] Optionally, determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0013] Check the pre-configured network card selection mode of the target network card, including the polling mode;
[0014] If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located;
[0015] If the identifier of the access node where the target service is located is invalid, it is determined that the target network card is not compatible with both the access node and the processor slot where the target service is located, and the target network card is updated to the first network card set.
[0016] Optionally, determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0017] Check the pre-configured network card selection mode of the target network card, including the polling mode;
[0018] If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located;
[0019] If the identifier of the access node where the target service is located is a valid value, obtain the identifier of the access node where the target network card is located;
[0020] Determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located;
[0021] If the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, it is determined that the target network card is compatible with the access node where the target service is located, and the target network card is updated to the third network card set.
[0022] Optionally, the method further includes:
[0023] If the identifier of the access node where the target service is located is different from the identifier of the access node where the target network card is located, the access node where the target service is located and the access node where the target network card is located are determined based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, respectively.
[0024] Determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor socket;
[0025] If the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket, it is determined that the target network card is not compatible with both the access node where the target service is located and the processor socket, and the target network card is updated to the first network card set;
[0026] If the access node where the target service is located and the access node where the target network card is located belong to the same processor socket, determine that the target network card is compatible with the processor socket where the target service is located, and update the target network card to the second network card set.
[0027] Optionally, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes:
[0028] Check the identifier of the target service;
[0029] If the identifier of the target service is a valid value, check the network card selection mode pre-configured for the target network card, which includes the affinity mode;
[0030] When the network interface card (NIC) selection mode is in affinity mode, a modulo operation is performed on the first NIC set, the second NIC set, and the third NIC set based on the identifier of the target service.
[0031] Based on the remainder obtained from the modulo operation, candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined, and the candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined as the network interfaces with the highest priority in each of the first network interface card set, the second network interface card set, and the third network interface card set.
[0032] Optionally, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes:
[0033] Check the identifier of the target service;
[0034] If the identifier of the target service is a valid value, check the network card selection mode pre-configured by the target network card, which includes an adaptive mode;
[0035] When the network card selection mode is adaptive mode, check whether the number of network cards connected to each processor slot on the server is the same;
[0036] When the number of network cards connected to each processor socket is different, the network cards in the first network card set, the second network card set, and the third network card set are aggregated into a new network card set;
[0037] Based on the identifier of the target service, perform a modulo operation on the new set of network interface cards;
[0038] Based on the remainder obtained from the modulo operation, candidate network cards for the target service are determined from the new set of network cards, and the candidate network cards for the target service are determined as the network cards with the highest priority among the first set of network cards, the second set of network cards, and the third set of network cards.
[0039] Optionally, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes:
[0040] Check the identifier of the target service;
[0041] If the identifier of the target service is a valid value, check the network card selection mode pre-configured by the target network card, which also includes an adaptive mode;
[0042] When the network card selection mode is adaptive mode, check whether the number of network cards connected to each processor slot on the server is the same;
[0043] When the number of network cards connected to each processor socket is the same, a modulo operation is performed on the first network card set, the second network card set, and the third network card set according to the identifier of the target service;
[0044] Based on the remainder obtained from the modulo operation, candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined, and the candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined as the network interfaces with the highest priority in each of the first network interface card set, the second network interface card set, and the third network interface card set.
[0045] Secondly, embodiments of this disclosure provide a network interface card (NIC) allocation device, the device comprising:
[0046] The judgment module is used to determine whether the target network card is compatible with the access node and / or processor socket where the target service is located, and based on the judgment result, update the target network card to a first network card set, a second network card set, or a third network card set. The first network card set includes network cards that are not compatible with either the access node or the processor socket where the target service is located. The second network card set includes network cards that are compatible with the processor socket where the target service is located. The third network card set includes network cards that are compatible with the access node where the target service is located.
[0047] The network interface card (NIC) allocation module is used to select the NIC with the highest priority from the first NIC set, the second NIC set, and the third NIC set as the NIC to be allocated for the target service, wherein the NICs in the first NIC set have the lowest priority and the NICs in the third NIC set have the highest priority.
[0048] Optionally, the determination module includes:
[0049] The first inspection submodule is used to inspect the network card selection mode pre-configured in the target network card, the network card selection mode including the polling mode;
[0050] The first determining submodule is used to determine, when the network card selection mode is polling mode, that the target network card is not compatible with the access node and processor slot where the target service is located, and to update the target network card to the first network card set.
[0051] Optionally, the determination module includes:
[0052] The second inspection submodule is used to inspect the network card selection mode pre-configured in the target network card, the network card selection mode including the polling mode;
[0053] The third inspection submodule is used to check the identifier of the access node where the target service is located when the network card selection mode is not polling mode.
[0054] The second determining submodule is used to determine, when the identifier of the access node where the target service is located is invalid, that the target network card is incompatible with both the access node and the processor slot where the target service is located, and to update the target network card to the first network card set.
[0055] Optionally, the determination module includes:
[0056] The third inspection submodule is used to check the network card selection mode pre-configured in the target network card, including the polling mode;
[0057] The fourth inspection submodule is used to check the identifier of the access node where the target service is located when the network card selection mode is not polling mode.
[0058] The acquisition submodule is used to acquire the identifier of the access node where the target network card is located, provided that the identifier of the access node where the target service is located is a valid value.
[0059] The judgment submodule is used to determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located;
[0060] The third determining submodule is used to determine the affinity between the target network card and the access node where the target service is located if the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, and update the target network card to the third network card set.
[0061] Optionally, the device further includes:
[0062] The access node determination module is used to determine the access node where the target service is located and the access node where the target network card is located, respectively, based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, when the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located are different.
[0063] The slot determination module is used to determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor slot.
[0064] The first update module is used to determine, when the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket, that the target network card is not compatible with both the access node where the target service is located and the processor socket, and to update the target network card to the first network card set.
[0065] The second update module is used to determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor socket, and update the target network card to the second network card set.
[0066] Optionally, the device further includes:
[0067] The first service identifier checking module is used to check the identifier of the target service;
[0068] The first network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode includes the affinity mode.
[0069] The first modulo module is used to perform a modulo operation on the first set of network cards, the second set of network cards, and the third set of network cards based on the identifier of the target service when the network card selection mode is affinity mode.
[0070] The first priority determination module is used to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set based on the remainder obtained by the remainder operation, and to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set as the network cards with the highest priority in each of the first network card set, the second network card set, and the third network card set.
[0071] Optionally, the device further includes:
[0072] The second service identifier checking module is used to check the identifier of the target service;
[0073] The second network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode includes an adaptive mode.
[0074] The first slot balancing check module is used to check whether the number of network cards connected to each processor slot on the server is the same when the network card selection mode is adaptive mode.
[0075] The aggregation module is used to aggregate network cards from the first set of network cards, the second set of network cards, and the third set of network cards into a new set of network cards when the number of network cards connected to each processor socket is different.
[0076] The second modulo module is used to perform a modulo operation on the new set of network interface cards based on the identifier of the target service.
[0077] The second update module is used to determine the candidate network interface card (NIC) for the target service from the new NIC set based on the remainder obtained by the modulo operation, and to determine the candidate NIC for the target service as the NIC with the highest priority among the first NIC set, the second NIC set, and the third NIC set.
[0078] Optionally, the device includes:
[0079] The third service identifier checking module is used to check the identifier of the target service;
[0080] The third network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode also includes an adaptive mode.
[0081] The second slot balancing check module is used to check whether the number of network cards connected to each processor slot on the server is the same when the network card selection mode is adaptive mode.
[0082] The third modulo module is used to perform a modulo operation on the first set of network cards, the second set of network cards, and the third set of network cards based on the identifier of the target service when the number of network cards connected to each processor slot is the same.
[0083] The third update module is used to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set according to the remainder obtained by the modulo operation, and to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set as the network cards with the highest priority in each of the first network card set, the second network card set, and the third network card set.
[0084] Thirdly, embodiments of this disclosure provide an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of a network interface card (NIC) allocation method.
[0085] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0086] This disclosure divides network interface cards (NICs) into multiple sets based on their affinity with the access node and processor slot where the target service resides. A priority ranking mechanism is used to preferentially select NICs with higher affinity to the target service for allocation. This reduces memory access latency across NUMA nodes or slots, thereby improving network communication efficiency. By dividing NICs into a first, second, and third set based on affinity and setting different priorities, more granular resource scheduling can be achieved. Compared to traditional round-robin or simple selection strategies, this disclosure considers multi-dimensional affinity relationships, ensuring that each service selects a NIC with the highest possible affinity, avoiding resource waste and performance bottlenecks. Through multi-level ranking and precise NIC selection, this disclosure ensures optimal matching between services and NICs, particularly improving service efficiency in complex environments with multiple NUMA nodes and multiple processor slots. Attached Figure Description
[0087] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0088] Figure 1 This is a flowchart illustrating the steps of a network card allocation method provided in an embodiment of this disclosure;
[0089] Figure 2 This is a schematic diagram illustrating the complete process of updating a set of network interface cards (NICs) according to an embodiment of this disclosure;
[0090] Figure 3 This is a complete flowchart illustrating the load balancing strategy for the network interface card (NIC) set provided in this embodiment.
[0091] Figure 4 This is a structural block diagram of a network card allocation device provided in an embodiment of this disclosure. Detailed Implementation
[0092] Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this disclosure. In the description of the embodiments in this disclosure, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. In this disclosure, "at least one" refers to one or more, and "more than one" refers to two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0093] In modern high-performance computing systems, especially in servers employing Non-Unified Memory Access (NUMA) architectures, the selection and allocation of Network Interface Cards (NICs) are crucial for improving system performance. In NUMA architectures, system memory is divided into multiple nodes, and different processor sockets (CPU sockets) have varying access latencies to local memory. Therefore, if the affinity between the processor running the service and the access node or socket to which the NIC is connected is not properly considered, unnecessary memory access latency may occur, significantly reducing network communication efficiency and overall system performance. Traditional NIC allocation methods mostly rely on simple polling or random selection strategies, which often ignore the differences in memory access in NUMA architectures and the affinity between services and NICs. Especially in complex multi-processor and multi-NUMA node systems, simple selection methods cannot fully utilize system resources, leading to network communication bottlenecks, load imbalances, and even service performance degradation. Therefore, the core idea of this disclosure is to determine and classify the affinity between the target NIC and the access node and processor socket where the target service resides, allocate NICs to different sets, and prioritize the allocation of NICs with higher affinity to the target service based on a priority mechanism. It can not only effectively reduce memory access latency, but also optimize system resource scheduling and improve overall network communication efficiency and service performance.
[0094] Figure 1 This is a flowchart illustrating the steps of a network card allocation method provided in an embodiment of this disclosure, as shown below. Figure 1 As shown, the method includes:
[0095] Step S101: Determine whether the target network card is compatible with the access node and / or processor slot where the target service is located, and based on the determination result, update the target network card to the first network card set, the second network card set, or the third network card set. The second network card set includes network cards compatible with the processor slot where the target service is located, and the third network card set includes network cards compatible with the access node where the target service is located.
[0096] The target service is a running computing task or application that needs to communicate with external networks or other computing nodes via a network interface card (NIC). In distributed computing or high-performance computing environments, services may be bound to a specific processor (CPU) or non-uniform memory access (NUMA) node. If a database service is bound to a specific processor socket, this disclosure proposes that, to improve performance, it is best to choose a NIC that is compatible with that processor socket and / or access node, thereby reducing latency across nodes or sockets.
[0097] "Affinity" refers to the compatibility between a network interface card (NIC) and the processor socket (CPU socket) and / or access node (NUMA node) of the target service. In a NUMA architecture, the system's physical memory is divided into multiple nodes, each associated with a specific processor socket. Determining the affinity between the target NIC and the access node of the target service, i.e., determining the NIC's node affinity, refers to the compatibility between the target NIC and the access node (NUMA node) of the target service. Each NUMA node corresponds to a specific processor socket and local memory; therefore, a NIC with good affinity should be located in the same or nearby physical location as the NUMA node of the target service to reduce cross-node access latency. Similarly, determining the affinity between the target NIC and the processor socket of the target service, i.e., determining the NIC's socket affinity, refers to the compatibility between the target NIC and the processor socket of the target service. In a NUMA architecture, processor sockets are highly correlated with local memory; a NIC with good affinity should be connected to the same physical location as the processor socket used by the target service.
[0098] In step S101, the affinity of the target network card with the access node and / or processor slot where the target service is located is determined, and the target network card is classified into the first network card set, the second network card set, or the third network card set accordingly.
[0099] The first set of network interface cards (NICs) includes all NICs with low affinity to the processor socket or access node where the target service resides. Specifically, these NICs do not have a clear affinity with the access node or processor socket of the target service. They are located on different NUMA nodes or are far from the socket / node where the target service resides, thus having low affinity. These NICs may be selected under resource constraints, but they have the lowest priority.
[0100] The second set of network interface cards (NICs) comprises those with affinity to the processor socket where the target service resides. In other words, these NICs are located on the same NUMA node as the processor socket where the target service resides, or at least are located close to the target socket, reducing memory access latency. Therefore, these NICs have higher affinity but lower priority than the third set.
[0101] The third set of network interface cards (NICs) includes those with affinity to the access node (NUMA node) where the target service resides. In other words, these NICs are located on the same NUMA node as the access node where the target service resides, or at least are closest to the target node, ensuring minimal memory access latency and optimal performance. These NICs have the highest affinity and the highest priority.
[0102] Step S102: Select the network card with the highest priority from the first set of network cards, the second set of network cards, and the third set of network cards as the network card to be allocated for the target service. The network cards in the first set of network cards have the lowest priority, and the network cards in the third set of network cards have the highest priority.
[0103] From three sets of network interface cards (NICs) (set 1, set 2, and set 3), the optimal NIC is selected in order of priority and ultimately assigned to the target service. First, NICs from the set 3 are considered. If the NICs in the set 3 cannot meet the actual application requirements (e.g., insufficient quantity or certain hardware limitations), then NICs from the set 2 are selected. NICs from the set 2 have better affinity with the processor socket where the target service resides, and although their affinity is not as high as the set 3, they still provide lower memory access latency than the set 1. If none of the first three sets meet the requirements, NICs from the set 1 are selected. NICs from the set 1 have lower hardware affinity with the target service, but as a last resort, they ensure the target service can continue to run. The NIC assigned to the target service will be used to handle requests from the target service to ensure its smooth operation and maximize performance.
[0104] This disclosure divides network interface cards (NICs) into multiple sets based on their affinity with the access node and processor slot where the target service resides. A priority ranking mechanism is used to preferentially select NICs with higher affinity to the target service for allocation. This reduces memory access latency across NUMA nodes or slots, thereby improving network communication efficiency. By dividing NICs into a first, second, and third set based on affinity and setting different priorities, more granular resource scheduling can be achieved. Compared to traditional round-robin or simple selection strategies, this disclosure considers multi-dimensional affinity relationships, ensuring that each service selects a NIC with the highest possible affinity, avoiding resource waste and performance bottlenecks. Through multi-level ranking and precise NIC selection, this disclosure ensures optimal matching between services and NICs, particularly improving service efficiency in complex environments with multiple NUMA nodes and multiple processor slots.
[0105] In one optional implementation, the step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0106] Step S201: Check the network card selection mode pre-configured for the target network card, the network card selection mode including polling mode.
[0107] The goal of affinity assessment is to check whether the target network card has a physical affinity with the access node (NUMA node) and / or processor socket (CPU socket) where the target service is located. Figure 2 This is a schematic diagram illustrating the complete process of updating a network interface card (NIC) set according to an embodiment of this disclosure. Please refer to [link / reference]. Figure 2 This disclosure takes into account that the network interface card (NIC) selection mode affects how to determine NIC affinity and how to assign NICs to target services. In other words, the NIC selection mode will affect the NIC classification and selection strategy. Therefore, this disclosure first determines the NIC selection mode in the affinity determination process.
[0108] Step S202: When the network card selection mode is polling mode, determine that the target network card is not compatible with the access node and processor slot where the target service is located, and update the target network card to the first network card set.
[0109] When the network interface card (NIC) selection mode is round-robin, all available NICs are checked sequentially and assigned to different services in order. Round-robin mode is used for load balancing and does not focus on NIC affinity with services; instead, it handles NIC allocation in a simple round-robin manner. In round-robin mode, the affinity between the NIC and the processor socket or access node where the target service resides is not considered. Even if the target NIC has poor affinity, no optimization is performed; NICs are assigned according to the round-robin order. In round-robin mode, the target NIC is allowed to be assigned to hardware resources that are not perfectly matched to the target service. Therefore, when the NIC selection mode is round-robin, if it is determined that the target NIC is incompatible with both the access node and processor socket of the target service, the target NIC will be classified into the first set of NICs.
[0110] In one optional implementation, the step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0111] Step S301: Check the network card selection mode pre-configured for the target network card, the network card selection mode including polling mode.
[0112] Step S302: If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located.
[0113] As mentioned earlier, if the network interface card (NIC) selection mode is round-robin, the affinity between the target NIC and the processor socket or access node where the target service resides will not be considered. Instead, the target NIC will be placed in the first set of NICs (the least priority set), indicating that the target NIC has low affinity. However, in NIC selection modes other than round-robin (non-round-robin mode), a more detailed affinity judgment is required.
[0114] Please see Figure 2 When the network interface card (NIC) selection mode is not in polling mode, a more detailed affinity determination process is initiated. First, the identifier of the access node where the target service resides is determined. Each NUMA node has an identifier representing its location and attributes within the system, used to identify a specific physical location or region (e.g., the location of the processor socket). If the identifier of the access node where the target service resides is valid (e.g., a positive integer representing a specific NUMA node), this identifier can be used to determine whether the target NIC is affiliated with the access node where the target service resides, further determining the allocation priority of the target NIC.
[0115] Step S303: If the identifier of the access node where the target service is located is invalid, determine that the target network card is not compatible with the access node and processor slot where the target service is located, and update the target network card to the first network card set.
[0116] If the identifier of the access node where the target service resides is invalid (e.g., -1), it means that the access node where the target service resides cannot be effectively determined, and node affinity cannot be used for judgment. Therefore, it is impossible to determine whether the target network card (NIC) is compatible with the access node or processor socket where the target service resides. When the identifier is invalid, it indicates that the information of the access node is unavailable or cannot be confirmed, so the affinity between the target NIC and the access node and / or processor socket where the target service resides cannot be determined. In this case, it is assumed that the target NIC has no affinity with either the access node or the processor socket where the target service resides. Since there is no affinity to speak of, the target NIC is classified into the first set of NICs.
[0117] The above steps ensure that network card allocation can continue even when affinity cannot be determined, while minimizing the possibility of making unreasonable network card selections without optimizing affinity.
[0118] In one optional implementation, the step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes:
[0119] Step S401: Check the network card selection mode pre-configured for the target network card, the network card selection mode including polling mode.
[0120] Step S402: If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located.
[0121] Steps S401 to S402 are implemented in the same way as steps S301 to S302, and will not be described again here.
[0122] Step S403: If the identifier of the access node where the target service is located is a valid value, obtain the identifier of the access node where the target network card is located.
[0123] Each network interface card (NIC) is also mapped to a specific NUMA node. After obtaining the access node identifier of the target NIC, it can be compared with the node where the target service is located to see if they are the same.
[0124] Step S404: Determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located.
[0125] Step S405: If the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, determine that the target network card is compatible with the access node where the target service is located, and update the target network card to the third network card set.
[0126] If the identifier of the access node where the target service resides is the same as the identifier of the access node where the target network interface card (NIC) resides, it indicates that there is good affinity between the target NIC and the target service. This means they reside on the same NUMA node, can share faster local memory, and reduce cross-node access latency. In this case, the NIC has high affinity with the target service, and the target NIC is considered suitable for the target service and is classified into the third set of NICs.
[0127] In an optional implementation, the method further includes:
[0128] If the identifier of the access node where the target service is located is different from the identifier of the access node where the target network card is located, the access node where the target service is located and the access node where the target network card is located are determined based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, respectively. It is then determined whether the access node where the target service is located and the access node where the target network card is located belong to the same processor socket. If the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket, it is determined that the target network card is not compatible with either the access node where the target service is located or the processor socket, and the target network card is updated to the first network card set. If the access node where the target service is located and the access node where the target network card is located belong to the same processor socket, it is determined that the target network card is compatible with the processor socket where the target service is located, and the target network card is updated to the second network card set.
[0129] Determine if the identifier of the access node where the target service resides is the same as the identifier of the access node where the target network interface card (NIC) resides. If these two identifiers are different, it is necessary to determine the specific physical access node corresponding to each identifier. The purpose is to clarify which NUMA node the target NIC and the target service reside on, thereby understanding their affinity.
[0130] Please see Figure 2 Next, it's determined whether the two access nodes reside in the same processor socket. In other words, it's necessary to determine if the two nodes belong to the same physical processor. The basis for this determination is that each NUMA node corresponds to a specific processor socket. If two access nodes belong to the same processor socket, their affinity is high. If the access node where the target service resides and the access node where the target network interface card (NIC) resides do not belong to the same processor socket, it indicates poor hardware affinity between the target NIC and the target service. Based on this situation, it's determined that there is no affinity between the target NIC and the access node or processor socket of the target service; therefore, the target NIC is assigned to the first set of NICs. Thus, in subsequent NIC allocation processes, the target NIC will be the last option considered.
[0131] If the access node hosting the target service and the access node hosting the target network interface card (NIC) belong to the same processor socket, then there is physical socket-level affinity between these two nodes. In this case, the affinity between the target NIC and the processor socket hosting the target service is good, reducing memory access latency, and therefore the NIC is considered suitable for the target service. At this point, the target NIC is updated to the second NIC set.
[0132] In an optional implementation, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated to the target service, the method further includes: checking the identifier of the target service; if the identifier of the target service is a valid value, checking the NIC selection mode pre-configured by the target NIC, the NIC selection mode including an affinity mode; if the NIC selection mode is an affinity mode, performing a modulo operation on the first set of NICs, the second set of NICs, and the third set of NICs according to the identifier of the target service; determining the candidate NICs of the target service in the first set of NICs, the second set of NICs, and the third set of NICs according to the remainder obtained from the modulo operation, and determining the candidate NICs of the target service in the first set of NICs, the second set of NICs, and the third set of NICs as the NICs with the highest priority in each of the first set of NICs, the second set of NICs, and the third set of NICs.
[0133] The preceding text explained how the network interface card (NIC) sets with different priorities are updated. Here, this disclosure takes into account the load balancing scheme within the NIC sets, aiming to determine the load balancing strategy for determining the final allocation of NICs for multiple services before the actual application of the first, second, and third NIC sets.
[0134] Figure 3 This is a complete flowchart illustrating the load balancing strategy for network interface card (NIC) sets provided in this embodiment. It verifies the validity of the target service's identifier (ID), similar to the identifier of the access node where the target service resides. A valid identifier indicates that the target service can be processed, while an invalid identifier indicates that the service cannot be processed or does not require NIC allocation. If the target service's identifier is valid, the target NIC selection mode is then checked. The affinity mode prioritizes NICs with high affinity to the target service. In practical implementation, load balancing must also be considered, i.e., a reasonable selection among multiple affinity NICs. When the NIC selection mode is affinity mode, a modulo operation is performed for each NIC set (first NIC set, second NIC set, third NIC set). That is, for each NIC set, an allocation method is performed based on the target service's identifier to ensure load balance. The modulo operation involves dividing the target service's identifier by the NIC values in the NIC set to obtain a remainder. Then, based on this remainder, candidate NICs in each NIC set are determined. Candidate NICs are determined based on the result of the modulo operation. These candidate network interface cards (NICs) will be assigned as the highest priority NICs in each NIC set. Within each NIC set, the priority of each set is redefined through a modulo operation and the selection of candidate NICs. This ensures load balancing and prevents some NICs from being overused or experiencing uneven load distribution.
[0135] For example, the target service identifier is S123, and the current network interface card (NIC) selection mode is affinity mode. The first NIC set contains NICs N1, N2, and N3. The second NIC set contains NICs N4, N5, and N6. The third NIC set contains NICs N7, N8, and N9. The size of the first, second, and third NIC sets is 3. Based on the target service identifier S123, its numerical part (i.e., 123) can be used to perform a modulo operation on the size (3) of each NIC set. The modulo operation on the first NIC set yields 123 % 3 = 0. The modulo operation on the second NIC set yields 123 % 3 = 0. The modulo operation on the third NIC set yields 123 % 3 = 0. Since the remainder is 0, the first NIC in each set is selected as a candidate NIC, that is, the candidate NIC in the first NIC set is N1, the candidate NIC in the second NIC set is N4, and the candidate NIC in the third NIC set is N7. The first set of network interface cards (NICs) identifies NIC N1 as the highest priority NIC internally, the second set identifies NIC N4 as the highest priority NIC internally, and the third set identifies NIC N7 as the highest priority NIC internally. Finally, the highest priority NIC is selected from these three sets for allocation.
[0136] In an optional implementation, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated to the target service, the method further includes: checking the identifier of the target service; if the identifier of the target service is a valid value, checking the NIC selection mode pre-configured by the target NIC, the NIC selection mode including an adaptive mode; if the NIC selection mode is an adaptive mode, checking whether the number of NICs connected to each processor slot on the server is the same; if the number of NICs connected to each processor slot is different, aggregating the NICs in the first set of NICs, the second set of NICs, and the third set of NICs into a new set of NICs; performing a modulo operation on the new set of NICs according to the identifier of the target service; determining the candidate NIC of the target service from the new set of NICs according to the remainder obtained from the modulo operation, and determining the candidate NIC of the target service as the NIC with the highest priority among the first set of NICs, the second set of NICs, and the third set of NICs.
[0137] In adaptive mode, network interface cards (NICs) are dynamically selected based on the current load and resource availability, rather than relying solely on static affinity or priority. Therefore, when adaptive NIC selection is enabled, the number of NICs connected to each processor socket (CPU socket) on the server is further examined. If the number of NICs on each socket is different, it indicates an unbalanced resource configuration across the sockets, which may affect load balancing, potentially causing some NICs to be overloaded while others remain idle. If the number of NICs connected to each processor socket is the same, it indicates a relatively balanced resource configuration, and higher-priority NICs can be selected. If the numbers are different, proceed to the next step to adjust the NIC set for load balancing.
[0138] Please see Figure 3 If the number of network interface cards (NICs) on different processor sockets is not the same, the NICs from the first, second, and third NIC sets can be aggregated into a new NIC set, or into any one of the first, second, and third NIC sets. The purpose of this is to break down the boundaries between different NIC sets, consider load balancing from a global perspective, and ensure that subsequent selections do not favor any particular set, thereby avoiding the problem of some NICs being overloaded.
[0139] Next, a modulo operation is performed on the new set of network interface cards (NICs) based on the identifier of the target service. The purpose of this modulo operation is to divide each NIC set using the numerical part of the target service identifier, ensuring a certain distribution and balance in the selection of each NIC. Based on the result of the modulo operation, candidate NICs for the target service are determined from the new NIC sets. These candidate NICs are set as the highest priority NICs for subsequent allocation. This is because, in cases of slot imbalance, adaptive mode can adjust the load distribution across NICs. One of the core purposes of adaptive mode is to dynamically adjust NIC allocation based on the server's load. For example, if more NICs are connected to certain processor slots, it may lead to higher loads on these NICs. The system will adjust this through adaptive mode to ensure that each NIC can reasonably share the load. Therefore, under dynamic load, candidate NICs are allocated to the target service based on its identifier, avoiding overloading of any single NIC or slot. Ultimately, the candidate NIC, as the most suitable NIC for the target service, is the highest priority NIC among all NICs in the first, second, and third NIC sets.
[0140] For example, assume the target service identifier is S123 (the identifier is valid, the target service can continue processing), and the network interface card (NIC) selection mode is adaptive. The first NIC set includes NICs N1, N2, and N3; the second NIC set includes NICs N4, N5, and N6; and the third NIC set includes NICs N7, N8, and N9 (which have the highest affinity with the access node where the target service resides). Also assume there are two processor slots, P1 and P2, each connected to a different number of NICs: P1 has two NICs connected (N1 and N2), and P2 has one NIC connected (N3).
[0141] Slot P1 has two network cards connected, and slot P2 has one network card connected, indicating an uneven distribution of network cards. The network cards from the first, second, and third network card sets are combined into a new network card set containing network cards N1, N2, N3, N4, N5, N6, N7, N8, and N9. The numerical part of the identifier S123 for the target service is 123, so 123 % 9 = 6. Based on the remainder of 6, the 6th network card is selected from the new network card set as a candidate network card, namely N6. Network card N6 is determined as a candidate network card and set as the highest priority network card.
[0142] In an optional implementation, before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated to the target service, the method further includes: checking the identifier of the target service; if the identifier of the target service is a valid value, checking the NIC selection mode pre-configured by the target NIC, the NIC selection mode further including an adaptive mode; if the NIC selection mode is an adaptive mode, checking whether the number of NICs connected to each processor slot on the server is the same; if the number of NICs connected to each processor slot is the same, performing a modulo operation on the first set of NICs, the second set of NICs, and the third set of NICs according to the identifier of the target service; determining the candidate NICs of the target service in the first set of NICs, the second set of NICs, and the third set of NICs according to the remainder obtained from the modulo operation, and determining the candidate NICs of the target service in the first set of NICs, the second set of NICs, and the third set of NICs as the NICs with the highest priority in each of the first set of NICs, the second set of NICs, and the third set of NICs.
[0143] With the same number of network interface cards (NICs) connected to each processor socket, the distribution of NICs is relatively balanced, with no significant load imbalance. Therefore, adaptive mode is not needed to dynamically adjust NICs; instead, static NIC selection can be performed based on the affinity (i.e., the priority among the three NIC sets) considered earlier. Similarly, candidate NICs are determined by taking the remainder of the NIC set based on the identifier of the target service, as explained in detail with examples earlier, and will not be repeated here.
[0144] The dynamic load balancing technology disclosed herein, when applied to multi-NIC systems, significantly improves system resource utilization efficiency and ensures load balance across NICs by dynamically adjusting NIC load distribution in adaptive NIC selection mode. This dynamic load distribution strategy enables the system to automatically adjust NIC allocation even when resource configuration is uneven, ensuring each NIC can handle a reasonable load and avoiding the load imbalance problems that may occur with traditional static allocation methods. Furthermore, the adaptive load balancing technology provided herein flexibly selects the most suitable NIC for the target service based on the NIC selection mode and actual hardware resource conditions. This dynamic adjustment under actual load optimizes network resource allocation and ensures the efficient and stable operation of the target service.
[0145] In an optional implementation, the method further includes: when the network interface card (NIC) selection mode is affinity mode or adaptive mode, monitoring the load of each NIC in each NIC set in real time, including network traffic, packet loss rate, and latency; when the identifier of the target service is valid and the selection mode is affinity mode or adaptive mode, if the NIC load in a certain NIC set exceeds a preset threshold, adjusting the priority of the NIC set, downgrading the NICs in that NIC set to a lower priority set, and promoting the NICs with lower loads in other sets to candidate NICs; in the NIC sets with lower loads, performing a modulo operation based on the identifier of the target service, thereby selecting a new NIC with the highest priority as the NIC allocated to the target service.
[0146] When the network interface card (NIC) selection mode is in affinity or adaptive mode, the NIC load is continuously monitored. Parameters characterizing the NIC load include network traffic, packet loss rate, and latency, which can be weighted to obtain the corresponding load values. The load value of each NIC is compared with a preset threshold, which can be configured based on factors such as the NIC's maximum bandwidth and performance metrics. When the load of a NIC in a set exceeds the threshold, the priority of that set is adjusted. That is, the NIC will be downgraded to a lower priority set (e.g., from the second set to the first set) to prevent it from continuing to bear excessive load. Simultaneously, NICs with lower loads in other sets are promoted as candidate NICs to better distribute the load. Within the set of NICs with lower loads, a modulo operation is performed based on the identifier of the target service. Based on the result of the modulo operation, the highest priority NIC is selected from the set of NICs with lower loads as the NIC to be allocated to the target service.
[0147] By dynamically adjusting network interface card (NIC) selection priorities, overloading of individual NICs can be avoided, reducing network congestion and latency, and improving overall system performance. Under high load conditions, NICs with lower loads can be prioritized for resource scheduling, enhancing the system's adaptability. This allows for more intelligent management of NIC resources, ensuring network performance remains optimized even in changing environments.
[0148] Figure 4 This is a structural block diagram of a network card allocation device provided in an embodiment of this disclosure, such as... Figure 4 As shown, the device includes:
[0149] The judgment module 501 is used to determine whether the target network card is compatible with the access node and / or processor socket where the target service is located, and based on the judgment result, update the target network card to a first network card set, a second network card set, or a third network card set. The first network card set includes network cards that are not compatible with either the access node or the processor socket where the target service is located. The second network card set includes network cards that are compatible with the processor socket where the target service is located. The third network card set includes network cards that are compatible with the access node where the target service is located.
[0150] The network interface card (NIC) allocation module 502 is used to select the NIC with the highest priority from the first NIC set, the second NIC set, and the third NIC set as the NIC to be allocated for the target service, wherein the NICs in the first NIC set have the lowest priority and the NICs in the third NIC set have the highest priority.
[0151] In one optional implementation, the determination module includes:
[0152] The first inspection submodule is used to inspect the network card selection mode pre-configured in the target network card, the network card selection mode including the polling mode;
[0153] The first determining submodule is used to determine, when the network card selection mode is polling mode, that the target network card is not compatible with the access node and processor slot where the target service is located, and to update the target network card to the first network card set.
[0154] In one optional implementation, the determination module includes:
[0155] The second inspection submodule is used to inspect the network card selection mode pre-configured in the target network card, the network card selection mode including the polling mode;
[0156] The third inspection submodule is used to check the identifier of the access node where the target service is located when the network card selection mode is not polling mode.
[0157] The second determining submodule is used to determine, when the identifier of the access node where the target service is located is invalid, that the target network card is incompatible with both the access node and the processor slot where the target service is located, and to update the target network card to the first network card set.
[0158] In one optional implementation, the determination module includes:
[0159] The third inspection submodule is used to check the network card selection mode pre-configured in the target network card, including the polling mode;
[0160] The fourth inspection submodule is used to check the identifier of the access node where the target service is located when the network card selection mode is not polling mode.
[0161] The acquisition submodule is used to acquire the identifier of the access node where the target network card is located, provided that the identifier of the access node where the target service is located is a valid value.
[0162] The judgment submodule is used to determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located;
[0163] The third determining submodule is used to determine the affinity between the target network card and the access node where the target service is located if the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, and update the target network card to the third network card set.
[0164] In one alternative embodiment, the device further includes:
[0165] The access node determination module is used to determine the access node where the target service is located and the access node where the target network card is located, respectively, based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, when the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located are different.
[0166] The slot determination module is used to determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor slot.
[0167] The first update module is used to determine, when the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket, that the target network card is not compatible with both the access node where the target service is located and the processor socket, and to update the target network card to the first network card set.
[0168] The second update module is used to determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor socket, and update the target network card to the second network card set.
[0169] In one alternative embodiment, the device further includes:
[0170] The first service identifier checking module is used to check the identifier of the target service;
[0171] The first network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode includes the affinity mode.
[0172] The first modulo module is used to perform a modulo operation on the first set of network cards, the second set of network cards, and the third set of network cards based on the identifier of the target service when the network card selection mode is affinity mode.
[0173] The first priority determination module is used to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set based on the remainder obtained by the remainder operation, and to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set as the network cards with the highest priority in each of the first network card set, the second network card set, and the third network card set.
[0174] In one alternative embodiment, the device further includes:
[0175] The second service identifier checking module is used to check the identifier of the target service;
[0176] The second network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode includes an adaptive mode.
[0177] The first slot balancing check module is used to check whether the number of network cards connected to each processor slot on the server is the same when the network card selection mode is adaptive mode.
[0178] The aggregation module is used to aggregate network cards from the first set of network cards, the second set of network cards, and the third set of network cards into a new set of network cards when the number of network cards connected to each processor socket is different.
[0179] The second modulo module is used to perform a modulo operation on the new set of network interface cards based on the identifier of the target service.
[0180] The second update module is used to determine the candidate network interface card (NIC) for the target service from the new NIC set based on the remainder obtained by the modulo operation, and to determine the candidate NIC for the target service as the NIC with the highest priority among the first NIC set, the second NIC set, and the third NIC set.
[0181] In one alternative embodiment, the device includes:
[0182] The third service identifier checking module is used to check the identifier of the target service;
[0183] The third network interface card (NIC) selection mode checking module is used to check the NIC selection mode pre-configured in the target NIC when the identifier of the target service is a valid value. The NIC selection mode also includes an adaptive mode.
[0184] The second slot balancing check module is used to check whether the number of network cards connected to each processor slot on the server is the same when the network card selection mode is adaptive mode.
[0185] The third modulo module is used to perform a modulo operation on the first set of network cards, the second set of network cards, and the third set of network cards based on the identifier of the target service when the number of network cards connected to each processor slot is the same.
[0186] The third update module is used to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set according to the remainder obtained by the modulo operation, and to determine the candidate network cards of the target service in the first network card set, the second network card set, and the third network card set as the network cards with the highest priority in each of the first network card set, the second network card set, and the third network card set.
[0187] This disclosure also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes described above in an embodiment of a network card allocation method and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0188] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, apparatus, electronic devices, and storage media. Therefore, embodiments of this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this disclosure can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0189] This disclosure describes embodiments of methods and systems according to embodiments of this disclosure with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 a process or multiple processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 a process or multiple processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0190] While preferred embodiments of the present disclosure have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the present disclosure.
[0191] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the term "comprising" or any other variations thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element. The above provides a detailed description of a network card allocation method, apparatus, and electronic device provided by this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas; at the same time, for those skilled in the art, based on the ideas of this disclosure, there will be changes in specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this disclosure.
Claims
1. A network card allocation method, characterized in that, The method includes: Determine whether the target network interface card (NIC) is compatible with the access node and / or processor socket where the target service is located, and based on the determination result, update the target NIC to a first NIC set, a second NIC set, or a third NIC set. The first NIC set includes NICs that are not compatible with either the access node or the processor socket where the target service is located. The second NIC set includes NICs that are compatible with the processor socket where the target service is located. The third NIC set includes NICs that are compatible with the access node where the target service is located. From the first set of network interface cards (NICs), the second set of NICs, and the third set of NICs, the NIC with the highest priority is selected as the NIC to be allocated for the target service. Among them, the NICs in the first set of NICs have the lowest priority, and the NICs in the third set of NICs have the highest priority. The step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes: Check the pre-configured network card selection mode of the target network card, including the polling mode; If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located; If the identifier of the access node where the target service is located is a valid value, obtain the identifier of the access node where the target network card is located; Determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located; If the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, it is determined that the target network card is compatible with the access node where the target service is located, and the target network card is updated to the third network card set; The method further includes: If the identifier of the access node where the target service is located is different from the identifier of the access node where the target network card is located, the access node where the target service is located and the access node where the target network card is located are determined based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, respectively. Determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor socket; If the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket, it is determined that the target network card is not compatible with both the access node where the target service is located and the processor socket, and the target network card is updated to the first network card set; If the access node where the target service is located and the access node where the target network card is located belong to the same processor socket, it is determined that the target network card is compatible with the processor socket where the target service is located, and the target network card is updated to the second network card set.
2. The method according to claim 1, characterized in that, The step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes: Check the pre-configured network card selection mode of the target network card, including the polling mode; When the network interface card (NIC) selection mode is polling mode, it is determined that the target NIC is not compatible with the access node and processor slot where the target service is located, and the target NIC is updated to the first NIC set.
3. The method according to claim 1, characterized in that, The step of determining whether the target network interface card (NIC) is compatible with the access node and / or processor slot where the target service resides, and updating the target NIC to the first NIC set, the second NIC set, or the third NIC set based on the determination result, includes: Check the pre-configured network card selection mode of the target network card, including the polling mode; If the network card selection mode is not a polling mode, check the identifier of the access node where the target service is located; If the identifier of the access node where the target service is located is invalid, it is determined that the target network card is not compatible with both the access node and the processor slot where the target service is located, and the target network card is updated to the first network card set.
4. The method according to claim 1, characterized in that, Before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes: Check the identifier of the target service; If the identifier of the target service is a valid value, check the network card selection mode pre-configured for the target network card, which includes the affinity mode; When the network interface card (NIC) selection mode is in affinity mode, the remainder operation is performed on the number of NICs in the first NIC set, the second NIC set, and the third NIC set according to the identifier of the target service. Based on the remainder obtained from the modulo operation, candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined, and the candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined as the network interfaces with the highest priority in each of the first network interface card set, the second network interface card set, and the third network interface card set.
5. The method according to claim 1, wherein Before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes: Check the identifier of the target service; If the identifier of the target service is a valid value, check the network card selection mode pre-configured by the target network card, which includes an adaptive mode; When the network card selection mode is adaptive, check whether the number of network cards connected to each processor slot on the server is the same; When the number of network cards connected to each processor socket is different, the network cards in the first network card set, the second network card set, and the third network card set are aggregated into a new network card set; Based on the identifier of the target service, perform a modulo operation on the number of network cards in the new network card set; Based on the remainder obtained from the modulo operation, candidate network cards for the target service are determined from the new set of network cards, and the candidate network cards for the target service are determined as the network cards with the highest priority among the first set of network cards, the second set of network cards, and the third set of network cards.
6. The method according to claim 2, characterized in that, Before selecting the network interface card (NIC) with the highest priority from the first set of NICs, the second set of NICs, and the third set of NICs as the NIC to be allocated for the target service, the method further includes: Check the identifier of the target service; If the identifier of the target service is a valid value, check the network card selection mode pre-configured by the target network card, which also includes an adaptive mode; When the network card selection mode is adaptive, check whether the number of network cards connected to each processor slot on the server is the same; When the number of network cards connected to each processor socket is the same, the remainder of the number of network cards in the first set of network cards, the second set of network cards, and the third set of network cards is calculated based on the identifier of the target service. Based on the remainder obtained from the modulo operation, candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined, and the candidate network interfaces for the target service in the first network interface card set, the second network interface card set, and the third network interface card set are determined as the network interfaces with the highest priority in each of the first network interface card set, the second network interface card set, and the third network interface card set.
7. A network card allocation device, characterized in that, The device includes: The judgment module is used to determine whether the target network card is compatible with the access node and / or processor socket where the target service is located, and based on the judgment result, update the target network card to a first network card set, a second network card set, or a third network card set. The first network card set includes network cards that are not compatible with either the access node or the processor socket where the target service is located. The second network card set includes network cards that are compatible with the processor socket where the target service is located. The third network card set includes network cards that are compatible with the access node where the target service is located. The network interface card (NIC) allocation module is used to select the NIC with the highest priority from the first NIC set, the second NIC set, and the third NIC set as the NIC to be allocated for the target service, wherein the NICs in the first NIC set have the lowest priority and the NICs in the third NIC set have the highest priority. The judgment module includes: The third inspection submodule is used to check the network card selection mode pre-configured in the target network card, including the polling mode; The fourth inspection submodule is used to check the identifier of the access node where the target service is located when the network card selection mode is not polling mode. The acquisition submodule is used to acquire the identifier of the access node where the target network card is located, provided that the identifier of the access node where the target service is located is a valid value. The judgment submodule is used to determine whether the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located; The third determining submodule is used to determine the affinity between the target network card and the access node where the target service is located when the identifier of the access node where the target service is located is the same as the identifier of the access node where the target network card is located, and update the target network card to the third network card set. The device further includes: The access node determination module is used to determine the access node where the target service is located and the access node where the target network card is located, respectively, based on the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located, when the identifier of the access node where the target service is located and the identifier of the access node where the target network card is located are different. The slot determination module is used to determine whether the access node where the target service is located and the access node where the target network card is located belong to the same processor slot. The first update module is used to determine that the target network card is not compatible with both the access node where the target service is located and the access node where the target network card is located, and update the target network card to the first network card set when the access node where the target service is located and the access node where the target network card is located do not belong to the same processor socket. The second update module is used to determine that the target network card is compatible with the processor socket where the target service is located, and update the target network card to the second network card set, when the access node where the target service is located and the access node where the target network card is located belong to the same processor socket.
8. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Network card selection method and system, electronic equipment and medium
CN115733800A
Empirical determination of adapter affinity in high performance computing (HPC) environment
US20160034312A1