Message flow processing method and device, electronic equipment and medium
By using the predictive model in the cloud computing soft load balancer to identify elephant flows and perform break-up and reorganization processing, the problem of excessive single-core processing is solved, multi-core balancing of elephant flows is achieved, and processing efficiency and service quality are improved.
Patent Information
- Application Number
- CN202410989363.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-01
AI Technical Summary
In the field of cloud computing, the soft load balancer developed based on DPDK has a large proportion of elephant flows, resulting in excessive single-core processing and inability to effectively utilize multi-core performance, resulting in processing bottlenecks and packet loss.
By using the trained prediction model to predict the message flow, determine whether it is an elephant flow, break it up and reorganize it, and hand it over to additional cores for processing, achieving balanced distribution of the elephant flow to multiple cores.
It improves processing efficiency, avoids single-core performance bottlenecks, significantly improves service quality, and reduces packet loss and bandwidth degradation.
Smart Images

Figure CN118740745A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of core networks, and in particular to a message flow processing method, device, electronic device, and medium. Background Art
[0002] In the field of cloud computing, the soft load balancer developed based on DPDK adopts a multi-core independent, polling-driven business model. The RSS mechanism of the packet receiving network card will hash the message according to the five-tuple attribute of the message to multiple queues. The elephant flow with exactly the same five-tuple will be assigned to the same packet receiving queue. Since the elephant flow traffic accounts for a very large proportion, usually reaching more than 80% of the total service traffic, it will cause a single core to process 80% of the traffic and the remaining 20% will be distributed to the remaining cores. Since there is no special processing for the elephant flow, all the pressure is handed over to one working core, and the performance of the remaining cores cannot be used. The elephant flow will exceed the processing capacity of the single core, which will cause subsequent packets sent to the core to be lost, affecting the quality of the soft load balancer service. Summary of the invention
[0003] In order to solve the problems existing in the related technology, the present invention proposes a message flow processing method, which uses a trained prediction model to predict a small number of message flow samples to determine whether it is an elephant flow. If so, the message flow is sent to an additional core for fragmentation and reorganization processing, thereby improving the processing efficiency and balancing the elephant flow to multiple cores for processing, thereby avoiding the performance bottleneck of a single core.
[0004] The first aspect of the present disclosure proposes a message flow processing method, which includes: obtaining a target prediction model, the target prediction model is obtained by training an initial prediction model using training data; using the target prediction model to predict multiple first messages, and determining whether the first message flow corresponding to the multiple first messages is an elephant flow, the multiple first messages are obtained after sampling and screening the first message flow; determining the first message flow whose prediction result is an elephant flow as a second message flow, and adding the second message obtained after sampling and screening the second message flow to a hash table; when the current message in the first message flow matches the message in the hash table, breaking up and reorganizing the current message.
[0005] In some embodiments of the present disclosure, the method also includes: sampling messages in the first message stream and storing descriptors of the sampled messages in a first queue; polling the first queue and determining messages that meet a first condition as first messages, the first condition being: the number of messages with the same five-tuple exceeds a first number and the length of the message is greater than a first length.
[0006] In some embodiments of the present disclosure, adding the second message obtained after sampling and screening the second message flow into the hash table includes: marking the five-tuple feature of the second message; using the five-tuple feature as the key and the identifier of the second message as the value to store in the hash table.
[0007] In some embodiments of the present disclosure, when a current message in a first message flow matches a message in a hash table, breaking up and reassembling the current message includes: redirecting the current message to an elephant flow processing thread; taking out a third message from the elephant flow processing thread in sequence, selecting a corresponding processing thread according to the five-tuple feature and TCP sequence number of the third message, and adding the third message to a second queue of the processing thread; sorting multiple messages in the second queue based on the TCP sequence number of the third message to determine a first sorting number; when the processing thread completes processing the third message, adding an identifier of the third message to a global packet sending queue; and reassembling multiple messages in the global packet sending queue.
[0008] In some embodiments of the present disclosure, reorganization processing of multiple messages in the global packet sending queue includes: taking out the third message from the global packet sending queue in sequence; selecting a red-black tree corresponding to the message flow based on the five-tuple feature of the third message, using the TCP sequence number of the third message as the key, and adding the descriptor of the third message to the red-black tree; when the TCP sequence number of the smallest node in the red-black tree is the same as the first sorting number, taking out the message corresponding to the smallest node from the second queue to the corresponding packet sending port.
[0009] In some embodiments of the present disclosure, the method further includes: setting a first timer, and clearing useless entries in the hash table according to the first timer.
[0010] The second aspect of the present disclosure proposes a message flow processing device, which includes: an acquisition module, used to acquire a target prediction model, the target prediction model is obtained by training an initial prediction model using training data; a prediction module, used to use the target prediction model to predict multiple first messages, and determine whether the first message flow corresponding to the multiple first messages is an elephant flow, and the multiple first messages are obtained after sampling and screening the first message flow; a determination module, used to determine the first message flow with a prediction result of being an elephant flow as a second message flow, and add the second message obtained after sampling and screening the second message flow to a hash table; a processing module, used to break up and reorganize the current message when the current message in the first message flow matches the message in the hash table.
[0011] The third aspect embodiment of the present disclosure proposes an electronic device, comprising: one or more processors; a storage device communicatively connected to the one or more processors, on which one or more programs are stored; when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in the first aspect embodiment of the present disclosure.
[0012] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the first aspect embodiment of the present disclosure.
[0013] The fifth aspect embodiment of the present disclosure provides a computer program product, including a computer program, and the computer program implements the method described in the first aspect embodiment of the present disclosure after being executed.
[0014] In summary, according to the message flow processing method proposed in the present disclosure, by obtaining a target prediction model; using the target prediction model to predict multiple first messages, determine whether the first message flow corresponding to the multiple first messages is an elephant flow, and the multiple first messages are obtained after sampling and screening the first message flow; determine the first message flow whose prediction result is an elephant flow as a second message flow, and add the second message obtained after sampling and screening the second message flow to the hash table; when the current message in the first message flow matches the message in the hash table, the current message is scattered and reorganized. By using a trained prediction model to predict a small number of message flow samples, it is determined whether it is an elephant flow. If so, the message flow is handed over to an additional core for scattering and distributed to all available working threads for processing, and sent to the packet sending port after reorganization processing, the processing efficiency is improved, and the elephant flow is balanced to multiple cores for processing to avoid single-core performance bottlenecks.
[0015] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0017] Figure 1 Forwarding schematic diagram for DPVS;
[0018] Figure 2 A flow chart of a method for processing a packet flow proposed in an embodiment of the present disclosure;
[0019] Figure 3 A schematic diagram of the sampling and screening process proposed in the embodiment of the present disclosure;
[0020] Figure 4 A schematic diagram of a process of breaking up and reassembling the current message proposed in an embodiment of the present disclosure;
[0021] Figure 5 A schematic diagram of a process for reassembling multiple messages proposed in an embodiment of the present disclosure;
[0022] Figure 6 A flowchart of a method for processing a packet flow according to an embodiment of the present disclosure;
[0023] Fig. 7A A flowchart of a method for processing a message flow provided by an embodiment of the present disclosure;
[0024] Figure 7B A flow chart of elephant flow detection provided by an embodiment of the present disclosure;
[0025] Figure 7C A flowchart of the elephant flow processing provided for the embodiment of the present disclosure;
[0026] Figure 8 A schematic diagram of the structure of a packet flow processing device proposed in an embodiment of the present disclosure;
[0027] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] Embodiments of the present disclosure are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. Embodiments are described below with reference to the accompanying drawings.
[0029] In the field of cloud computing, since the number of requests from users is very large, it often exceeds the performance limit of a server. Therefore, load balancing devices are needed to distribute the requests to multiple service nodes. Software load balancing programs developed based on the DPDK framework have gradually become the mainstream of cloud services. The soft load balancer developed based on DPDK adopts a multi-core independent, polling-driven business model. The DPVS forwarding principle diagram in its architecture is as follows: Figure 1 As shown in the figure, DPVS runs at the transport layer of the OSI reference model. It selects the appropriate backend service node and forwards the request based on the characteristic five-tuple (protocol number, source address, source port, destination address, destination port) of the user request message. DPVS binds multiple working cores (or working threads, referred to as workers) to multiple queues of the network card, and each core polls its own sending queue and receiving queue descriptors. After receiving the service message, DPVS intercepts the message at the network layer, selects the backend node based on the pre-configured virtual service, and modifies the description information of the message according to the service mode.
[0030] The present invention proposes a message flow processing method, which utilizes the powerful learning and reasoning ability of artificial neural networks to determine whether the flow is an elephant flow based on a small amount of data flow samples. If it is, the subsequent traffic of the request is broken up by an additional core and distributed to all available working threads for processing. Finally, the processing results are reorganized and sent to the network card for forwarding.
[0031] The message flow processing method provided in this application is described in detail below with reference to the accompanying drawings.
[0032] Figure 2 The following is a flow chart of a method for processing a message flow proposed in an embodiment of the present disclosure. Figure 2 As shown, the method includes the following steps.
[0033] Step 201, obtaining a target prediction model.
[0034] In an embodiment of the present disclosure, the target prediction model is obtained by training the initial prediction model using training data.
[0035] In an embodiment of the present disclosure, the target prediction model may be a FFN feedforward network, which is a common feature projection component in a deep neural network model. Multi-layer FFN has the advantages of simple structure, nonlinearity, and low computational complexity.
[0036] In some embodiments, the target prediction model may be a recurrent neural network or a model based on a set of rules such as Sketch.
[0037] In the embodiment of the present disclosure, the target prediction model is used to predict the message flow and determine whether the message flow is an elephant flow. The target prediction model can be obtained by training in the device of the present disclosure, or it can be trained in advance and used in the present method. Among them, the training data of the target prediction model can be multiple groups of message flows belonging to elephant flows, and the training method of the target prediction model is not limited.
[0038] Step 202: Use the target prediction model to predict the multiple first messages, and determine whether the first message flow corresponding to the multiple first messages is an elephant flow.
[0039] In the embodiment of the present disclosure, the plurality of first messages are obtained by sampling and filtering the first message flow. In other words, the first message is a message sample obtained by sampling and filtering the first message flow according to the conditions preset in the present disclosure.
[0040] In an embodiment of the present disclosure, using a target prediction model to predict multiple first messages can be to predict the messages after sampling and filtering in the first message flow, so that only part of the samples can be predicted to determine whether the message flow is an elephant flow.
[0041] For example, the message samples are transmitted to the pre-trained multi-layer FFN for classification prediction.
[0042] In the above embodiment, by using the trained model to predict the message samples, the message flow belonging to the elephant flow can be obtained, and then the message flow of the elephant flow is processed accordingly to achieve load balancing processing of the elephant flow.
[0043] Step 203, determining the first message flow predicted to be an elephant flow as the second message flow, and adding the second message obtained after sampling and screening the second message flow into the hash table.
[0044] In an embodiment of the present disclosure, the second message flow is the first message flow that is predicted to belong to the elephant flow. Adding the second message flow obtained after sampling and screening to the hash table can be storing the message samples of the message flow belonging to the elephant flow into the marked hash table for use in subsequent processes.
[0045] In an embodiment of the present disclosure, the process of sampling and filtering the second message stream is the same as the method of sampling and filtering the first message stream to obtain the first message in step 202, that is, the second message is a message sample determined from the second message stream according to the sampling and filtering conditions preset in the present disclosure.
[0046] In an embodiment of the present disclosure, adding the second message to the hash table may be to mark a five-tuple feature of the second message, and use the five-tuple feature as a key and the identifier of the second message as a value to store it in the hash table.
[0047] In an embodiment of the present disclosure, the hash table may be a data structure with a five-tuple feature as a key and a message identifier as a value.
[0048] In an embodiment of the present disclosure, adding the second message to the hash table may be to store the features of the message belonging to the elephant flow in the hash table, so that subsequent messages can be matched with the hash table to determine whether the message flow corresponding to the current message is the elephant flow.
[0049] For example, the detector marks the five-tuple features of the sample predicted as an elephant flow and adds them to the global marking hash table for use in subsequent processes.
[0050] Step 204: When the current message in the first message flow matches the message in the hash table, the current message is broken up and reassembled.
[0051] In an embodiment of the present disclosure, when a current message in the first message flow matches a message in a hash table, the five-tuple feature of the current message may be consistent with the five-tuple feature of the second message in the hash table.
[0052] For example, all workers query the above-mentioned tag hash table when processing a message, and if a hit is found, the message is redirected to a separate processing thread for decomposition and reassembly.
[0053] In an embodiment of the present disclosure, the current message can be broken up and reassembled by isolating the message belonging to the elephant flow into a separate processing thread, and breaking it up according to the characteristics of the message. After the processing is completed, all the messages are reassembled in the original order, so that the order of the messages after breaking up and reassembling remains unchanged.
[0054] In summary, according to the message flow processing method proposed in the present disclosure, a target prediction model is obtained by training the initial prediction model using training data; a plurality of first messages are predicted using the target prediction model to determine whether the first message flow corresponding to the plurality of first messages is an elephant flow, and the plurality of first messages are obtained after sampling and screening the first message flow; the first message flow whose prediction result is an elephant flow is determined as a second message flow, and the second message obtained after sampling and screening the second message flow is added to a hash table; when the current message in the first message flow matches the message in the hash table, the current message is broken up and reassembled. By using a trained prediction model to predict a small number of message samples, it is determined whether the current message flow is an elephant flow. If so, the message flow is handed over to an additional core for breaking up and reassembling, which improves processing efficiency, and realizes balancing the elephant flow to multiple cores for processing, thereby avoiding single-core performance bottlenecks.
[0055] based on Figure 2 The embodiment shown, Figure 3 The following is a schematic diagram of the sampling and screening process proposed in the present disclosure. Figure 3 based on Figure 2 In the embodiment shown, the method further comprises the following steps:
[0056] Step 301: Sample the messages in the first message flow, and store the descriptors of the sampled messages in a first queue.
[0057] In the embodiment of the present disclosure, sampling the packets in the first packet flow may be performing a sampling operation according to a preset number or rule, and determining a preset number of packets as sampled packets.
[0058] In the embodiment of the present disclosure, sampling the packets in the first packet flow may be obtaining a portion of packets at the beginning or end of the first packet flow.
[0059] In an embodiment of the present disclosure, the message descriptor may be used to describe the structure and purpose of a message, so that after receiving the message, the Host can parse the message content according to the message format described by the message descriptor. The descriptor may include a message ID, the data length of the message, the sender and the receiver, etc.
[0060] For example, the DPDK packet descriptor is stored in a lock-free circular queue during the packet sending phase.
[0061] Step 302: poll the first queue and determine the message that meets the first condition as the first message.
[0062] In an embodiment of the present disclosure, the first condition is: the number of messages with the same quintuple exceeds a first number, and the length of the message is greater than the first length.
[0063] In an embodiment of the present disclosure, polling the first queue and screening the messages in the first queue may be completed by a separate detector core.
[0064] In an embodiment of the present disclosure, determining a message that meets the first condition as a first message may be determining a message whose number exceeds a first number and whose length is greater than a first length as a first message, wherein the first number and the first length are preset values, and different values may be set in different schemes, which is not limited by the present disclosure.
[0065] For example, a separate detector core polls the message samples in the lock-free ring queue and performs preliminary statistical screening. The specific screening rule is: take the messages with the same quintuple count exceeding 100 and the message length greater than 500 bytes, and transmit these messages to the pre-trained multi-layer FFN for classification prediction.
[0066] In the above embodiment, by setting the screening conditions, the sampled messages are screened, and the screened messages are used as the input of the model classification prediction, so that the type of the message flow can be determined based on only a small number of message samples, thereby improving efficiency.
[0067] based on Figure 2 , Figure 3 The embodiment shown, Figure 4 The following is a schematic diagram of the process of breaking up and reassembling the current message proposed by the present disclosure. Figure 4 based on Figure 2 In the embodiment shown, step 204 is further defined. Figure 4 As shown, the method comprises the following steps:
[0068] Step 401, redirect the current message to the elephant flow processing thread.
[0069] In an embodiment of the present disclosure, redirecting the current message to the elephant flow processing thread can be to hand over the message belonging to the elephant flow to an additional core for processing. In other words, the additional core is the elephant flow processing thread, which is responsible for processing the message flow belonging to the elephant flow.
[0070] For example, all workers query the tag hash table when processing messages and redirect the hit messages to a separate elephant flow processing thread.
[0071] Step 402, take out the third message from the elephant flow processing thread in sequence, select the corresponding processing thread according to the five-tuple feature and TCP sequence number of the third message, and add the third message to the second queue of the processing thread.
[0072] In an embodiment of the present disclosure, the third message is a message that sequentially enters the redirection queue of the elephant flow processing thread.
[0073] In the embodiments of the present disclosure, each message has a corresponding TCP sequence number. By selecting the corresponding processing thread according to the five-tuple feature of the third message and the TCP sequence number, multiple messages added to the elephant flow processing thread can be broken up and distributed on different cores, thereby balancing the elephant flow to multiple cores for processing, thereby avoiding the single-core performance bottleneck.
[0074] For example, the Elephant Flow Processing Thread takes a message from its own redirection ring, selects an available worker based on the five-tuple features of the message and the TCP sequence number, and adds the message to the redirection ring of the worker.
[0075] For example, for multiple packets in an elephant flow, the TCP sequence number of each packet is arranged in sequence. If they are scattered to different workers, worker 1 has TCP1, worker 2 has TCP2, worker 3 has TCP3, and so on. Multiple packets in the same packet flow are scattered to different workers according to the TCP sequence number.
[0076] Step 403: sort the multiple messages in the second queue based on the TCP sequence number of the third message, and determine a first sorting number.
[0077] In an embodiment of the present disclosure, sorting the plurality of messages in the second queue based on the TCP sequence number of the third message may be to use a small top heap algorithm to record the sequence number at the top of the heap so as to maintain the order during subsequent reorganization. In other words, the first sorting number may be the TCP sequence number at the top of the heap in the current second queue.
[0078] In an embodiment of the present disclosure, sorting of multiple messages in the second queue may be performed by reordering using an array-based heap structure, thereby reducing the performance loss of indirect addressing in the array structure to achieve an effect of accelerating sorting.
[0079] In the embodiment of the present disclosure, the multiple messages in the second queue may be sorted by using other sorting algorithms, which is not limited by the present disclosure.
[0080] Step 404: When the processing thread finishes processing the third message, the identifier of the third message is added to the global packet sending queue.
[0081] In an embodiment of the present disclosure, adding the identifier of the third message to the global packet sending queue can be to place the scattered message identifiers in the global packet sending queue. The message identifiers in the global packet sending queue are disordered and may be mixed with multiple message streams. The message identifiers in the global packet sending queue correspond one-to-one to the third message in the processing thread.
[0082] For example, after processing the marked message, the worker adds it to the global packet sending ring.
[0083] Step 405: reassemble multiple messages in the global packet sending queue.
[0084] In an embodiment of the present disclosure, the reorganization processing of multiple messages in the global packet sending queue can be to reorder the multiple messages according to the sorting number and the TCP sequence number, so that the messages are sent to the sending queue in the original order and sent to the network card for packet sending.
[0085] For example, the elephant flow processing thread takes out the message from the packet sending ring and reassembles the message into the original elephant flow, selects the sending queue and sends it to the network card for packet sending.
[0086] In the above embodiment, by dispersing the message flow belonging to the elephant flow to multiple cores, each core processes the message inside it separately, and reassembles it after processing, it is achieved that the elephant flow is balanced to multiple cores for processing, avoiding the performance bottleneck of single-core processing.
[0087] based on Figure 2 , Figure 3 , Figure 4 The embodiment shown, Figure 5 The following is a schematic diagram of a process for reassembling multiple messages proposed by the present disclosure. Figure 5 based on Figure 2-Figure 4 The embodiment shown, Figure 4 Step 405 is further defined. Figure 5 As shown, the method comprises the following steps:
[0088] Step 501, taking out the third message from the global packet sending queue in sequence.
[0089] In an embodiment of the present disclosure, taking out the third message from the global packet sending queue may be processing the corresponding third message in sequence according to the message identifier in the global packet sending queue, and the third message is unordered and belongs to multiple elephant flows.
[0090] Step 502: Select a red-black tree corresponding to the message flow based on the five-tuple feature of the third message, use the TCP sequence number of the third message as a key, and add the descriptor of the third message to the red-black tree.
[0091] In an embodiment of the present disclosure, selecting the red-black tree of the corresponding message flow based on the quintuple feature of the third message may be placing messages with the same quintuple feature in the same red-black tree.
[0092] For example, a message is taken out from the packet sending ring and a red-black tree corresponding to the data flow is selected according to the five-tuple, and the descriptor of the message is added to the red-black tree with the TCP sequence number as the key.
[0093] Step 503: When the TCP sequence number of the smallest node in the red-black tree is the same as the first sequence number, the message corresponding to the smallest node is taken out from the second queue to the corresponding packet sending port.
[0094] In an embodiment of the present disclosure, when the TCP sequence number of the smallest node in the red-black tree is the same as the first sorting number, it can be determined whether the smallest TCP serial number taken out from the global packet sending queue and reordered is the same as the first sorting number at the top of the stack in each processing thread when the packet is scattered. If they are the same, it means that there is no packet loss in the message flow, and the message in the corresponding processing thread is taken out and sent to the network card for packet sending.
[0095] In an embodiment of the present disclosure, after taking out the corresponding message in the processing thread, the processing thread will reorder it, determine the first sorting number, and then determine whether the TCP sequence number of the next smallest node in the red-black tree is the same as the first sorting number. If they are the same, the message in the corresponding processing thread will be taken out.
[0096] For example, check the sequence number of the top of the stack and the sequence number of the smallest node in the tree. If they are the same, it means that the message is legal. The node is taken out of the tree and the sending queue is selected to send it to the network card for packet transmission.
[0097] In an embodiment of the present disclosure, when the TCP sequence number of the smallest node in the red-black tree is different from the first sequence number, the first sequence number of the next processing thread is continuously compared until the two are the same, and the message in the corresponding processing thread is taken out.
[0098] In the above embodiment, by adding the messages in the global packet sending queue into the red-black tree of the same message flow according to the five-tuple feature, and comparing the sequence number of the smallest node with the sorting number in the processing thread in turn, the corresponding messages are taken out in order of the TCP sequence number and sent to the corresponding packet sending port, so that the scattered messages can be reassembled and sent in the original order.
[0099] based on Figure 2-Figure 5 The embodiment shown, Figure 6 The following is a flow chart of the message flow processing method proposed in the present disclosure. Figure 6 based on Figure 2-Figure 5 In the embodiment shown, the method further comprises the following steps:
[0100] Step 601, setting a first timer, and clearing useless entries in the hash table according to the first timer.
[0101] In an embodiment of the present disclosure, setting the first timer may be adding a timer in the probe core to clear useless entries in the hash table.
[0102] In an embodiment of the present disclosure, the first timer may be used to clear the message flows in the hash table that have been forwarded.
[0103] In the above embodiment, a timer is added to clean up useless entries in the hash table to prevent the hash table from being too long and occupying space.
[0104] In summary, the message flow processing method proposed in the present disclosure obtains a target prediction model; uses the target prediction model to predict multiple first messages, determines whether the first message flow corresponding to the multiple first messages is an elephant flow, and the multiple first messages are obtained after sampling and screening the first message flow; determines the first message flow whose prediction result is an elephant flow as a second message flow, and adds the second message obtained after sampling and screening the second message flow to the hash table; when the current message in the first message flow matches the message in the hash table, the current message is scattered and reassembled. By using a trained prediction model to predict a small number of message samples, it is determined whether the current message flow is an elephant flow. If so, the message flow is handed over to an additional core for scattered and reassembled processing, which improves the processing efficiency, and realizes the elephant flow balancing to multi-core processing to avoid single-core performance bottlenecks, as well as packet loss and bandwidth reduction problems. In practical applications, it can significantly improve the service quality in elephant flow hot business scenarios such as audio and video transmission and cloud games.
[0105] Fig. 7A A specific embodiment of the message flow processing method provided in the embodiment of the present disclosure is described in detail. Fig. 7A As shown, the method includes the following steps.
[0106] Step 1: Detect elephant flow, such as Figure 7B The elephant flow detection flow chart shown.
[0107] 1.1. Message sampling: The worker performs sampling operations in the process of processing messages, and stores the DPDK message descriptor (mbuf) in a lock-free ring queue (ring) during the packet sending stage;
[0108] Optionally, the packets in the first packet flow are sampled, and the descriptors of the sampled packets are stored in the first queue.
[0109] 1.2. Screening prediction: A separate detector core polls the sample ring and makes preliminary statistical screening.
[0110] The specific screening rules are as follows: take the messages with the same five-tuple count exceeding 100 and the message length greater than 500 bytes, and transmit these messages to the pre-trained multi-layer FFN for classification prediction. For samples predicted as elephant flow, the detector marks its five-tuple features and adds them to the global marking hash table for use in subsequent processes.
[0111] Optionally, the first queue is polled to determine a message that meets a first condition as the first message, and the first condition may be a specific screening rule.
[0112] Optionally, a target prediction model is used to predict multiple first messages to determine whether a first message flow corresponding to the multiple first messages is an elephant flow, the first message flow whose prediction result is an elephant flow is determined as a second message flow, and the second message obtained after sampling and screening the second message flow is added to a hash table.
[0113] The detector will add a timer to clean up unused entries in the tag hash table.
[0114] Step 2: Process the elephant flow, such as Figure 7C The elephant flow processing flowchart shown.
[0115] 2.1. Isolate elephant flow: All workers will query the above-mentioned tag hash table when processing messages. If a hit is found, the message will be redirected to a separate elephant flow processing thread (EFHandler) for fragmentation and reassembly.
[0116] Optionally, when a current message in the first message flow matches a message in the hash table, the current message is broken up and reassembled.
[0117] 2.2. Break up the elephant flow: EFHandler takes the message from its own redirection ring, selects an available worker according to the five-tuple characteristics of the message and the TCP sequence number, and adds the message to the redirection ring of the worker. At the same time, it uses a mini-heap to record the sequence numbers of these messages so that the order can be maintained during subsequent reassembly.
[0118] Optionally, the current message is redirected to the elephant flow processing thread, the third message is taken out from the elephant flow processing thread in sequence, the corresponding processing thread is selected according to the five-tuple feature and TCP sequence number of the third message, and the identifier of the third message is added to the second queue of the processing thread; based on the TCP sequence number of the third message, multiple messages in the second queue are sorted to determine the first sorting number.
[0119] 2.3. Reassembling the elephant flow: After processing the marked message, the worker adds it to the global packet sending ring. At this time, the messages in the ring are out of order and may be mixed with multiple data flows;
[0120] Optionally, when the processing thread finishes processing the third message, the third message is added to the global packet sending queue.
[0121] EFHandler takes the message from the above-mentioned packet sending ring and selects the red-black tree of the corresponding data stream according to its five-tuple, and adds the descriptor of the message to the red-black tree with the TCP sequence number as the key; at the same time, it checks the sequence number at the top of the stack and the sequence number of the smallest node in the tree. If they are the same, it means that the message is legal, takes the node out of the tree and selects the sending queue to send it to the network card for packet sending.
[0122] Optionally, a red-black tree corresponding to the message flow is selected based on the quintuple feature of the third message, and the TCP sequence number of the third message is used as the key to add the descriptor of the third message to the red-black tree. When the TCP sequence number of the smallest node in the red-black tree is the same as the first sorting number, the message of the smallest node is taken out to the corresponding packet sending port.
[0123] In summary, the message flow processing method provided by the present disclosure has the following beneficial effects:
[0124] 1. Only a small amount of traffic samples are needed to accurately determine the type of message flow, which is highly efficient;
[0125] 2. It makes full use of the multi-core advantage of the DPDK program to balance the elephant flow to multiple cores for processing, thereby avoiding the performance bottleneck of a single core. It is more advantageous to run the soft load balancer on hardware devices with multiple cores and low single-core power consumption, such as Arm architecture machines.
[0126] based on Figure 2-Figure 6 The embodiment shown, as Figure 8 As shown, the present disclosure provides a schematic structural diagram of a packet flow processing device 800. The device 800 includes an acquisition module 810, a prediction module 820, a determination module 830 and a processing module 840.
[0127] The acquisition module 810 is used to acquire a target prediction model, where the target prediction model is obtained by training an initial prediction model using training data.
[0128] The prediction module 820 is used to use the target prediction model to predict multiple first messages and determine whether the first message flow corresponding to the multiple first messages is an elephant flow, and the multiple first messages are obtained after sampling and screening the first message flow.
[0129] The determination module 830 is used to determine the first message flow predicted to be an elephant flow as the second message flow, and add the second message obtained after sampling and screening the second message flow into the hash table.
[0130] The processing module 840 is used to break up and reassemble the current message when the current message in the first message flow matches the message in the hash table.
[0131] In an embodiment of the present disclosure, the prediction module is also used to sample messages in the first message flow, and store the descriptors of the sampled messages in the first queue; poll the first queue, and determine the messages that meet the first condition as the first messages, and the first condition is: the number of messages with the same five-tuple exceeds the first number, and the length of the message is greater than the first length.
[0132] In an embodiment of the present disclosure, the determination module is further used to mark the five-tuple feature of the second message; the five-tuple feature is used as a key and the identifier of the second message is used as a value and stored in the hash table.
[0133] In an embodiment of the present disclosure, the processing module is also used to redirect the current message to the elephant flow processing thread; take out the third message from the elephant flow processing thread in sequence, select the corresponding processing thread according to the five-tuple feature and TCP sequence number of the third message, and add the third message to the second queue of the processing thread; based on the TCP sequence number of the third message, sort the multiple messages in the second queue to determine the first sorting number; when the processing thread finishes processing the third message, add the identifier of the third message to the global packet sending queue; and reorganize the multiple messages in the global packet sending queue.
[0134] In an embodiment of the present disclosure, the processing module is also used to take out the third message from the global packet sending queue in sequence; select the red-black tree corresponding to the message flow based on the quintuple feature of the third message, and use the TCP sequence number of the third message as the key to add the descriptor of the third message to the red-black tree; when the TCP sequence number of the smallest node in the red-black tree is the same as the first sorting number, take out the message corresponding to the smallest node from the second queue to the corresponding packet sending port.
[0135] In an embodiment of the present disclosure, the determination module is further configured to set a first timer, and clear useless entries in the hash table according to the first timer.
[0136] In summary, the message flow processing device proposed in the embodiment of the present disclosure uses a trained prediction model to predict a small number of message samples to determine whether the current message flow is an elephant flow. If so, the message flow is handed over to an additional core for breaking up and reassembling, thereby improving the processing efficiency and balancing the elephant flow to multiple cores for processing, thereby avoiding the performance bottleneck of a single core, as well as the problems of packet loss and bandwidth reduction. In practical applications, it can significantly improve the service quality in business scenarios with elephant flows such as audio and video transmission and cloud games.
[0137] In the embodiments provided in the present application, the methods and systems provided in the embodiments of the present application are introduced. In order to implement the functions in the methods provided in the embodiments of the present application, the electronic device may include a hardware structure and a software module, and implement the functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. A function in the functions may be executed in the form of a hardware structure, a software module, or a hardware structure plus a software module.
[0138] Fig. 9 It is a block diagram of an electronic device 900 for implementing the above-mentioned message flow processing method according to an exemplary embodiment.
[0139] Reference Fig. 9 The electronic device 900 may include a communication interface 901, which can interact with other devices; a processor 902, which is connected to the communication interface 901 to interact with other devices and is used to execute the method provided by one or more of the above technical solutions when running a computer program; and a memory 903, on which the computer program is stored. Specifically, the specific processing process of the processor 902 can refer to the message flow processing method described in the above embodiment of the present disclosure.
[0140] Of course, in actual application, the various components in the electronic device 900 are coupled together through the bus system 904. It can be understood that the bus system 904 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig. 9 Various buses are labeled as bus system 904.
[0141] The memory 903 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device 900. Examples of such data include: any computer program used to operate on the electronic device 900.
[0142] The method disclosed in the above embodiment of the present application can be applied to the processor 902, or implemented by the processor 902. The processor 902 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 902 or an instruction in the form of software. The above processor 902 may be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 902 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 903, and the processor 902 reads the information in the memory 903 and completes the steps of the above method in combination with its hardware.
[0143] In an exemplary embodiment, the electronic device 900 can be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.
[0144] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the message flow processing method described in the above embodiments of the present disclosure.
[0145] The embodiments of the present disclosure further provide a computer program product, including a computer program, which executes the packet flow processing method described in the above embodiments of the present disclosure when a processor is used to execute the computer program.
[0146] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0147] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0148] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0149] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (control method), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.
[0150] It should be understood that the various parts of the embodiments of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0151] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0152] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0153] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A message flow processing method, characterized in that: The method comprises: Obtaining a target prediction model, where the target prediction model is obtained by training an initial prediction model using training data; Predicting a plurality of first messages using the target prediction model to determine whether a first message flow corresponding to the plurality of first messages is an elephant flow, wherein the plurality of first messages are obtained by sampling and screening the first message flow; Determine the first message flow whose prediction result is elephant flow as the second message flow, and add the second message obtained after sampling and screening the second message flow into the hash table; When a current message in the first message flow matches a message in the hash table, the current message is broken up and reassembled.
2. The method according to claim 1, characterized in that The method further comprises: Sampling the messages in the first message flow, and storing the descriptors of the sampled messages in the first queue; The first queue is polled to determine a message that meets a first condition as the first message, where the first condition is: the number of messages with the same quintuple exceeds a first number, and the length of the message is greater than a first length.
3. The method according to claim 1, characterized in that The step of adding the second message obtained after sampling and screening the second message flow into the hash table comprises: Marking the quintuple feature of the second message; The five-tuple feature is used as a key and the identifier of the second message is stored in the hash table as a value.
4. The method according to claim 1, characterized in that: When the current message in the first message flow matches the message in the hash table, breaking up and reassembling the current message includes: Redirect the current message to the elephant flow processing thread; Sequentially take out the third message from the elephant flow processing thread, select the corresponding processing thread according to the five-tuple feature and TCP sequence number of the third message, and add the third message to the second queue of the processing thread; Sort the multiple messages in the second queue based on the TCP sequence number of the third message to determine a first sorting number; When the processing thread finishes processing the third message, adding the identifier of the third message to the global packet sending queue; Reassembly processing is performed on multiple messages in the global packet sending queue.
5. The method according to claim 4, characterized in that The reassembling of the multiple messages in the global packet sending queue comprises: Sequentially taking out the third message from the global packet sending queue; Selecting a red-black tree corresponding to the message flow based on the five-tuple feature of the third message, using the TCP sequence number of the third message as a key, and adding the descriptor of the third message to the red-black tree; When the TCP sequence number of the smallest node in the red-black tree is the same as the first sequence number, the message corresponding to the smallest node is taken out from the second queue to the corresponding packet sending port.
6. The method according to claim 1, characterized in that The method further comprises: A first timer is set, and useless entries in the hash table are cleared according to the first timer.
7. A message flow processing device, characterized in that: The device comprises: An acquisition module is used to acquire a target prediction model, where the target prediction model is obtained by training an initial prediction model using training data; A prediction module, used to predict a plurality of first messages using the target prediction model, and determine whether a first message flow corresponding to the plurality of first messages is an elephant flow, wherein the plurality of first messages are obtained after sampling and screening the first message flow; A determination module, used to determine the first message flow whose prediction result is an elephant flow as a second message flow, and add a second message obtained after sampling and screening the second message flow into a hash table; A processing module is used to break up and reassemble the current message when the current message in the first message flow matches the message in the hash table.
8. An electronic device, characterized in that: include: one or more processors; A storage device communicatively connected to the one or more processors, on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 after being executed.
