Traffic distribution method, device, apparatus and storage medium

By dynamically allocating and migrating traffic connections on the CPU based on the load factor, the problem of unbalanced traffic connections in existing technologies is solved, achieving more efficient CPU load balancing and intelligent migration.

CN117170867BActive Publication Date: 2026-05-19CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2023-09-01
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In existing technologies, the traffic connections allocated on the CPU are not balanced, which affects processing performance and the migration process takes a long time.

Method used

By obtaining the CPU load factor at preset intervals, new traffic connections are allocated to the CPU with the lowest load factor based on the load factor, and when the load factor change rate exceeds a threshold, traffic connections with the highest load factor are migrated to the CPU with the lowest load factor.

Benefits of technology

It improves the balance of traffic connections on the CPU, reduces the reliance of migration on users, and enhances processing performance and intelligence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117170867B_ABST
    Figure CN117170867B_ABST
Patent Text Reader

Abstract

The application provides a flow distribution method and device, equipment and a storage medium. The method comprises the following steps: every preset time length, a plurality of central processing units (CPUs) currently specified by a storage performance development kit (SPDK) iSCSI service are acquired. When a new flow connection appears, according to the current load coefficient of each CPU, the flow connection is distributed to the CPU with the minimum current load coefficient. When no new flow connection appears, according to the current load coefficient of each CPU, the flow connection connected to the CPU corresponding to the maximum load coefficient is migrated to the CPU corresponding to the minimum load coefficient. The application improves the balance of flow distribution on the CPU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a method, apparatus, device and storage medium for traffic allocation. Background Technology

[0002] The Storage Performance Development Kit (SPDK) specifies multiple Central Processing Units (CPUs) and achieves CPU load balancing by reasonably allocating the traffic accessed to each CPU.

[0003] In existing technologies, traffic connections are evenly distributed across different CPUs based on the number of traffic connections that each CPU can handle. The number of traffic connections that each CPU can handle is essentially the same.

[0004] However, existing technologies do not distribute bandwidth connections evenly across the CPU. Summary of the Invention

[0005] This application provides a method, apparatus, device, and storage medium for allocating traffic, in order to solve the technical problem of uneven traffic connections allocated on the CPU in the prior art.

[0006] Firstly, this application provides a method for allocating traffic, comprising:

[0007] At preset intervals, obtain the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service.

[0008] When a new traffic connection is added, the traffic connection is allocated to the CPU with the lowest current load factor based on the current load factor of each CPU.

[0009] When no new traffic connections are added, the traffic connections already connected on the CPU with the highest load factor are migrated to the CPU with the lowest load factor, based on the current load factor of each CPU.

[0010] Alternatively, the method described above,

[0011] The process of acquiring the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service at preset intervals includes:

[0012] Every preset time interval, obtain the current busy parameter value of each CPU specified by the SPDK iSCSI service and the traffic bandwidth allocated to each thread under each CPU. The busy parameter value is the operating parameter of the CPU resource.

[0013] The current load factor of each CPU is determined based on the current busy parameter value of each CPU and the bandwidth allocated to each thread under each CPU.

[0014] Get the current load factor of multiple CPUs specified by the SPDK iSCSI service.

[0015] Optionally, in the method described above, allocating the traffic connection to the CPU with the lowest current load factor based on the current load factor of each CPU includes:

[0016] Based on the current load factor of each CPU, determine the CPU with the lowest current load factor;

[0017] Based on the bandwidth allocated to each thread under the CPU with the lowest current load factor, determine the first target thread corresponding to the minimum bandwidth value;

[0018] The traffic connection is assigned to the first target thread.

[0019] Optionally, in the method described above, migrating the traffic connections already connected on the CPU with the highest load factor to the CPU with the lowest load factor based on the current load factor of each CPU includes:

[0020] Based on the current load factor of each CPU, sort the current load factors of each CPU by size to determine the maximum load factor and the minimum load factor;

