Message forwarding method, network card, gateway device, storage medium and program
By dynamically switching the message forwarding mode in the gateway device according to the water level of the order-saving queue, the problem of excessive load of the processor core in RSS mode is solved, and more efficient message forwarding performance is achieved.
Patent Information
- Application Number
- CN202411680147.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-11-21
AI Technical Summary
In gateway devices, when packets are forwarded in RSS mode, messages from the same network stream are continuously sent to the same processor core, resulting in excessive load on the processor core and large delay in message processing, which affects forwarding performance.
Dynamically determine the message forwarding mode according to the water level of the order-saving queue corresponding to the target service. If the water level is normal or low, use the first message forwarding mode (DLB mode) to distribute the message in a polling manner; if the water level is high, switch to the second message forwarding mode (RSS mode) and use its natural order preservation function to forward the message.
By dynamically switching the message forwarding mode, the advantages of both modes are taken into account, reducing the risk of excessive load on the processor core, and avoiding the problems of large delay in message processing and degradation of forwarding performance.
Smart Images

Figure CN119211152B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to a message forwarding method, a network card, a gateway device, a storage medium and a program. Background Art
[0002] Gateway devices play a vital role in network communications based on their routing function (ability to transfer data between different networks). In scenarios such as data centers, there is often a need to forward large-volume messages. For example, a gateway device in a data center forwards large-volume messages received from a switch to the corresponding cloud server. Therefore, gateway devices that can handle large-volume message forwarding have become an important development trend.
[0003] At present, a gateway device is usually equipped with multiple network cards, which usually use the network card multi-queue technology. The so-called network card multi-queue, as the name implies, means that the high-speed network card has multiple direct memory access (DMA) queues. The network card has an allocation mechanism based on multiple DMA queues. A DMA queue can be bound to a processor core (usually a CPU core) in the gateway device. In actual applications, the network card generally uses the receive side scaling (RSS) mode to distribute the received messages to the CPU core.
[0004] However, although the RSS mode has the natural advantage of preserving message order, when forwarding messages in the RSS mode, messages of the same network flow will be continuously sent to the same processor core, causing the processor core to be overloaded and message processing to be delayed, ultimately affecting the forwarding performance of the gateway device. Summary of the invention
[0005] The embodiment of the present invention provides a message forwarding method, a network card, a gateway device, a storage medium and a program, which can ensure the forwarding performance of the gateway device.
[0006] In a first aspect, an embodiment of the present invention provides a message forwarding method, which is applied to a programmable chip in a network card, wherein the network card is located in a gateway device, and the gateway device includes multiple processor cores, and the method includes:
[0007] Determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, wherein the order-preserving queue corresponds to the first message forwarding mode and is used to store message sequence numbers;
[0008] If the target message forwarding mode is the first message forwarding mode, in response to receiving the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue, and the target message corresponds to the target service;
[0009] If the target message forwarding mode is the second message forwarding mode, then in response to receiving the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device; wherein the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0010] In a second aspect, an embodiment of the present invention provides a message forwarding device, which is applied to a programmable chip in a network card, wherein the network card is located in a gateway device, and the gateway device includes multiple processor cores, and the device includes:
[0011] A determination module, used to determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, wherein the order-preserving queue corresponds to the first message forwarding mode and is used to store a message sequence number;
[0012] A first sending module, configured to, if the target message forwarding mode is the first message forwarding mode, send the target message to the first processor core for processing in a polling manner in response to reception of the target message, and send the first processed message fed back by the first processor core to the destination device in sequence based on the message sequence number allocated in the order-preserving queue, wherein the target message corresponds to the target service;
[0013] A second sending module is used to send the target message to the second processor core corresponding to the target service for processing in response to the reception of the target message if the target message forwarding mode is the second message forwarding mode, and to send the second processed message fed back by the second processor core directly to the destination device; wherein the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0014] In a third aspect, an embodiment of the present invention provides a network card, wherein the network card includes a programmable chip, and the network card is respectively communicatively connected to a plurality of processor cores in a gateway device;
[0015] The programmable chip is used to determine the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store the message sequence number; if the target message forwarding mode is the first message forwarding mode, then in response to the reception of the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number allocated in the order-preserving queue; if the target message forwarding mode is the second message forwarding mode, then in response to the reception of the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, the target message corresponds to the target service, and the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0016] In a fourth aspect, an embodiment of the present invention provides a gateway device, the gateway device comprising: a plurality of processor cores;
[0017] A network card, wherein the network card includes a programmable chip and the network card is communicatively connected to the multiple processor cores respectively;
[0018] The programmable chip is used to: determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, the order-preserving queue corresponds to a first message forwarding mode, and the order-preserving queue is used to store message sequence numbers; if the target message forwarding mode is the first message forwarding mode, then in response to receiving a target message, the target message is sent to a first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent in sequence to a destination device based on the message sequence number allocated in the order-preserving queue; if the target message forwarding mode is a second message forwarding mode, then in response to receiving a target message, the target message is sent to a second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, the target message corresponds to the target service, and the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0019] In the fifth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method described in the first aspect.
[0020] In a sixth aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, which, when executed by a programmable chip in a gateway device, enables the programmable chip to execute the message forwarding method described in the first aspect.
[0021] The message forwarding method provided by the embodiment of the present invention determines the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service. When the water level of the order-preserving queue is normal or low, the first message forwarding mode is used to perform message forwarding work. When the water level of the order-preserving queue is high, the second message forwarding mode (which may be the RSS mode) is used to perform message forwarding work.
[0022] Specifically, since the first message forwarding mode can send the target message carrying the target message sequence number to the first processor core for processing in a polling manner after receiving the target message, that is, when the gateway device receives different messages, these messages will be sent to different processor cores for processing in a polling manner, therefore, by using the first message forwarding mode to forward messages when the water level of the order-preserving queue is normal or low, the risk of a processor core being blown up (i.e., the load is too high, which will cause the message processing delay to increase) due to continuous reception of too many messages (such as large-volume messages) is reduced. However, in the first message forwarding mode, the first processed message fed back by the first processor core needs to be sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue. Then, when the processor core has a large delay in processing the message and the source device continues to send messages, the water level of the order-preserving queue will continue to grow, and there may be risks such as packet loss, thereby reducing the forwarding performance. Therefore, when the water level of the order-preserving queue is high, it switches to the second message forwarding mode (because the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode).
[0023] Since the second message forwarding mode can directly send the target message to the second processor core corresponding to the target service for processing after receiving the target message, and directly send the second processed message fed back by the second processor core to the destination device, the whole process does not require the participation of the order-preserving queue, and utilizes the natural order-preserving function of the RSS mode to realize the order-preserving forwarding of messages. When the water level of the order-preserving queue drops to normal or low, switch to the first message forwarding mode again to forward messages.
[0024] It can be seen that by determining the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, the respective advantages of the two message forwarding modes can be taken into account to ensure the forwarding performance of the gateway device. When the water level of the order-preserving queue is not high, the load balancing advantages of different processor cores in the first message forwarding mode are fully utilized to reduce the message processing delay, and the sequential forwarding function of the message is realized through the order-preserving queue. When the water level of the order-preserving queue is high, the order-preserving function naturally possessed by the second message forwarding mode is used to realize the sequential forwarding of the message, thereby giving the message received and processed based on the first message forwarding mode a certain amount of time to release the allocated message sequence number in the order-preserving queue, so as to restore to the first message forwarding mode later, thereby ensuring the forwarding performance of the gateway device. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0026] Figure 1 A flowchart of a message forwarding method provided by an embodiment of the present invention;
[0027] Figure 2 A schematic diagram of an application of a message forwarding method provided by an embodiment of the present invention;
[0028] Figure 3 A flow chart of determining a target message forwarding mode provided by an embodiment of the present invention;
[0029] Figure 4 A flow chart of determining a target message forwarding mode provided by an embodiment of the present invention;
[0030] Figure 5 An application schematic diagram of another message forwarding method provided by an embodiment of the present invention;
[0031] Figure 6 A schematic structural diagram of a message forwarding device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0034] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and the features in the embodiments can be combined with each other. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0035] First, the terms or concepts involved in the embodiments of the present invention are explained:
[0036] Gateway device: can be a gateway-type forwarding node in application scenarios such as data centers, and is a traffic convergence point. The gateway device in the embodiment of the present invention can also be a network device such as a switch, a router, etc. that can forward messages.
[0037] Field-Programmable Gate Array (FPGA) is a programmable chip, an integrated circuit that can be reconfigured at the hardware level.
[0038] The communication traffic carried on various Internet networks is continuously growing and changing. Among them, the transmission of elephant flows will occupy more network resources. Elephant flows refer to network traffic with a long duration and large data volume in the network. For example, elephant flows with a message share of about 5% may account for about 40% of the network bandwidth. Common elephant flows include virtual machine migration, data migration, distributed database data processing, etc. In scenarios such as data centers, there is often a need to forward elephant flows. For example, a gateway device in a data center forwards the elephant flow received from a switch to the corresponding cloud server.
[0039] At present, since the receive side scaling (RSS) mode has a natural message order preservation function, the RSS mode is usually used for message distribution, that is, when the gateway device receives a message, it can calculate the hash value according to the specific area of the message header, such as the five-tuple (including the five fields of source IP, source port, destination IP, destination port and protocol number), and query the forwarding table based on multiple low-significant bits of the hash value, that is, the index indirection table, to determine the corresponding CPU core number, so as to assign the message to the corresponding CPU core for processing. It is understandable that different messages under the same network flow have the same specific header area (such as the same five-tuple), so in the RSS mode, the messages of the same network flow (especially when the network flow belongs to the elephant flow) will be distributed to the same CPU core for processing, which can easily blow up a single CPU core. That is, when forwarding messages in RSS mode, messages of the same network flow will be continuously sent to the same processor core, resulting in excessive load on the processor core and large message processing delays, ultimately affecting the forwarding performance of the gateway device.
[0040] In view of this, an embodiment of the present invention provides a message forwarding method, which can determine the target message forwarding mode as a first message forwarding mode (which can be named dynamic load balancing (DataLoad Balance, DLB for short) mode) or a second message forwarding mode (which can be RSS mode) according to the water level of the order-preserving queue corresponding to the target service.
[0041] In DLB mode, the packets of the same network flow are no longer distributed to the same processor core for processing, but are processed by different processor cores in a round-robin manner. In addition, an order-preserving queue is introduced in the first packet forwarding mode to realize the function of packet order preservation during packet forwarding. In summary, based on the order in which the packets are received, packet sequence numbers are assigned to them, and the order-preserving queue stores the message sequence numbers to achieve orderly forwarding of the packets. In this way, the water level of the order-preserving queue (i.e., the number of allocated message sequence numbers stored therein) will become one of the key factors restricting forwarding performance: if the water level of the order-preserving queue is high, it means that the subsequent packets that need to be forwarded will have no more message sequence numbers available. When the upper limit is reached, the newly received packets may be discarded, and there is a risk of packet loss.
[0042] Therefore, in view of the respective advantages of the above two message forwarding modes, the message forwarding mode to be adopted can be dynamically decided based on the water level of the order-preserving queue. The DLB mode can be used for message forwarding when the water level of the order-preserving queue is normal or low to reduce the risk of a single processor core being blown up. However, in the DLB mode, an order-preserving queue is required to ensure that messages are sent out in an orderly manner according to the order in which they are received, that is, when a message is received, a message sequence number is assigned and stored in the order-preserving queue. After the processor core processes the message, the message sequence is sent out based on the message sequence number stored in the order-preserving queue. Then, when the processor core has a large delay in processing the message and the source device continues to send messages, the water level of the order-preserving queue will continue to grow, and risks such as packet loss may occur, thereby reducing the forwarding performance.
[0043] Therefore, when the water level of the order-preserving queue is high, it switches to the RSS mode that does not require the participation of the order-preserving queue, and uses the natural order-preserving function of the RSS mode to achieve in-order forwarding of messages, providing time for the order-preserving queue to lower the water level. Of course, there will be no risk of packet loss caused by the high water level of the order-preserving queue, but it will cause the load of some processor cores to increase. Through the flexible switching of DLB mode and RSS mode, the target message takes into account the advantages of the above two message forwarding modes when forwarding messages, ensuring the forwarding performance of the gateway device.
[0044] Figure 1 The present invention provides a flowchart of a message forwarding method, which is applied to a programmable chip in a network card, the network card is located in a gateway device, and the gateway device includes multiple processor cores. Figure 1 As shown, the method comprises the following steps:
[0045] 101. Determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store message sequence numbers.
[0046] 102. If the target message forwarding mode is the first message forwarding mode, then in response to the reception of the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue, and the target message corresponds to the target service.
[0047] 103. If the target message forwarding mode is the second message forwarding mode, then in response to receiving the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device; wherein the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0048] In the embodiment of the present invention, the first message forwarding mode may be a DLB mode, and the second message forwarding mode may be an RSS mode.
[0049] It should be noted that the water level of the order-preserving queue is used to reflect the storage status of the message sequence numbers in the order-preserving queue. The target service can be a live broadcast application service, a game application service, etc., which are not listed here one by one. The source device and the destination device refer to two devices that need to communicate through the gateway device, such as a terminal device that uses the target service and a cloud server that provides the target service. Multiple processor cores can usually be multiple CPU cores, such as Figure 2 The gateway device shown in FIG. 1 includes CPU core 1, CPU core 2, ..., CPU core n. The programmable chip may be Figure 2 The FPGA chip in the embodiment is not limited to this, and other dedicated integrated chips may also be used. The following description takes the CPU core as the processor core and the FPGA chip as the programmable chip as an example. In addition, the gateway device can run a variety of different services, and each service can correspond to its own order-keeping queue. Figure 2 As shown in the figure, a network card is provided in the gateway device, and the FPGA chip is located in the network card. The network card is a multi-queue gateway, which may include multiple DMA receiving queues illustrated in the figure and multiple DMA sending queues corresponding thereto one by one.
[0050] In actual applications, the upper limit of the number of packet sequence numbers (PSN) that the order-preserving queue can accommodate can be preset, such as 4K (K represents 1024 PSNs). The message sequence number can be a continuous integer numbered from 1, and when it increases to 4K, it will be renumbered from 1. In an embodiment of the present invention, two thresholds reflecting the water level of the order-preserving queue corresponding to the target service can be preset: a first set threshold and a second set threshold. When the water level is higher than the first set threshold, it indicates that the water level is too high; when the water level is equal to or less than the second set threshold, it indicates that the water level is low.
[0051] If the water level of the order-preserving queue is less than the second set threshold (such as 3K), it means that the water level of the current order-preserving queue is normal or low, and the target message forwarding mode is determined to be the first message forwarding mode. At this time, according to the allocation of message sequence numbers in the order-preserving queue corresponding to the target service, the target message is assigned its corresponding target message sequence number: add one to the allocated message sequence number to obtain the target message sequence number corresponding to the current target message.
[0052] Afterwards, the target message is sent to the first processor core for processing (such as encapsulation, parsing, etc.) in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue. The specific process is as follows: assign a target message sequence number corresponding to the target message in the order-preserving queue, send the target message carrying the target message sequence number to the first processor core for processing in a polling manner, and determine the sending order of the first processed message fed back by the first processor core according to the message sequence number currently stored in the order-preserving queue; after sending the first processed message to the destination device in the sending order, delete the target message sequence number in the order-preserving queue.
[0053] In the specific implementation, it should be noted that each network card receiving queue corresponding to the target service has a set corresponding relationship with the processor core. For ease of understanding, please refer to Figure 2 , Figure 2 A schematic diagram of an application of a message forwarding method provided by an embodiment of the present invention. Figure 2 In the example, queue 1 in the DMA receive queue corresponds to CPU core 1, queue 2 in the DMA receive queue corresponds to CPU core 2...queue n in the DMA receive queue corresponds to CPU core n. Assuming that the target network card receive queue currently polled is queue 2, the message distribution module sends the target message received by the message receiving module to the first processor core (i.e., processor core 2) through queue 2 for processing. Among them, the message receiving module is a module that receives messages from the source device. The message distribution module is a module responsible for distributing messages to the DMA receive queue. In the above example, processor core 2 will read the target message from the corresponding network card receive queue for processing.
[0054] Furthermore, the first processed message fed back by the first processor core is stored in a target network card sending queue corresponding to the target network card receiving queue, so as to read the first processed message from the target network card sending queue.
[0055] Among them, the network card sending queue and the network card receiving queue are one-to-one corresponding. In specific implementation, the target message uploaded through the target network card receiving queue will be sent to the corresponding target network card sending queue after being processed by the first processor core. For ease of understanding, please refer to Figure 2 .exist Figure 2In the DMA transmission queue, queue No. 1 corresponds to CPU core 1, queue No. 2 corresponds to CPU core 2, and queue No. n corresponds to processor core n. Assuming that the first processor core is processor core 2, the first processed message fed back by it will be stored in DMA transmission queue No. 2 corresponding to DMA receiving queue No. 2. The reordering module responsible for sending the processed message to the destination device reads the first processed message from DMA transmission queue No. 2, performs "sequence preservation processing" according to the queue number of the sequence preservation queue and the target message sequence number contained in the first processed message, and then sends it through the message sending module.
[0056] Among them, the sending order of the first processed message fed back by the first processor core is determined according to the message sequence number currently stored in the order-preserving queue (at this time, the first processed message also carries identification information corresponding to the first message forwarding mode), which specifically includes the following steps: parsing the first processed message to obtain the first identification information and the target message sequence number corresponding to the first message forwarding mode (it may also carry the queue number of the order-preserving queue); based on the first identification information and the target message sequence number, querying the message sequence number currently stored in the order-preserving queue; if the target message sequence number is the same as the minimum message sequence number among the currently stored message sequence numbers, determining to send the first processed message immediately; if there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, the first processed message is cached, and it is determined that the sending order of the first processed message is after the processed message corresponding to the message sequence number smaller than the target message sequence number.
[0057] In the specific implementation, the first processed message is parsed to obtain the first identification information for identifying the first message forwarding mode, and the target message sequence number corresponding to the first message forwarding mode (assuming it is No. 3). Based on the first identification information and the target message sequence number, the message sequence number currently stored in the sequence-preserving queue is queried. If the message sequence numbers currently stored in the sequence-preserving queue include No. 3, No. 4, and No. 5, it means that the target message sequence number is the same as the minimum message sequence number in the currently stored message sequence numbers (both are No. 3). At this time, the first processed message can be directly sent to the destination device. If the message sequence numbers currently stored in the sequence-preserving queue include No. 1 and No. 2, it means that there is a message sequence number that is smaller than the target message sequence number in the currently stored message sequence numbers. At this time, the first processed message is cached, and after determining that the messages corresponding to No. 1 and No. 2 are sent out, the first processed message is sent to the destination device. In this way, it is ensured that the target message can be sent to the destination device smoothly and accurately according to the set sending order.
[0058] After the first processed message is sent to the destination device in the sending order, the target message sequence number is deleted from the order-preserving queue to free up storage space in the order-preserving queue, so that other messages corresponding to subsequent target services can store corresponding message sequence numbers in the order-preserving queue.
[0059] However, in the first message forwarding mode, an order-preserving queue is required to ensure that messages are sent out in order according to the order in which they are received, that is, when a message is received, a message sequence number is assigned and stored in the order-preserving queue, and after the processor core processes the message, the message sequence is sent out in order based on the message sequence number stored in the order-preserving queue. If the processor core has a large delay in processing the message and the source device continues to send messages, the water level of the order-preserving queue will continue to grow, and there may be risks such as packet loss, thereby reducing the forwarding performance.
[0060] In view of this, if the water level of the order-preserving queue is greater than the first set threshold (such as 4K), it means that the current water level of the order-preserving queue is high. At this time, the target message forwarding mode is switched from the first message forwarding mode to the second message forwarding mode, wherein the first set threshold is greater than the second set threshold. By maintaining a threshold interval between the first set threshold and the second set threshold, frequent mode switching can be avoided.
[0061] At this time, in the second message forwarding mode, the target receiving queue corresponding to the target message is determined, and the target message is sent to the second processor core bound to the target receiving queue for processing through the target receiving queue, and the second processed message fed back by the second processor core is directly sent to the destination device (wherein, the second processed message also carries the identification information corresponding to the second message forwarding mode). The specific process includes: parsing the second processed message to obtain the second identification information corresponding to the second message forwarding mode; based on the second identification information, sending the second processed message directly to the destination device. In this way, the natural order-preserving function of the second message forwarding mode can be used to realize the in-order forwarding of messages, and the second processed message can be quickly sent to the destination device. The whole process does not require the use of an order-preserving queue, which provides sufficient time for the water level of the order-preserving queue to recover, and ensures the forwarding performance of the gateway device. When the water level of the order-preserving queue drops to normal or low, switch to the first message forwarding mode again to forward messages. It should be understood that when the water level of the order-preserving queue is normal or low, the first message forwarding mode is better for achieving load balancing of the processor core. Therefore, when the water level of the order-preserving queue is reduced to normal or low, the target message forwarding mode needs to be switched from the second message forwarding mode back to the first message forwarding mode.
[0062] Among them, in the second message forwarding mode, the method of determining the target receiving queue corresponding to the target message is as described above: the hash value can be calculated according to the five-tuple in the target message, and the forwarding table is queried by setting the low-order significant bits of the hash value to determine the corresponding target receiving queue.
[0063] It can be understood that even after switching from the first message forwarding mode to the second message forwarding mode, the messages previously distributed to the processor core through the first message forwarding mode, because the messages carry the identification information of the first message forwarding mode and the relevant information of the order-preserving queue (such as queue number, PSN), after the processor core processes the messages, the processed messages will still be sent to the corresponding destination device according to the first message forwarding mode, and the corresponding PSN will be deleted from the order-preserving queue after being sent, thereby gradually reducing the water level of the order-preserving queue.
[0064] In addition, it should be noted that the first set threshold may be the same as or different from the second set threshold. When they are different, for example, the second set threshold is 3K and the first set threshold is 4K, then there may be the following two situations between the two thresholds:
[0065] First, if the water level of the order-preserving queue changes from high to low, that is, the water level is higher than the first set threshold before, and then lower than the first set threshold but still higher than the second set threshold, then, optionally, the second message forwarding mode used when the water level is higher than the first set threshold can be used;
[0066] Second, if the water level of the order-preserving queue changes from low to high, that is, the water level was lower than the second set threshold before, and then higher than the second set threshold but still lower than the first set threshold, at this time, optionally, the first message forwarding mode used when it is lower than the second set threshold can be used.
[0067] That is to say, optionally, when between two threshold ranges, the message forwarding mode adopted before changing from outside the threshold range to between the threshold ranges can be used.
[0068] The message forwarding method provided by the embodiment of the present invention uses the first message forwarding mode to perform message forwarding when the water level of the order-preserving queue is normal or low, thereby avoiding a processor core from being blown up due to continuous reception of too many messages. However, in the first message forwarding mode, an order-preserving queue is required to ensure that the message is sent out in an orderly manner according to the order of reception, that is, when the message is received, the message sequence number is allocated and stored in the order-preserving queue, and after the processor core processes the message, the message sequence is sent out in order based on the message sequence number stored in the order-preserving queue. Then, when the processor core has a large delay in processing the message and the source device continues to send messages, the water level of the order-preserving queue will continue to grow, and there may be risks such as packet loss, thereby reducing the forwarding performance. Therefore, when the water level of the order-preserving queue is high, it is switched to the second message forwarding mode, and the natural order-preserving function of the second message forwarding mode is used to realize the order-preserving forwarding of the message, thereby giving the message received and processed based on the first message forwarding mode a certain time to release the message sequence number allocated in the order-preserving queue, so as to restore to the first message forwarding mode later. By flexibly switching between the first message forwarding mode and the second message forwarding mode, the target message takes into account the respective advantages of the two message forwarding modes when performing message forwarding operations, thereby ensuring the forwarding performance of the gateway device.
[0069] In the embodiment of the present invention, different message forwarding mode switching strategies may be adopted according to the characteristics of the target service, specifically:
[0070] As an implementation method, if the target service causes the processor core to exhibit a short-term, low-frequency, high-load abnormality, then the first implementation method can be used: when the water level of the order-preserving queue is lower than the second set threshold, the first message forwarding mode is used to forward messages, and when the water level of the order-preserving queue is higher than the first set threshold, the first message forwarding mode is switched to the second message forwarding mode to forward messages. For example, assuming that the target service is a game service that is prone to a surge in traffic at a set time, then the processor core used to process the target message corresponding to the target service is prone to a sudden increase in load in a short period of time, resulting in processor core abnormalities. In this case, the first implementation method can be used, as described in the aforementioned embodiment.
[0071] As another implementation method, if the target service causes the processor core to show a long-term high load abnormal phenomenon, then the second implementation method can be used. For example, if the network traffic corresponding to the target service is a large flow, it may cause the processor core used to process the target message corresponding to the target service to be abnormal for a long time. In this case, if Figure 3 As shown, the packet forwarding mode can be switched through the following second implementation method:
[0072] 301. If the water level of the order-preserving queue is greater than the third set threshold, determine that the target message forwarding mode is the second message forwarding mode, and the timing duration in the second message forwarding mode is the first duration, and after reaching the first duration, determine to switch the target message forwarding mode to the first message forwarding mode.
[0073] 302. After switching to the first message forwarding mode, the following process is iteratively executed until the set conditions are met, and the timing duration is kept unchanged: if it is monitored that the water level of the order-preserving queue is still greater than the third set threshold, it is determined to switch the target message forwarding mode to the second message forwarding mode, and the timing duration in the second message forwarding mode is updated to the second duration according to the set timing duration increment strategy; wherein, the set condition is that the timing duration for switching the target message forwarding mode to the second message forwarding mode is updated to the set duration upper limit.
[0074] 303. Within the target duration after switching to the first message forwarding mode, if the water level of the order-preserving queue is less than or equal to a third set threshold, reduce the timing duration after the next switching to the second message forwarding mode.
[0075] In specific implementation, if the water level of the order-preserving queue is greater than the third set threshold value (such as 4K) at time T1, it means that the current water level of the order-preserving queue is high. In order to reduce the water level of the order-preserving queue without affecting the normal forwarding of messages, the second message forwarding mode can be used to forward messages. After using the second message forwarding mode to forward messages for the first duration (such as 1s), the message forwarding mode can be automatically switched from the second message forwarding mode to the first message forwarding mode at time T2 to detect whether the water level of the order-preserving queue has returned to normal, where T2=T1+1s, indicating the time 1 second after the switching at time T1.
[0076] After switching to the first message forwarding mode at T2, if it is monitored again that the water level of the order-preserving queue is still greater than the third set threshold, it is determined that the water level of the current order-preserving queue is still high. At this time, in order to lower the water level of the order-preserving queue, it is still necessary to switch the message forwarding mode from the first message forwarding mode to the second message forwarding mode, and update the timing duration in the second message forwarding mode to the second duration (such as 2s) according to the set timing duration increment strategy. Assuming that the time consumption caused by monitoring whether the water level exceeds the third set threshold is not considered, it can be considered that the switching time at this time is T2. Taking the timing duration increment strategy of "double each update" as an example, then at T3=T2+2s, it will automatically switch to the first message forwarding mode again.
[0077] In the embodiment of the present invention, the upper limit value (set time limit) to which the timing duration is updated can be set, for example, 64s, which means that if the water level of the order-preserving queue is monitored to be higher than the third set threshold each time after switching to the first message forwarding mode, and when T is determined according to the above iterative process n =T n-1 After switching to the first message forwarding mode at time +64s, when the water level of the order-preserving queue is still greater than the third set threshold, it is determined to switch to the second message forwarding mode next. At this time, the timing duration in the second message forwarding mode remains at 64s and will no longer be "doubled". After that, it is equivalent to switching to the first message forwarding mode every 64s to detect whether the water level of the order-preserving queue is lower than the third set threshold.
[0078] The reason why the water level of the order-preserving queue can only be detected when switching to the first message forwarding mode is that PSNs are allocated to newly received messages only in this mode. Through the allocation of PSNs and their storage in the order-preserving queue, the total number of PSNs stored in the order-preserving queue (i.e., the water level) can be known.
[0079] By increasing the timing duration each time the first message forwarding mode is switched to the second message forwarding mode, the water level recovery time of the order-preserving queue can be continuously increased. It should be understood that each time the second message forwarding mode is executed, it will switch to the first message forwarding mode after a period of time to detect whether the water level of the order-preserving queue has been restored. Therefore, the result obtained in each detection is: when the water level of the order-preserving queue is still greater than the third set threshold, it means that the water level of the order-preserving queue has not returned to normal, and it may take more time to return to normal. In view of this, the time for the next execution of message forwarding in the second message forwarding mode can be increased to provide more time for the water level recovery of the order-preserving queue, thereby ensuring that when the water level of the order-preserving queue returns to normal (that is, less than or equal to the third set threshold), it can switch back to the first message forwarding mode for subsequent message forwarding work, further improving the message forwarding performance of the gateway device.
[0080] Furthermore, in the above iterative process, if it is found that the water level of the order-preserving queue is less than or equal to the third set threshold within the target duration after switching to the first message forwarding mode, the timing duration after the next switch to the second message forwarding mode can be reduced.
[0081] Optionally, if the first message forwarding mode is switched after being in the second message forwarding mode for t seconds (i.e., the timing duration is t seconds), the target duration can be determined as t seconds, or it can be a duration greater than t seconds. At this time, the timing duration can be reduced, for example, by half, such as 0.5t.
[0082] For example, assuming that in the above T n=T n-1 At time +64s, the second message forwarding mode is switched to the first message forwarding mode. After that, it is detected that the water level of the order-preserving queue is less than the third set threshold, and it continues to be lower than the third set threshold in the next 64s, which means that the first message forwarding mode is used in these 64s. After that, the timing duration can be updated to 32s. Assume that at T k =T n-1 At the moment of +64s+64s+5s (assuming that the first message forwarding mode is used in these 69s), it is detected that the water level of the order-preserving queue is higher than the third set threshold, then the second message forwarding mode is switched. At this time, the timing duration of the second message forwarding mode is determined to be 32s, that is, at T k After +32s, the first message forwarding mode is switched again to detect the water level of the order-preserving queue.
[0083] The above embodiments are all from the perspective of hardware, that is, programmable chips, to introduce how to switch different forwarding modes according to the water level of the order-preserving queue. Figure 4 The illustrated embodiment introduces a solution for switching the forwarding mode from the software level, that is, from the perspective of the processor core.
[0084] Figure 4 A flow chart of determining a target message forwarding mode provided by an embodiment of the present invention, such as Figure 4 As shown, the following steps are included:
[0085] 401. The programmable chip receives a switching instruction sent by the third processor core, where the switching instruction is used to instruct switching from the second message forwarding mode to the first message forwarding mode. The switching instruction is triggered when the third processor core detects that there is a receiving queue with a water level higher than a fourth set threshold among multiple receiving queues.
[0086] 402. The programmable chip determines, according to the switching instruction, that the target message forwarding mode is the first message forwarding mode.
[0087] In actual applications, multiple processor cores include both processor cores for message processing and processor cores for forwarding mode control, and the third processor core can be a processor core for forwarding mode control randomly selected from the multiple processor cores. Of course, the third processor core can not only perform forwarding mode control but also message processing, which is not limited here.
[0088] When implementing it, Figure 5As shown, when the third processor core detects that there is a DMA receiving queue with a water level higher than the fourth set threshold value among the multiple DMA receiving queues corresponding to the target service, a switching instruction is sent to the programmable chip, so that the programmable chip switches the message forwarding mode from the second message forwarding mode to the first message forwarding mode according to the switching instruction. Among them, the DMA receiving queue can actually reflect the message receiving rate, so the number of messages transmitted per second (Packet Per Second, referred to as PPS) can be used as a measurement indicator, so the fourth set threshold value can be a set PPS threshold value, such as 1M / s (one megabit per second).
[0089] It should be understood that multiple messages corresponding to the target service need to be sent to multiple processor cores for processing through multiple DMA receive queues. If there is a DMA receive queue with a high water level, it means that one or more of the multiple processor cores may have a high load, which will cause the water level of the order-preserving queue to rise. Therefore, the water level of the DMA receive queue is positively correlated with the water level of the order-preserving queue. In view of this, using a third processor core to monitor the water level of multiple DMA receive queues can be used as a supplement to the water level monitoring of the order-preserving queue, so as to perform corresponding message forwarding mode switching.
[0090] It should be noted that if at time T the third processor core detects that there is a DMA receive queue with a water level higher than the fourth set threshold value among multiple DMA receive queues, at this time, it sends a message forwarding mode switching instruction to the programmable chip to switch the message forwarding mode from the second message forwarding mode to the first message forwarding mode. At the same time at time T, the programmable chip finds based on the water level of the order-preserving queue it monitors that the water level of the order-preserving queue is at a high state and needs to switch the message forwarding mode from the first message forwarding mode to the second message forwarding mode, that is, the switching instructions of the third processor and the programmable chip conflict. At this time, the water level of the order-preserving queue monitored by the programmable chip shall prevail, that is, the message forwarding mode switch from the first message forwarding mode to the second message forwarding mode is executed.
[0091] The message forwarding device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0092] Figure 6 A schematic diagram of the structure of a message forwarding device provided in an embodiment of the present invention, the device is applied to a programmable chip in a network card, the network card is located in a gateway device, and the gateway device includes multiple processor cores, such as Figure 6 As shown, the device includes: a determination module 11, a first sending module 12 and a second sending module 13.
[0093] The determination module 11 is used to determine the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, wherein the order-preserving queue corresponds to the first message forwarding mode and is used to store message sequence numbers.
[0094] The first sending module 12 is used to send the target message to the first processor core for processing in a polling manner in response to the reception of the target message if the target message forwarding mode is the first message forwarding mode, and to send the first processed message fed back by the first processor core to the destination device in sequence based on the message sequence number allocated in the order-preserving queue, and the target message corresponds to the target service.
[0095] The second sending module 13 is used to send the target message to the second processor core corresponding to the target service for processing in response to the reception of the target message if the target message forwarding mode is the second message forwarding mode, and to send the second processed message fed back by the second processor core directly to the destination device; wherein the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0096] Among them, optionally, the determination module 11 is specifically used to: if the water level of the order-preserving queue is greater than a first set threshold, determine that the target message forwarding mode is the second message forwarding mode; if the water level of the order-preserving queue is less than a second set threshold, determine that the target message forwarding mode is the first message forwarding mode, wherein the first set threshold is greater than the second set threshold.
[0097] Among them, optionally, the determination module 11 is also specifically used for: if the water level of the order-preserving queue is greater than a third set threshold, then determining that the target message forwarding mode is the second message forwarding mode, and the timing duration in the second message forwarding mode is the first duration, and after reaching the first duration, determining to switch the target message forwarding mode to the first message forwarding mode.
[0098] Optionally, the device also includes: an iteration module, which is used to iteratively execute the following process after switching to the first message forwarding mode until the set condition is met, keeping the timing duration no longer changing: if it is monitored that the water level of the order-preserving queue is still greater than the third set threshold, determine to switch the target message forwarding mode to the second message forwarding mode, and update the timing duration in the second message forwarding mode to the second duration according to the set timing duration increment strategy; wherein the set condition is that the timing duration for switching the target message forwarding mode to the second message forwarding mode is updated to the set duration upper limit.
[0099] Among them, optionally, the iteration module is specifically used to: within the target duration after switching to the first message forwarding mode, if the water level of the order-preserving queue is less than or equal to the third set threshold, then reduce the timing duration after the next switch to the second message forwarding mode.
[0100] Among them, optionally, the determination module 11 is also specifically used to: receive a switching instruction issued by a third processor core, the switching instruction is used to instruct switching from the second message forwarding mode to the first message forwarding mode, and the switching instruction is triggered when the third processor core detects that there is a receiving queue among the multiple receiving queues whose water level is higher than a fourth set threshold; according to the switching instruction, determine that the target message forwarding mode is the first message forwarding mode.
[0101] Among them, optionally, the first sending module 12 is specifically used to: assign a target message sequence number corresponding to the target message in the order-preserving queue, send the target message carrying the target message sequence number to the first processor core for processing in a polling manner, and determine the sending order of the first processed message fed back by the first processor core according to the message sequence number currently stored in the order-preserving queue, and after sending the first processed message to the destination device according to the sending order, delete the target message sequence number in the order-preserving queue.
[0102] Among them, optionally, the target message also carries identification information corresponding to the target message forwarding mode; the first sending module 12 is specifically used to: parse the first processed message to obtain the first identification information corresponding to the first message forwarding mode and the target message sequence number; based on the first identification information and the target message sequence number, query the message sequence number currently stored in the order preservation queue; if the target message sequence number is the same as the minimum message sequence number among the currently stored message sequence numbers, determine to send the first processed message immediately; if there is a message sequence number less than the target message sequence number among the currently stored message sequence numbers, cache the first processed message, and determine that the sending order of the first processed message is after the processed message corresponding to the message sequence number less than the target message sequence number.
[0103] Among them, optionally, the target message also carries identification information corresponding to the target message forwarding mode; the second sending module 13 is specifically used to: parse the second processed message to obtain the second identification information corresponding to the second message forwarding mode; based on the second identification information, send the second processed message directly to the destination device.
[0104] Figure 6The device shown can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.
[0105] In addition, an embodiment of the present invention provides a network card, wherein the network card includes a programmable chip, and the network card is respectively connected to multiple processor cores in the gateway device. The programmable chip may be a field programmable gate array (FPGA), a complex programmable logic device (CPLD), a system on chip (SoC), or a processor core. Chip, SoC for short), etc., the programmable chip is used to determine the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store the message sequence number; if the target message forwarding mode is the first message forwarding mode, then in response to the reception of the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number allocated in the order-preserving queue; if the target message forwarding mode is the second message forwarding mode, then in response to the reception of the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, the target message corresponds to the target service, and the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0106] In addition, an embodiment of the present invention provides a gateway device, which includes: a network card and multiple processor cores. Among them, the network card includes a programmable chip, and the network card is respectively connected to the multiple processor cores in communication; the programmable chip is used to: determine the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store the message sequence number; if the target message forwarding mode is the first message forwarding mode, then in response to the reception of the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue; if the target message forwarding mode is the second message forwarding mode, then in response to the reception of the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, the target message corresponds to the target service, and the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode.
[0107] In addition, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a programmable chip in a gateway device, the programmable chip can at least implement the message forwarding method provided in the aforementioned embodiment.
[0108] In addition, an embodiment of the present invention provides a computer program product, which includes: a computer program, when the computer program is executed by a programmable chip in a gateway device, the programmable chip can at least implement the message forwarding method provided in the aforementioned embodiment.
[0109] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0110] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and application programs. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A message forwarding method, characterized in that: A programmable chip applied to a network card, wherein the network card is located in a gateway device, wherein the gateway device includes a plurality of processor cores, and the method includes: Determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, wherein the order-preserving queue corresponds to the first message forwarding mode, the order-preserving queue is used to store message sequence numbers, and the water level of the order-preserving queue refers to the number of allocated message sequence numbers stored in the order-preserving queue; If the target message forwarding mode is the first message forwarding mode, in response to receiving the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue, the target message corresponds to the target service, and the first message forwarding mode is a dynamic load balancing mode; If the target message forwarding mode is the second message forwarding mode, then in response to receiving the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device; wherein, the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode, the second message forwarding mode is a receiving side scaling mode, the order-preserving queue is not used in the second message forwarding mode to implement the message order-preserving function, and when the water level of the order-preserving queue drops to meet the set conditions, it is determined to switch back to the first message forwarding mode to continue message forwarding processing.
2. The method according to claim 1, characterized in that Determining the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service includes: If the water level of the order-preserving queue is greater than the first set threshold, determining that the target message forwarding mode is the second message forwarding mode; If the water level of the order-preserving queue is less than a second set threshold, the target message forwarding mode is determined to be the first message forwarding mode, wherein the first set threshold is greater than the second set threshold.
3. The method according to claim 1, characterized in that Determining the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service includes: If the water level of the order-preserving queue is greater than the third set threshold, the target message forwarding mode is determined to be the second message forwarding mode, and the timing duration in the second message forwarding mode is the first duration, and after reaching the first duration, it is determined to switch the target message forwarding mode to the first message forwarding mode.
4. The method according to claim 3, characterized in that: The method further comprises: After switching to the first message forwarding mode, the following process is iteratively executed until the set conditions are met, and the timing duration is kept unchanged: if it is monitored that the water level of the order-preserving queue is still greater than the third set threshold, it is determined to switch the target message forwarding mode to the second message forwarding mode, and the timing duration in the second message forwarding mode is updated to the second duration according to the set timing duration increment strategy; wherein the set condition is that the timing duration for switching the target message forwarding mode to the second message forwarding mode is updated to the set duration upper limit.
5. The method according to claim 4, characterized in that Determining the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service includes: Within the target duration after switching to the first message forwarding mode, if the water level of the order-preserving queue is less than or equal to the third set threshold, the timing duration after the next switching to the second message forwarding mode is reduced.
6. The method according to claim 1, characterized in that Determining the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service includes: receiving a switching instruction sent by the third processor core, the switching instruction being used to instruct switching from the second message forwarding mode to the first message forwarding mode, the switching instruction being triggered when the third processor core detects that there is a receiving queue whose water level is higher than a fourth set threshold among multiple receiving queues for receiving messages on the network card; According to the switching instruction, the target message forwarding mode is determined to be the first message forwarding mode.
7. The method according to any one of claims 1 to 6, characterized in that: The step of sending the target message to the first processor core for processing in a polling manner, and sending the first processed message fed back by the first processor core to the destination device in sequence based on the message sequence number allocated in the order-preserving queue, includes: Assign a target message sequence number corresponding to the target message in the order-preserving queue, send the target message carrying the target message sequence number to the first processor core for processing in a polling manner, and determine the sending order of the first processed message fed back by the first processor core according to the message sequence number currently stored in the order-preserving queue; after sending the first processed message to the destination device according to the sending order, delete the target message sequence number from the order-preserving queue.
8. The method according to claim 7, characterized in that The target message also carries identification information corresponding to the target message forwarding mode; The determining, according to the message sequence numbers currently stored in the order-preserving queue, the sending order of the first processed messages fed back by the first processor core comprises: Parsing the first processed message to obtain first identification information corresponding to the first message forwarding mode and the target message sequence number; Based on the first identification information and the target message sequence number, query the message sequence number currently stored in the order-preserving queue; If the target message sequence number is the same as the minimum message sequence number among the currently stored message sequence numbers, determining to immediately send the first processed message; If there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, the first processed message is cached, and the sending order of the first processed message is determined to be after the processed message corresponding to the message sequence number smaller than the target message sequence number.
9. A network card, characterized in that: The network card includes a programmable chip, and the network card is respectively connected to multiple processor cores in the gateway device; The programmable chip is used to determine the target message forwarding mode according to the water level of the order-preserving queue corresponding to the target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store the message sequence number; If the target message forwarding mode is the first message forwarding mode, in response to receiving the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue; If the target message forwarding mode is the second message forwarding mode, then in response to receiving the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, and when the water level of the order-preserving queue drops to meet the set conditions, it is determined to switch back to the first message forwarding mode to continue message forwarding processing, the target message corresponds to the target service, the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode, the water level of the order-preserving queue refers to the number of allocated message sequence numbers stored in the order-preserving queue, the first message forwarding mode is a dynamic load balancing mode, the second message forwarding mode is a receiver scaling mode, and the order-preserving queue is not used in the second message forwarding mode to implement the message order-preserving function.
10. A gateway device, characterized in that: include: Multiple processor cores; A network card, wherein the network card includes a programmable chip and the network card is communicatively connected to the multiple processor cores respectively; The programmable chip is used to: determine a target message forwarding mode according to a water level of an order-preserving queue corresponding to a target service, the order-preserving queue corresponds to the first message forwarding mode, and the order-preserving queue is used to store a message sequence number; If the target message forwarding mode is the first message forwarding mode, in response to receiving the target message, the target message is sent to the first processor core for processing in a polling manner, and the first processed message fed back by the first processor core is sent to the destination device in sequence based on the message sequence number assigned in the order-preserving queue; If the target message forwarding mode is the second message forwarding mode, then in response to receiving the target message, the target message is sent to the second processor core corresponding to the target service for processing, and the second processed message fed back by the second processor core is directly sent to the destination device, and when the water level of the order-preserving queue drops to meet the set conditions, it is determined to switch back to the first message forwarding mode to continue message forwarding processing, the target message corresponds to the target service, the water level corresponding to the first message forwarding mode is lower than the water level corresponding to the second message forwarding mode, the water level of the order-preserving queue refers to the number of allocated message sequence numbers stored in the order-preserving queue, the first message forwarding mode is a dynamic load balancing mode, the second message forwarding mode is a receiver scaling mode, and the order-preserving queue is not used in the second message forwarding mode to implement the message order-preserving function.
11. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method according to any one of claims 1 to 8.
12. A computer program product, characterized in that include: A computer program, when the computer program is executed by a programmable chip in a gateway device, causes the programmable chip to execute the message forwarding method as described in any one of claims 1-8.
Citation Information
Patent Citations
Dynamic load balancing in network interface cards for optimal system level performance
CN108694087A
Method and apparatus to assign and check Anti-replay sequence numbers using load balancing
US20230198912A1