Message shunting method, device, equipment and medium
By finding the queue number corresponding to the LSB of the message and shunting it to the queue with the smallest load, the problem of uneven load between queues in the existing technology is solved, and more balanced load distribution and system performance improvement are achieved.
Patent Information
- Application Number
- CN202411455476.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-24
AI Technical Summary
Existing RSS packet shunt methods can easily lead to uneven load between queues, resulting in processing delays or packet loss, and waste of resources.
By searching for the queue number corresponding to the least significant bit LSB of the message, if it does not exist, the message will be diverted to the target receiving queue with the smallest current load, and the corresponding relationship will be updated; if it exists, the packet will be diverted according to the found queue number.
It achieves load balancing among queues, avoids processing delays and waste of resources, and improves system performance.
Smart Images

Figure CN119363668A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communications, and in particular to a message diversion method, device, equipment and medium. Background Art
[0002] RSS (Received Side Scaling) is a network message processing technology that aims to distribute received messages to multiple processor cores so that all messages in the same message stream are processed by one processor core, avoiding unnecessary resource sharing and synchronization overhead and improving system processing performance.
[0003] The RSS method usually implements message distribution based on a hashing method. When a message is received from a network card, a hash operation is first performed on the fields extracted from the message, and then the number of queues (one receiving queue for each processor core) is modulo the LSB (Least Significant Bits) of the calculated hash value, and then the message is assigned to the corresponding receiving queue based on the queue number corresponding to the remainder, so that messages with similar characteristics are assigned to the same processor core.
[0004] Currently, due to the limitation of the number of processor cores and network card resources, the system can only support a limited number of receiving queues. Due to the uneven distribution of network traffic and the characteristics of hash functions, the message distribution method that uses a hash algorithm to calculate the hash value and takes the remainder of the number of queues may lead to uneven loads between queues. Specifically, when network traffic is unevenly distributed, some queues may receive a large number of messages, and the corresponding processor core may be overloaded due to carrying too many data packets, resulting in processing delays or even packet loss, while other queues may be lightly loaded, resulting in a waste of processing resources, which in turn affects the overall performance of the system. Summary of the invention
[0005] In response to the above problems, the present application provides a message diversion method, device, equipment and medium, which are used to solve the problem that the existing RSS message diversion method easily leads to uneven load between queues.
[0006] In a first aspect, the present application provides a message diversion method, the method comprising:
[0007] For a received message, after processing the message to obtain the least significant bit LSB, searching whether there is a queue number corresponding to the LSB in the corresponding relationship;
[0008] If there is no queue number corresponding to the LSB, the message is diverted to a target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load;
[0009] If there is a queue number corresponding to the LSB, the message is diverted to the corresponding receiving queue according to the found queue number.
[0010] In a possible implementation manner, the target receiving queue is determined in the following manner:
[0011] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0012] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0013] In a possible implementation manner, determining the accumulated number of messages in each receiving queue in the current diversion period includes:
[0014] Determine the cumulative number of messages in each receiving queue by querying the first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in the current diversion period;
[0015] After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the method further includes:
[0016] Based on the diversion result of the message, the first relationship table is updated.
[0017] In a possible implementation manner, the step of shunting the message to a target receiving queue includes:
[0018] A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number;
[0019] Calculate the difference between the first queue number and the queue number of the target receiving queue, and calculate the sum of the difference and the number of the receiving queues, and perform a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value;
[0020] Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number;
[0021] The message is diverted to the receiving queue corresponding to the second queue number.
[0022] In a possible implementation manner, if there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load, the method further includes:
[0023] Selecting a receiving queue from the multiple receiving queues with the same and smallest loads based on a preset rule;
[0024] The message is diverted to the selected receiving queue.
[0025] In a second aspect, the present application provides a message splitting device, the device comprising:
[0026] A relationship search module is used for processing a received message to obtain the least significant bit (LSB), and then searching for a queue number corresponding to the LSB in the corresponding relationship;
[0027] A first shunting module is used for shunting the message to a target receiving queue if there is no queue number corresponding to the LSB, and adding the LSB and the queue number of the target receiving queue to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load;
[0028] The second diversion module is used to divert the message to the corresponding receiving queue according to the found queue number if there is a queue number corresponding to the LSB.
[0029] In a possible implementation manner, the first traffic distribution module determines the target receiving queue in the following manner:
[0030] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0031] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0032] In a possible implementation manner, the first flow distribution module is specifically used to:
[0033] Determine the cumulative number of messages in each receiving queue by querying the first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in the current diversion period;
[0034] After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the method further includes:
[0035] Based on the diversion result of the message, the first relationship table is updated.
[0036] In a possible implementation manner, the first flow distribution module is specifically used to:
[0037] A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number;
[0038] Calculate the difference between the first queue number and the queue number of the target receiving queue, and calculate the sum of the difference and the number of the receiving queues, and perform a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value;
[0039] Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number;
[0040] The message is diverted to the receiving queue corresponding to the second queue number.
[0041] In one possible embodiment, the device also includes a queue screening module, which is used to select a receiving queue from the multiple receiving queues with the same and smallest load based on preset rules if there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load; and divert the message to the selected receiving queue.
[0042] In a third aspect, the present application provides an electronic device, including:
[0043] A memory for storing program instructions;
[0044] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.
[0045] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.
[0046] The beneficial effects of this application are as follows:
[0047] In an embodiment of the present application, a query is made to see whether there is a queue number corresponding to the LSB parsed from the received message in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the found queue number. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced. At the same time, by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0048] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings introduced below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 A schematic diagram of a message diversion method flow provided in an embodiment of the present application;
[0051] Figure 2 A schematic diagram of a method for determining a target receiving queue based on a first relationship table provided in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of the overall flow of message diversion provided in an embodiment of the present application;
[0053] Figure 4 A schematic diagram of a message diversion example provided in an embodiment of the present application;
[0054] Figure 5 A schematic diagram of a message diversion device provided in an embodiment of the present application;
[0055] Figure 6 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0057] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0058] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0059] Before introducing the message diversion method provided in the embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.
[0060] RSS (Received Side Scaling) is a network message processing technology that aims to distribute received messages to multiple processor cores so that all messages in the same message stream are processed by one processor core, avoiding unnecessary resource sharing and synchronization overhead and improving system processing performance.
[0061] The RSS method usually implements message distribution based on a hashing method. When a message is received from a network card, a hash operation is first performed on the fields extracted from the message, and then the number of queues (one receiving queue for each processor core) is modulo the LSB (Least Significant Bits) of the calculated hash value, and then the message is assigned to the corresponding receiving queue based on the queue number corresponding to the remainder, so that messages with similar characteristics are assigned to the same processor core.
[0062] Currently, due to the limitation of the number of processor cores and network card resources, the system can only support a limited number of receiving queues. Due to the uneven distribution of network traffic and the characteristics of hash functions, the message distribution method that uses a hash algorithm to calculate the hash value and takes the remainder of the number of queues may lead to uneven loads between queues. Specifically, when network traffic is unevenly distributed, some queues may receive a large number of messages, and the corresponding processor core may be overloaded due to carrying too many data packets, resulting in processing delays or even packet loss, while other queues may be lightly loaded, resulting in a waste of processing resources, which in turn affects the overall performance of the system.
[0063] In view of this, in order to solve the problem that the existing RSS message diversion method is prone to cause uneven load between queues, the embodiments of the present application provide a message diversion method, device, equipment and medium.
[0064] Embodiment 1:
[0065] Figure 1 A flow chart of a message diversion method provided in some embodiments of the present application is as follows: Figure 1 As shown, the process includes the following steps:
[0066] S101: For a received message, after processing the message to obtain the least significant bit LSB, find out whether there is a queue number corresponding to the LSB in the corresponding relationship.
[0067] In the embodiment of the present application, after receiving a message, the message header characteristic information of the message is extracted and a hash operation is performed on the extracted message header characteristic information, and then the set number of bits of the obtained hash value is extracted to obtain the LSB. Among them, the message header characteristic information is usually data that can identify the message flow to which the message belongs.
[0068] Optionally, the above-mentioned message header characteristic information is a field extracted from the message header. For example, the message header characteristic information may be a four-tuple consisting of a source IP address, a destination IP address, a source port number and a destination port number extracted from a message header field.
[0069] In some embodiments, the types of the above-mentioned messages include messages based on TCP (Transmission Control Protocol) and messages based on UDP (User Datagram Protocol).
[0070] In S101, for the received message, after extracting the message header feature information, the message header feature information is used as input, a hash value is generated through a hash function, and a set number of binary bits is extracted from the rightmost bit of the generated hash value as the LSB, where the value of the set number of bits depends on the number of receiving queues.
[0071] For example, the number of receiving queues is 4, and the receiving queues are 0th, 1st, 2nd and 3rd respectively. Since the binary number corresponding to 4 is "100", the set number of bits needs to be greater than or equal to 3. For the specific principle of setting the value of the number of bits, please refer to the existing RSS technology, which will not be repeated here.
[0072] In an embodiment of the present application, after receiving a message, unlike the existing RSS diversion technology, after calculating the LSB, the message is directly diverted based on the result of the modulo operation on the number of receiving queues based on the LSB; instead, the queue number corresponding to the LSB is searched in the correspondence stored in the system (the correspondence includes the correspondence between all LSBs and queue numbers previously parsed). If the queue number corresponding to the LSB is found, it indicates that a message sent by the message flow to which the message belongs has been received before. If the LSB and the queue number corresponding to the LSB are not found, it means that this is the first time that a message sent by the message flow to which the message belongs has been received. At this time, the receiving queue determined based on the existing RSS diversion technology is not necessarily the receiving queue with the smallest current load. Diversion according to the RSS diversion technology may cause processing delays or packet loss problems due to overload of some receiving queues.
[0073] S102: If there is no queue number corresponding to the LSB, the message is diverted to a target receiving queue, and the LSB and the queue number of the target receiving queue are added to a corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load.
[0074] S103: If there is a queue number corresponding to the LSB, the message is diverted to the corresponding receiving queue according to the found queue number.
[0075] In some embodiments, the target receiving queue is determined in the following manner:
[0076] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0077] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0078] As a feasible implementation method, determining the cumulative number of messages in each receiving queue in the current diversion period includes:
[0079] By querying the first relationship table, the accumulated number of messages in each receiving queue is determined.
[0080] The first relation table is used to store the cumulative number of messages in each receiving queue in the current diversion cycle, such as Figure 2 As shown, it is a schematic diagram of a method for determining a target receiving queue based on a first relationship table provided in an embodiment of the present application, Q1, Q2, Q3…Qn respectively represent the current n receiving queues, num1, num2, num3…num n respectively represent the cumulative number of messages corresponding to the current n receiving queues, Qi is a function defined in the present application, and is used to take the receiving queue corresponding to the minimum value among num1, num2, num3…num n as the target receiving queue.
[0081] In one or more embodiments, if it is determined in step S102 that there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load, the method further includes: selecting a receiving queue from the multiple receiving queues with the same and smallest load based on a preset rule; and diverting the message to the selected receiving queue. Exemplarily, the preset rule may be to select the receiving queue with the smallest queue index, or to select these receiving queues in turn according to a preset order.
[0082] In the present application, in each diversion cycle, the cumulative number of messages of each receiving queue is counted based on the cumulative number of messages diverted to each receiving queue. The cumulative number of messages corresponding to each receiving queue can represent the size of the corresponding queue load.
[0083] Optionally, the size of the above diversion cycle depends on the actual scenario and user needs. For example, for a high concurrency scenario, a large number of messages need to be diverted per second. The diversion cycle can be adaptively set to be very small to avoid excessive accumulation of data and increase the computing burden.
[0084] It should be noted that the storage method of the first relationship table of the present application can be set based on actual scenarios and requirements, such as a global hash table, array, or other data structure that can be used to store the cumulative number of messages in each receiving queue. The present application does not limit this.
[0085] It should be noted that the target receiving queue can also be determined based on the cumulative number of messages diverted to each receiving queue and the size of the message packets, and the receiving queue with the least cumulative number of messages and the smallest amount of data corresponding to the message packets can be determined as the target receiving queue. However, compared with determining the receiving queue with the least cumulative number of messages as the target receiving queue, this will increase the computing resources required and slow down the diversion speed to a certain extent. Therefore, the method of determining the receiving queue with the smallest current load can be selected according to the actual application scenario.
[0086] In one or more embodiments, it is necessary to synchronously update the cumulative number of messages in each receiving queue after each diversion is performed. Specifically, after the message is diverted to the target receiving queue in step S102, or after the message is diverted to the corresponding receiving queue according to the found queue number in step S103, the above method also includes: updating the first relationship table based on the diversion result of the message.
[0087] As a feasible implementation manner, the message is diverted to the target receiving queue, including the following steps S102a-S102d:
[0088] S102a, performing a modulo operation on the number of receiving queues based on the LSB to obtain a first queue number.
[0089] Specifically, the first queue number r is calculated by the formula LSB%n=r, where n is the number of receiving queues.
[0090] S102b, calculating the difference between the first queue number and the queue number of the target receiving queue, and calculating the sum of the difference and the number of receiving queues, and performing a modulo operation on the number of receiving queues based on the sum to obtain a queue offset value.
[0091] Specifically, the offset value offset is calculated by the formula (i-r+n)%n=offset, where i is the queue number of the target receiving queue.
[0092] S102c, obtaining a second queue number based on a result of performing a modulo operation on the number n of receiving queues based on the sum of the queue offset value and the first queue number.
[0093] Specifically, the second queue number r1 is calculated by the formula (r+offset)%n=r1.
[0094] S102d, divert the message to the receiving queue corresponding to the second queue number.
[0095] It can be seen that based on the above steps S102a-S102d, a specific implementation method for allocating messages to the queue with the smallest load is given. On the basis of the first queue number r calculated by the existing RSS, the offset value is calculated, and the second queue number r1 is obtained based on the calculated offset value. The second queue number r1 is the queue number corresponding to the target receiving queue. Therefore, based on the above steps S102a-S102d, it can be ensured that the messages of the received new message flow are accurately allocated to the queue with the smallest current load, avoiding the problem of queue load imbalance that may be caused by the existing RSS message diversion method directly allocating messages to the queue corresponding to the queue number obtained based on the hash operation and the modulo operation.
[0096] For the above steps S102a-S102d, if Figure 3 The present application stores all historical LSBs obtained through historical analysis and the queue numbers corresponding to the historical LSBs obtained based on step S102 in the second relationship table, and updates the second relationship table each time a new correspondence between the LSBs and the queue numbers is obtained.
[0097] It should be noted that the data structure of the first relationship table used to store the correspondence between LSB and queue number can be set based on actual scenarios and requirements, such as using a global hash table, mapping table or dictionary to store the correspondence between LSB and queue number, or other data structures that can be used to store the correspondence between LSB and queue number. This application does not limit this.
[0098] refer to Figure 3 After receiving the message, the present application extracts a four-tuple from the message header field, then performs a hash calculation on the four-tuple through a hash function, and extracts the value of the set number of bits from the calculated hash value to obtain the LSB; the next step is to determine whether there is a queue number corresponding to the LSB in the second relationship table. If there is a queue number, the message is directly diverted to the corresponding receiving queue according to the found queue number, and then the corresponding processor core CPU performs message processing; if it does not exist, the queue offset value is calculated based on the above steps S102a-S102d to determine the queue number corresponding to the LSB and update the corresponding relationship, and then the message is diverted to the corresponding receiving queue according to the determined queue number corresponding to the LSB, and then the corresponding processor core CPU performs message processing.
[0099] In order to better illustrate the technical solution of the present application, a specific example of applying the technical solution in the aforementioned embodiment of the present application is given below.
[0100] like Figure 4 As shown in FIG. 1 , a schematic diagram of a message diversion example provided in an embodiment of the present application is provided. Figure 4 , assuming n=4, the number of queues is 4 (including Q0, Q1, Q2 and Q3), then perform the following steps for the obtained message:
[0101] (1) Parse the four-tuple 192.168.1.10|12345|192.168.1.20|80 from the message.
[0102] (2) Generate a hash value h=10101100101011000011110010101100 through a hash function.
[0103] (3) LSB is 10 bits and we get 0010101100.
[0104] (4-1) If the LSB does not exist in the second relationship table: LSB modulo the number of queues 4 is r=0, that is, the first queue number is Q0. Assuming that the first relationship table is checked to determine that the target receiving queue (the receiving queue with the smallest current load) is Q3, and the corresponding queue number is 3, then the offset value offset=(3-0+4)%4=3 is calculated by the formula (i-r+n)%n=offset, and then the second queue number r1=(0+3)%4=3 is calculated by the formula (r+offset)%n=r1. In this case, the message should be assigned to the receiving queue Q3, and the second relationship table is updated accordingly based on the correspondence between the LSB and Q3.
[0105] (4-2) If the LSB is present in the second relational table:
[0106] If the LSB exists in the second relationship table, it means that a message belonging to the same message flow as the message has been diverted before. By checking the second relationship table, the queue number corresponding to the LSB is 3, so the message should be allocated to the receiving queue Q3.
[0107] The message diversion method of the present application is suitable for network environments or application scenarios that perform message diversion based on RSS technology, such as high-concurrency network environments or data centers that need to distribute a large number of network messages at the same time. In an embodiment of the present application, a queue number corresponding to the LSB parsed from the received message is searched in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the queue number found. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced, and by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0108] Embodiment 2:
[0109] Based on the same technical concept, on the basis of the above embodiments, in an embodiment of the present application, a message diversion device is provided. Figure 5 A schematic diagram of the structure of a message diversion device provided in an embodiment of the present application. Figure 5 As shown, the device comprises:
[0110] The relationship search module 501 is used for processing the received message to obtain the least significant bit LSB, and then searching whether there is a queue number corresponding to the LSB in the corresponding relationship;
[0111] A first shunting module 502 is configured to shunt the message to a target receiving queue if there is no queue number corresponding to the LSB, and add the LSB and the queue number of the target receiving queue to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load;
[0112] The second diversion module 503 is configured to divert the message to a corresponding receiving queue according to the found queue number if there is a queue number corresponding to the LSB.
[0113] In a possible implementation manner, the first traffic distribution module 502 determines the target receiving queue in the following manner:
[0114] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0115] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0116] In a possible implementation manner, the first flow distribution module 502 is specifically configured to:
[0117] Determine the cumulative number of messages in each receiving queue by querying the first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in the current diversion period;
[0118] After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the first relationship table is updated based on the diversion result of the message.
[0119] In a possible implementation manner, the first flow distribution module 502 is specifically configured to:
[0120] A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number;
[0121] Calculating a difference between the first queue number and the queue number of the target receiving queue, and calculating a sum of the difference and the number of the receiving queues, and performing a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value;
[0122] Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number;
[0123] The message is diverted to the receiving queue corresponding to the second queue number.
[0124] In one possible embodiment, the device also includes a queue screening module, which is used to select a receiving queue from the multiple receiving queues with the same and smallest load based on preset rules if there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load; and divert the message to the selected receiving queue.
[0125] In an embodiment of the present application, a query is made to see whether there is a queue number corresponding to the LSB parsed from the received message in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the found queue number. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced. At the same time, by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0126] Embodiment 3:
[0127] Based on the same technical concept, on the basis of the above embodiments, in the embodiment of the present application, an electronic device 600 is further provided, such as Figure 6 As shown, it includes at least one processor 602; and a memory 601 that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the following steps:
[0128] For a received message, after processing the message to obtain the least significant bit LSB, searching whether there is a queue number corresponding to the LSB in the corresponding relationship;
[0129] If there is no queue number corresponding to the LSB, the message is diverted to a target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load;
[0130] If there is a queue number corresponding to the LSB, the message is diverted to the corresponding receiving queue according to the found queue number.
[0131] In a possible implementation manner, the processor 602 is further configured to:
[0132] The target receiving queue is determined in the following manner:
[0133] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0134] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0135] In a possible implementation, the processor 602 is further configured to: determine the cumulative number of messages in each receiving queue by querying a first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in a current diversion period;
[0136] After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the method further includes:
[0137] Based on the diversion result of the message, the first relationship table is updated.
[0138] In a possible implementation manner, the processor 602 is further configured to:
[0139] A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number;
[0140] Calculate the difference between the first queue number and the queue number of the target receiving queue, and calculate the sum of the difference and the number of the receiving queues, and perform a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value;
[0141] Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number;
[0142] The message is diverted to the receiving queue corresponding to the second queue number.
[0143] In a possible implementation manner, the processor 602 is further configured to:
[0144] If there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load, select a receiving queue from the multiple receiving queues with the same and smallest load based on a preset rule; and divert the message to the selected receiving queue.
[0145] The memory 601 is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory 601 may be a volatile memory, such as a random-access memory (RAM); or a non-volatile memory, such as a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or a combination of any one or more of the above volatile memories and non-volatile memories.
[0146] The processor 602 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP. It may also be a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0147] In an embodiment of the present application, a query is made to see whether there is a queue number corresponding to the LSB parsed from the received message in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the found queue number. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced. At the same time, by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0148] Embodiment 4:
[0149] Based on the same technical concept, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the following steps:
[0150] For a received message, after processing the message to obtain the least significant bit LSB, searching whether there is a queue number corresponding to the LSB in the corresponding relationship;
[0151] If there is no queue number corresponding to the LSB, the message is diverted to a target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load;
[0152] If there is a queue number corresponding to the LSB, the message is diverted to the corresponding receiving queue according to the found queue number.
[0153] In a possible implementation manner, the target receiving queue is determined in the following manner:
[0154] Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period;
[0155] The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
[0156] In a possible implementation manner, determining the accumulated number of messages in each receiving queue in the current diversion period includes:
[0157] Determine the cumulative number of messages in each receiving queue by querying the first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in the current diversion period;
[0158] After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the method further includes:
[0159] Based on the diversion result of the message, the first relationship table is updated.
[0160] In a possible implementation manner, the step of shunting the message to a target receiving queue includes:
[0161] A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number;
[0162] Calculating a difference between the first queue number and the queue number of the target receiving queue, and calculating a sum of the difference and the number of the receiving queues, and performing a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value;
[0163] Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number;
[0164] The message is diverted to the receiving queue corresponding to the second queue number.
[0165] In a possible implementation manner, if there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load, the method further includes:
[0166] Selecting a receiving queue from the multiple receiving queues with the same and smallest loads based on a preset rule;
[0167] The message is diverted to the selected receiving queue.
[0168] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.
[0169] In an embodiment of the present application, a query is made to see whether there is a queue number corresponding to the LSB parsed from the received message in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the found queue number. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced. At the same time, by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0170] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the message diversion methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the message diversion method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0171] In an embodiment of the present application, a query is made to see whether there is a queue number corresponding to the LSB parsed from the received message in the corresponding relationship; if not, the message is diverted to the target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; if yes, the message is diverted to the corresponding receiving queue according to the found queue number. The present application improves the existing RSS diversion method by allocating new messages to the queue with the smallest current real-time load, rather than using the queue number obtained by taking the modulus of the number of queues using the LSB, so that the load between queues is balanced. At the same time, by storing the corresponding relationship between the LSB and the queue number, the message of the same message flow can be quickly diverted when it arrives in the future, thereby improving the diversion efficiency.
[0172] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0173] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0174] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0175] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated module can 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 can be stored in a computer-readable storage medium.
[0176] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0177] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
[0178] The technical solution provided by the present application is introduced in detail above. The principles and implementation methods of the present application are explained by using specific examples in the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0179] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0180] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0183] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A message diversion method, characterized in that: include: For a received message, after processing the message to obtain the least significant bit LSB, searching whether there is a queue number corresponding to the LSB in the corresponding relationship; If there is no queue number corresponding to the LSB, the message is diverted to a target receiving queue, and the LSB and the queue number of the target receiving queue are added to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; If there is a queue number corresponding to the LSB, the message is diverted to the corresponding receiving queue according to the found queue number.
2. The method according to claim 1, characterized in that The target receiving queue is determined in the following manner: Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period; The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
3. The method according to claim 2, characterized in that The step of determining the accumulated number of messages in each receiving queue in the current diversion period includes: Determine the cumulative number of messages in each receiving queue by querying the first relationship table, wherein the first relationship table is used to store the cumulative number of messages in each receiving queue in the current diversion period; After the message is diverted to the target receiving queue, or after the message is diverted to the corresponding receiving queue according to the found queue number, the method further includes: Based on the diversion result of the message, the first relationship table is updated.
4. The method according to claim 1, characterized in that The step of shunting the message to a target receiving queue includes: A result of performing a modulo operation on the number of receiving queues based on the LSB is used to obtain a first queue number; Calculate the difference between the first queue number and the queue number of the target receiving queue, and calculate the sum of the difference and the number of the receiving queues, and perform a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value; Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number; The message is diverted to the receiving queue corresponding to the second queue number.
5. The method according to claim 1, characterized in that If there is no queue number corresponding to the LSB and there are currently multiple receiving queues with the same and smallest load, the method further includes: Selecting a receiving queue from the multiple receiving queues with the same and smallest loads based on a preset rule; The message is diverted to the selected receiving queue.
6. A message diversion device, characterized in that: include: A relationship search module is used for processing a received message to obtain the least significant bit (LSB), and then searching for a queue number corresponding to the LSB in the corresponding relationship; A first shunting module is used for shunting the message to a target receiving queue if there is no queue number corresponding to the LSB, and adding the LSB and the queue number of the target receiving queue to the corresponding relationship, wherein the target receiving queue is the receiving queue with the smallest current load; The second diversion module is used to divert the message to the corresponding receiving queue according to the found queue number if there is a queue number corresponding to the LSB.
7. The device according to claim 6, characterized in that The first traffic distribution module determines the target receiving queue in the following manner: Determine the cumulative number of messages of each receiving queue in the current diversion period, wherein the cumulative number of messages of a receiving queue is the cumulative number of messages diverted to the receiving queue in the current diversion period; The receiving queue with the least number of accumulated messages is determined as the target receiving queue.
8. The device according to claim 6, characterized in that The first traffic distribution module obtains a first queue number by performing a modulo operation on the number of receiving queues based on the LSB; Calculate the difference between the first queue number and the queue number of the target receiving queue, and calculate the sum of the difference and the number of the receiving queues, and perform a modulo operation on the number of the receiving queues based on the sum to obtain a queue offset value; Obtain a second queue number based on a result of performing a modulo operation on the number n of the receiving queues based on the sum of the queue offset value and the first queue number; The message is diverted to the receiving queue corresponding to the second queue number.
9. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of claims 1-5 according to the obtained program instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 5.
Citation Information
Cited By
5G data distribution method realized by using domestic FPGA (Field Programmable Gate Array) chip
CN119690681A