[0021] The load factor change rate is determined based on the maximum load factor and the minimum load factor.

[0022] When the rate of change of the load factor exceeds a preset threshold, the traffic connections accessed on the CPU corresponding to the maximum load factor are migrated to the CPU corresponding to the minimum load factor.

[0023] Optionally, in the method described above, determining the load factor change rate based on the maximum load factor and the minimum load factor includes:

[0024] Calculate the difference between the maximum load factor and the minimum load factor based on the maximum load factor and the minimum load factor;

[0025] The ratio of the difference to the maximum load factor is determined as the load factor change rate.

[0026] Optionally, in the method described above, the step of migrating the traffic connections already connected on the CPU corresponding to the maximum load factor to the CPU corresponding to the minimum load factor when the load factor change rate exceeds a preset threshold includes:

[0027] Based on the bandwidth allocated to each thread under the CPU corresponding to the maximum load coefficient, determine the second target thread corresponding to the minimum bandwidth.

[0028] The second target thread and the traffic connections connected to the second target thread are migrated to the CPU corresponding to the minimum load factor.

[0029] Optionally, in the method described above, before obtaining the current load coefficients of the multiple central processing unit CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service at preset intervals, the method further includes:

[0030] When the SPDK iSCSI service starts, it initializes multiple specified CPUs, including allocating a preset number of threads to each CPU and setting the load factor of each CPU to 0.

[0031] Secondly, this application provides a flow distribution device, comprising:

[0032] The acquisition module is used to acquire the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit Small Computer System Interface (SPDK) iSCSI service at preset intervals.

[0033] The allocation module is used to allocate new traffic connections to the CPU with the lowest current load factor when new traffic connections are added, based on the current load factor of each CPU.

[0034] The allocation module is also used to migrate the traffic connections accessed on the CPU with the highest load factor to the CPU with the lowest load factor when no new traffic connections are added, based on the current load factor of each CPU.

[0035] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0036] The memory stores computer-executed instructions;

[0037] The processor executes computer execution instructions stored in the memory to implement the traffic allocation method as described in any of the first aspects.

[0038] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the traffic allocation method as described in any of the first aspects.

[0039] The traffic allocation method, apparatus, device, and storage medium provided in this application obtain the current load factor of multiple central processing units (CPUs) specified by the Storage Performance Development Kit (SPDK) iSCSI service at preset time intervals. When a new traffic connection is added, the connection is allocated to the CPU with the lowest current load factor based on the current load factor of each CPU. When no new traffic connection is added, the traffic connection connected to the CPU with the highest load factor is migrated to the CPU with the lowest load factor based on the current load factor of each CPU. This method, by allocating traffic connections based on the current CPU load factor, improves the uneven distribution of traffic connections across CPUs caused by the number of traffic connections that a CPU can handle, thus enhancing the balance of traffic allocation across CPUs. Attached Figure Description

[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0041] Figure 1 This application provides a schematic diagram of an existing traffic connection allocation structure;

[0042] Figure 2 A flowchart illustrating a traffic allocation method provided in an embodiment of this application;

[0043] Figure 3 A flowchart illustrating a method for allocating new traffic connections, provided in an embodiment of this application;

[0044] Figure 4 A flowchart illustrating a traffic connection migration method provided in an embodiment of this application;

[0045] Figure 5 This is a schematic diagram of a traffic connection allocation structure provided in an embodiment of this application;

[0046] Figure 6 A schematic diagram of the structure of a flow distribution device provided in an embodiment of this application;

[0047] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0048] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0049] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0050] In the description of the embodiments of this application, the terms "inner" and "outer", etc., which indicate the direction or positional relationship, are based on the direction or positional relationship shown in the drawings. This is only for the convenience of description and is not intended to indicate or imply that the device or component must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation of this application.

[0051] Furthermore, it should be noted that, in the description of the embodiments of this application, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of this application according to the specific circumstances.

[0052] First, let me explain the terms used in this application:

[0053] Storage Performance Development Kit (SPDK): This provides a set of tools and libraries for writing high-performance, scalable user-mode storage applications.

[0054] iSCSI (Internet SCSI) is a storage device remote mapping technology that can map a storage device on a remote server to the local machine and present it as a block device (disk). It is widely used in IPSAN and is based on TCP connection. Data flow I / O is transmitted through TCP channel.

[0055] IP SAN (IP Storage Network): This technology uses IP channels to connect servers and storage devices.

[0056] In existing technologies, the number of traffic connections that can be processed on each CPU is assumed to be basically the same. When different traffic connection requests occur, in order to ensure that the number of traffic connections processed on each CPU is not much different, the different traffic connection requests are usually evenly distributed to different CPUs based on the number of traffic connections currently being processed on each CPU.

[0057] However, in existing technologies, the traffic corresponding to each traffic connection is different. If traffic is allocated solely based on the number of traffic connections, it can easily lead to an uneven distribution of traffic on the CPU, affecting CPU processing performance. Furthermore, when a CPU is allocated a large number of traffic connections, the migration of traffic connections is mostly done manually by the user, impacting user experience.

[0058] For example,

[0059] Figure 1 This application provides a schematic diagram of an existing traffic connection allocation structure, such as... Figure 1 As shown, each CPU is allocated one thread, and the thread has a polling function `poll_group` to handle traffic connections `conn`. The thread is connected to the CPU's reactor. A single thread can have multiple traffic connections.

[0060] When a new traffic connection request occurs, to ensure that the number of traffic connections processed on each CPU is not significantly different, the new traffic connection will be allocated to [a specific CPU / CPU]. Figure 1 The processing is performed on the thread corresponding to CPU4.

[0061] If there are many existing traffic connections allocated on CPU2, migrating a certain traffic connection allocated on CPU2 can only be done manually by the user. During the migration process, the threads on CPU2 along with all traffic connections need to be migrated to CPU4, which is equivalent to migrating all traffic connections on the entire CPU. The migration scope is large, the migration process takes a long time, and it is impossible to achieve migration with smaller granularity.

[0062] Therefore, to address the aforementioned technical problems in the prior art, this application proposes a traffic allocation method, apparatus, device, and storage medium. By obtaining the current load factor of each CPU and allocating new traffic connections and automatically migrating existing traffic connections based on the load factor, the traffic connections allocated to each CPU are more balanced. The load factor is determined based on the current busy parameter value of the CPU and the traffic bandwidth allocated to each thread under the CPU.

[0063] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0064] Figure 2 This is a flowchart illustrating a traffic allocation method provided in an embodiment of this application. The execution subject of this method can be a terminal with traffic allocation capabilities, such as a personal computer, laptop, smartphone, tablet, portable wearable device, server, or server cluster. The method in this embodiment can be implemented through software, hardware, or a combination of both.

[0065] like Figure 2 As shown, the method specifically includes the following steps:

[0066] S201. At preset intervals, obtain the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service.

[0067] In this embodiment, the execution subject is a computer. N CPUs are pre-specified in the computer's SPDK iSCSI service, and each CPU is identified.

[0068] In this embodiment, N=4 CPUs are pre-specified, and each CPU is identified by its ID information.

[0069] One possible way to obtain the load factor is:

[0070] At preset intervals, obtain the current busy parameter value of each CPU specified by the SPDK iSCSI service, as well as the bandwidth allocated to each thread under each CPU.

[0071] The busy parameter is a set of operating parameters for CPU resources, including but not limited to: number of CPU tasks, number of running tasks, and waiting time.

[0072] The current load factor of each CPU is determined based on the current busy parameter value of each CPU and the bandwidth allocated to each thread under each CPU.

[0073] Specifically,

[0074] The CPU load factor is determined using the following formula (1):

[0075]

[0076] Where load_coefficient represents the load coefficient; busy represents the busy parameter value; T represents the number of threads allocated to each CPU; and thread_mbps represents the bandwidth per thread.

[0077] The busy parameter value and the bandwidth of each thread can be obtained through the internal interface of SPDK.

[0078] Get the current load factor of multiple CPUs specified by the SPDK iSCSI service.

[0079] S202. When a new traffic connection is added, the traffic connection is allocated to the CPU with the lowest current load factor based on the current load factor of each CPU.

[0080] When a new traffic connection is added, it can be allocated according to a preset allocation strategy.

[0081] One possible implementation is to allocate the new traffic connection to the CPU with the lowest current load factor, specifically, the thread corresponding to the minimum traffic bandwidth on that CPU.

[0082] S203. When no new traffic connections are added, based on the current load factor of each CPU, migrate the traffic connections already connected on the CPU with the highest load factor to the CPU with the lowest load factor.

[0083] When no new traffic connections are added, the traffic connections are automatically migrated based on the current load factor of each CPU. For details of the implementation process, please refer to the following example.

[0084] In this application, before obtaining the current load coefficients of multiple central processing unit CPUs specified by the Storage Performance Development Kit Small Computer System Interface (SPDKiSCSI) service at preset intervals, initialization settings can also be performed on multiple specified CPUs.

[0085] Optionally, a preset number of threads are allocated to each CPU, and the load factor for each CPU is set to 0.

[0086] To distinguish each thread allocated to each CPU, each thread can be numbered, which can be thread[i][j]. Here, i represents the i-th CPU and j represents the j-th thread, where i and j are both integers.

[0087] For example, suppose there are 4 CPUs, and each CPU is allocated 4 threads. The first thread allocated under the first CPU is numbered thread[1][4].

[0088] In the above embodiments of this application, the current load factor of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service is obtained at preset intervals. When a new traffic connection is added, the connection is allocated to the CPU with the lowest current load factor based on the current load factor of each CPU. When no new traffic connection is added, the traffic connection accessed on the CPU with the highest load factor is migrated to the CPU with the lowest load factor based on the current load factor of each CPU. This method improves the balance of traffic connections allocated to CPUs by allocating traffic connections based on the current load factor of the CPUs.

[0089] Based on the above embodiments, the following embodiments will be used to explain in detail the process involved in step S202 of allocating traffic connections to the CPU with the lowest current load factor according to the current load factor of each CPU when a new traffic connection occurs.

[0090] Figure 3 A flowchart illustrating a method for allocating new traffic connections provided in an embodiment of this application is shown below. Figure 3 As shown, the method includes the following steps:

[0091] S301. Based on the current load factor of each CPU, determine the CPU with the smallest current load factor.

[0092] Based on the current load coefficient (load_coefficient) of each CPU, determine the CPU with the smallest current load coefficient (load_coefficient).

[0093] S302. Based on the bandwidth allocated to each thread under the CPU with the lowest current load factor, determine the first target thread corresponding to the minimum bandwidth value.

[0094] Obtain the bandwidth allocated to each thread under the CPU with the lowest current load factor, determine the minimum bandwidth, and determine the first target thread corresponding to the minimum bandwidth.

[0095] S303. Assign the traffic connection to the first target thread.

[0096] The newly added traffic connections are assigned to the first target thread determined in step S302 above.

[0097] The method in this embodiment improves the balance of traffic connections allocated on the CPU by allocating new traffic connections according to the current load factor of each CPU.

[0098] Furthermore, through Figure 4The illustrated embodiment describes the process in step S203 of migrating the traffic connections already connected on the CPU with the highest load factor to the CPU with the lowest load factor, based on the current load factor of each CPU.

[0099] Figure 4 A flowchart illustrating a traffic connection migration method provided in this application embodiment is shown below. Figure 4 As shown, the method includes the following steps:

[0100] S401. Based on the current load factor of each CPU, sort the current load factors of each CPU by size to determine the maximum load factor and the minimum load factor.

[0101] Access traffic may change due to changes in upper-layer services or the mounting and unmounting of disks (volumes), and CPU traffic connections may also change. For CPUs with heavy loads, traffic connections on that CPU can be migrated.

[0102] Sort the current load coefficients of each CPU by size, and determine the maximum load coefficient (load_coefficient) based on the sorting. max and minimum load coefficient (load_coefficient) min .

[0103] S402. Determine the load factor change rate based on the maximum load factor and the minimum load factor.

[0104] One possible implementation is:

[0105] Calculate the difference between the maximum load factor and the minimum load factor based on the maximum load factor and the minimum load factor.

[0106] The ratio of the difference to the maximum load factor is determined as the load factor change rate.

[0107] Specifically,

[0108] The rate of change of the load factor is determined by the following formula (2):

[0109]

[0110] Where delta represents the rate of change of the load coefficient; load_coefficient max The load_coefficient represents the maximum load factor. min This represents the minimum load factor.

[0111] S403. When the load factor change rate exceeds the preset threshold, the traffic connections already connected on the CPU corresponding to the maximum load factor will be migrated to the CPU corresponding to the minimum load factor.

[0112] When the load factor change rate delta exceeds a preset threshold, such as exceeding 50%, traffic migration is triggered.

[0113] One possible way to implement traffic migration is:

[0114] Based on the maximum load coefficient load_coefficient max The minimum bandwidth (thread_mbps) is determined by the bandwidth allocated to each thread under the corresponding CPU. min The corresponding second target thread.

[0115] Migrate the second target thread and the traffic connections connected to the second target thread to the minimum load coefficient (load_coefficient). min On the corresponding CPU.

[0116] In this application, when a traffic connection migrates, it is marked. The purpose of marking is to prevent the traffic connection from migrating again within a preset period of time, thereby preventing frequent migrations of the traffic connection.

[0117] In the above embodiments of this application, the current load coefficients of each CPU are sorted by size to determine the maximum and minimum load coefficients. Based on these maximum and minimum load coefficients, a load coefficient change rate is determined. When the load coefficient change rate exceeds a preset threshold, the traffic connections already connected to the CPU corresponding to the maximum load coefficient are migrated to the CPU corresponding to the minimum load coefficient. This method, which migrates traffic connections based on the current load coefficient of each CPU, reduces the reliance on manual migration and improves the level of intelligence.

[0118] In summary, the above embodiments, Figure 5 This is a schematic diagram of a traffic connection allocation structure provided in an embodiment of this application, as shown below. Figure 5 As shown, each CPU has multiple threads, and each thread has a polling function `poll_group` to handle traffic connections `conn`. Each thread is connected to the CPU's reactor. Each thread must have at least one traffic connection.

[0119] exist Figure 5When a new traffic connection is added, it will be assigned to the thread with the minimum traffic bandwidth on CPU4, which has the lowest current load factor, for processing, based on the current load factor of each CPU.

[0120] If a large number of traffic connections are allocated to CPU2, the traffic connections on the thread with the minimum traffic bandwidth on CPU2 (which has the maximum load factor) will be migrated to CPU4 (which has the minimum load factor) for processing.

[0121] For the specific steps and technical effects of implementation, please refer to the above embodiments. To avoid redundancy, they will not be described again.

[0122] Figure 6 This is a schematic diagram of the structure of a flow distribution device provided in an embodiment of this application, as shown below. Figure 6 As shown, the device includes: an acquisition module 601 and an allocation module 602.

[0123] The acquisition module 601 is used to acquire the current load factor of multiple CPUs specified by the Storage Performance Development Kit Small Computer System Interface (SPDK iSCSI service) at preset intervals.

[0124] The allocation module 602 is used to allocate the traffic connection to the CPU with the lowest current load factor when a new traffic connection is added, based on the current load factor of each CPU.

[0125] The allocation module 602 is also used to migrate the traffic connections accessed on the CPU with the highest load factor to the CPU with the lowest load factor when no new traffic connections are added, based on the current load factor of each CPU.

[0126] One possible implementation is that the acquisition module 601 is specifically used for:

[0127] At preset intervals, obtain the current busy parameter value of each CPU specified by the SPDK iSCSI service, as well as the bandwidth allocated to each thread under each CPU. The busy parameter value is the operating parameter of the CPU resource.

[0128] The current load factor of each CPU is determined based on the current busy parameter value of each CPU and the bandwidth allocated to each thread under each CPU.

[0129] Get the current load factor of multiple CPUs specified by the SPDK iSCSI service.

[0130] One possible implementation is that the allocation module 602 is specifically used for:

[0131] Based on the current load factor of each CPU, determine the CPU with the lowest current load factor.

[0132] Based on the bandwidth allocated to each thread under the CPU with the lowest current load factor, determine the first target thread corresponding to the minimum bandwidth value.

[0133] Assign traffic connections to the first target thread.

[0134] One possible implementation is that the allocation module 602 is specifically used for:

[0135] Based on the current load factor of each CPU, sort the current load factors of each CPU by size to determine the maximum load factor and the minimum load factor.

[0136] The rate of change of the load factor is determined based on the maximum and minimum load factors.

[0137] When the rate of change of the load factor exceeds the preset threshold, the traffic connections already connected on the CPU corresponding to the maximum load factor will be migrated to the CPU corresponding to the minimum load factor.

[0138] One possible implementation is that the allocation module 602 is specifically used for:

[0139] Calculate the difference between the maximum load factor and the minimum load factor based on the maximum load factor and the minimum load factor.

[0140] The ratio of the difference to the maximum load factor is determined as the load factor change rate.

[0141] One possible implementation is that the allocation module 602 is specifically used for:

[0142] Based on the bandwidth allocated to each thread under the CPU corresponding to the maximum load factor, determine the second target thread corresponding to the minimum bandwidth value.

[0143] Migrate the second target thread and the traffic connections connected to the second target thread to the CPU with the lowest load factor.

[0144] One possible implementation is that the device further includes a processing module for:

[0145] When the SPDK iSCSI service starts, it initializes multiple specified CPUs. The initialization settings include: allocating a preset number of threads to each CPU and setting the load factor of each CPU to 0.

[0146] The flow distribution device provided in this embodiment is used to execute the aforementioned method embodiment. Its implementation principle and technical effect are similar, and will not be described again.

[0147] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 7 As shown, the device may include at least one processor 701 and a memory 702.

[0148] The memory 702 is used to store programs. Specifically, the program may include program code, which may include computer operation instructions or executable instructions of the processor 701, etc.

[0149] The memory 702 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0150] The processor 701 is used to execute computer execution instructions stored in the memory 702 to implement the method described in any of the foregoing embodiments. The processor 701 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0151] Optionally, the electronic device may also include a communication interface 703. In specific implementations, if the communication interface 703, memory 702, and processor 701 are implemented independently, they can be interconnected via a bus to complete communication. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc., but this does not imply that there is only one bus or one type of bus.

[0152] Optionally, in a specific implementation, if the communication interface 703, memory 702, and processor 701 are integrated on a single chip, then the communication interface 703, memory 702, and processor 701 can communicate through an internal interface.

[0153] The electronic device provided in this embodiment is used to execute the traffic allocation method executed in the aforementioned embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0154] This application also provides a computer-readable storage medium, which may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a disk, or an optical disk. Specifically, the computer-readable storage medium stores computer-executable instructions, which are used for the traffic allocation method in the above embodiments.

[0155] This application also provides a computer program product comprising executable instructions or a computer program stored in a readable storage medium. At least one processor of an electronic device can read the executable instructions from the readable storage medium, and the processor executes the executable instructions to cause the electronic device to implement the traffic allocation methods provided in the various embodiments described above.

[0156] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0157] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for allocating traffic, characterized in that, include: At preset intervals, obtain the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service. When a new traffic connection is added, the traffic connection is allocated to the CPU with the lowest current load factor based on the current load factor of each CPU. When no new traffic connections are added, the traffic connections already connected on the CPU with the highest load factor are migrated to the CPU with the lowest load factor, based on the current load factor of each CPU. The process of acquiring the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service at preset intervals includes: Every preset time interval, obtain the current busy parameter value of each CPU specified by the SPDK iSCSI service and the traffic bandwidth allocated to each thread under each CPU. The busy parameter value is the operating parameter of the CPU resource. The current load factor of each CPU is determined based on the current busy parameter value of each CPU and the bandwidth allocated to each thread under each CPU. Get the current load factor of multiple CPUs specified by the SPDK iSCSI service.

2. The method according to claim 1, characterized in that, The step of allocating the traffic connection to the CPU with the lowest current load factor based on the current load factor of each CPU includes: Based on the current load factor of each CPU, determine the CPU with the lowest current load factor; Based on the bandwidth allocated to each thread under the CPU with the lowest current load factor, determine the first target thread corresponding to the minimum bandwidth value; The traffic connection is assigned to the first target thread.

3. The method according to claim 2, characterized in that, The step of migrating the traffic connections already connected on the CPU with the highest load factor to the CPU with the lowest load factor based on the current load factor of each CPU includes: Based on the current load factor of each CPU, sort the current load factors of each CPU by size to determine the maximum load factor and the minimum load factor; The load factor change rate is determined based on the maximum load factor and the minimum load factor. When the rate of change of the load factor exceeds a preset threshold, the traffic connections already connected on the CPU corresponding to the maximum load factor are migrated to the CPU corresponding to the minimum load factor.

4. The method according to claim 3, characterized in that, The step of determining the load factor change rate based on the maximum load factor and the minimum load factor includes: Calculate the difference between the maximum load factor and the minimum load factor based on the maximum load factor and the minimum load factor; The ratio of the difference to the maximum load factor is determined as the load factor change rate.

5. The method according to claim 4, characterized in that, When the load factor change rate exceeds a preset threshold, migrating the traffic connections already connected on the CPU corresponding to the maximum load factor to the CPU corresponding to the minimum load factor includes: Based on the bandwidth allocated to each thread under the CPU corresponding to the maximum load coefficient, determine the second target thread corresponding to the minimum bandwidth. The second target thread and the traffic connections connected to the second target thread are migrated to the CPU corresponding to the minimum load factor.

6. The method according to any one of claims 1-5, characterized in that, Before obtaining the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit (SPDK) iSCSI service at preset intervals, the process also includes: When the SPDK iSCSI service starts, it initializes multiple specified CPUs, including allocating a preset number of threads to each CPU and setting the load factor of each CPU to 0.

7. A flow distribution device, characterized in that, include: The acquisition module is used to acquire the current load coefficients of multiple CPUs specified by the Storage Performance Development Kit Small Computer System Interface (SPDK) iSCSI service at preset intervals. The allocation module is used to allocate new traffic connections to the CPU with the lowest current load factor when new traffic connections are added, based on the current load factor of each CPU. The allocation module is also used to migrate the traffic connections accessed on the CPU with the highest load factor to the CPU with the lowest load factor when no new traffic connections are added, based on the current load factor of each CPU. The acquisition module is specifically used to acquire the current busy parameter value of each CPU specified by the SPDK iSCSI service and the traffic bandwidth allocated to each thread under each CPU at preset intervals. The busy parameter value is the operating parameter of the CPU resource. Based on the current busy parameter value of each CPU and the traffic bandwidth allocated to each thread under each CPU, the current load factor of each CPU is determined. Get the current load factor of multiple CPUs specified by the SPDK iSCSI service.

8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the traffic allocation method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the traffic allocation method as described in any one of claims 1 to 6.