Self-adaptive message processing method and device, medium and equipment
By using genetic algorithms to adjust the token bucket parameters in the message queue system, the problem that traditional systems are difficult to efficiently handle large-scale message flows when facing complex network environments and load fluctuations is solved, and the system is self-optimized and efficiently operated, improving stability and response capabilities.
Patent Information
- Application Number
- CN202411671343.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional message queue systems are difficult to cope with complex and changeable network environments and load fluctuations, and cannot effectively handle large-scale and high-frequency message flows, resulting in system stability being affected.
Genetic algorithms are used to periodically adjust the token bucket parameters, including the token generation rate and token bucket capacity, to adaptively adjust the message processing rate. The message processing process is controlled through the token bucket mechanism to ensure that the system can self-optimize and operate efficiently in scenarios of high concurrency and dynamic load changes.
Significantly improves the response time and throughput of message processing, ensuring that the system operates at optimal conditions at any given point in time, avoiding overload and resource idleness, and improving overall stability and reliability.
Smart Images

Figure CN119629126A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of message processing, and in particular to an adaptive message processing method, device, medium and equipment. Background Art
[0002] With the rapid development of cloud computing and big data, message processing in distributed systems faces unprecedented challenges, especially how to efficiently process large-scale, high-frequency message flows while ensuring system stability. Traditional message queue systems often use static configuration or simple dynamic adjustment strategies, which are difficult to cope with complex and changing network environments and load fluctuations. Therefore, a solution that can adaptively adjust and intelligently optimize is urgently needed. Summary of the invention
[0003] In view of at least one of the above technical problems, an embodiment of the present invention provides an adaptive message processing method, device, medium, and equipment.
[0004] According to a first aspect, an adaptive message processing method provided by an embodiment of the present invention includes:
[0005] Allocate a token bucket for the message queue;
[0006] Regularly using a genetic algorithm to determine token bucket parameters according to changes in network performance, the token bucket parameters including a token generation rate and a token bucket capacity;
[0007] Generate tokens according to the token bucket generation rate, and fill each generated token into the token bucket, and limit the number of tokens in the token bucket to be less than or equal to the token bucket capacity;
[0008] Before processing each message in the message queue, taking a token from the token bucket;
[0009] If the token is successfully retrieved, the message will be processed.
[0010] In one embodiment, the method further comprises:
[0011] If the token is not successfully taken out, wait until the token can be successfully taken out from the token bucket, and then process the message.
[0012] In one embodiment, the periodic use of a genetic algorithm to determine token bucket parameters according to changes in network performance includes:
[0013] S1. Setting an initial population; wherein the population includes a plurality of individuals, each of which represents a set of token bucket parameters;
[0014] S2. Calculate the fitness value of each individual in the population according to the fitness function, and select the individual with the highest fitness from the population as the current optimal solution; wherein the fitness function is constructed according to a network performance indicator that can reflect the impact of the token generation rate and the token bucket capacity;
[0015] S3, update the current population;
[0016] S4, according to the fitness function, calculate the fitness value of each individual in the current population, select the individual with the highest fitness from the current population, and determine whether the fitness value of the individual with the highest fitness is higher than the fitness value of the current optimal solution; if so, take the individual with the highest fitness as the current optimal solution, otherwise, keep the current optimal solution unchanged;
[0017] S5, determining whether a preset termination condition is met;
[0018] S6. If yes, output the current optimal solution;
[0019] S7. Otherwise, increase the number of iterations by 1 and return to S3.
[0020] In one embodiment, updating the current population includes:
[0021] A non-replay excellent individual multi-copy selection strategy is used to select multiple individuals from the current population;
[0022] The intergenerational subspace optimization gene cluster strategy is used to optimize the genes of the current population, and the optimized individuals are cross-processed;
[0023] The selected individuals and the individuals after the crossover process form a population, and the individuals in the population are mutated.
[0024] In one embodiment, the process of updating the current population using the non-playback excellent individual multi-copy selection strategy includes:
[0025] According to the roulette wheel selection algorithm, n individuals are taken from the current population without replacement;
[0026] Calculate the fitness value of each of the n individuals, and sort the n individuals in descending order of fitness value;
[0027] Select the first n / 3 individuals and make two copies, and make one copy of the middle n / 3 individuals. The three copies of n / 3 individuals are used as the selected individuals.
[0028] In one embodiment, the method of using the intergenerational subspace optimization gene cluster strategy to perform gene optimization on the current population and performing crossover processing on the optimized individuals includes:
[0029] The entire parameter space is divided into u subspaces, each of which represents a gene cluster; wherein the parameter space includes all possible values of the token bucket parameter; u is an integer greater than 1;
[0030] Cluster the token bucket parameters corresponding to each individual in the current population into u gene clusters, so that each individual is divided into u subspaces;
[0031] Sort the individuals in the current population in descending order of fitness value, and select the top r individuals from the sorted individuals; where r is an integer greater than 1;
[0032] Assigning corresponding weights to the r individuals, and the individuals with higher fitness values are assigned larger weights;
[0033] Multiplying the average fitness of the gene cluster to which each of the r individuals belongs by the weight of the individual to obtain r products;
[0034] Based on r products, select w individuals with the largest product; where w is an integer greater than 1 and less than r;
[0035] Perform crossover processing on the w individuals to obtain individuals after crossover processing.
[0036] In one embodiment, the fitness function is a modified fitness function based on the initial fitness function, and the modified fitness function is:
[0037]
[0038] Among them, F is the modified fitness function, f is the initial fitness function, and f min is the minimum fitness value in the current population, f max is the maximum fitness value in the current population, a is a constant that ensures that the denominator is not 0, and a is greater than 0.
[0039] According to a second aspect, an adaptive message processing device provided by an embodiment of the present invention includes:
[0040] A token bucket allocation module is used to allocate a token bucket to a message queue;
[0041] A parameter determination module, used to periodically use a genetic algorithm to determine token bucket parameters according to changes in network performance, wherein the token bucket parameters include a token generation rate and a token bucket capacity;
[0042] A token filling module, used for generating tokens according to the token bucket generation rate, and filling each token generated into the token bucket, and limiting the number of tokens in the token bucket to be less than or equal to the token bucket capacity;
[0043] A token acquisition module, used for taking a token from the token bucket before processing each message in the message queue;
[0044] The message processing module is used to process the message if the token is successfully retrieved.
[0045] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method provided in the first aspect.
[0046] According to a fourth aspect, an embodiment of the present invention provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method provided in the first aspect is implemented.
[0047] The adaptive message processing method, device, medium, and equipment provided by the embodiment of the present invention use a genetic algorithm to determine the token generation rate and the token bucket capacity, generate tokens according to the token generation rate, and then fill the tokens into the token bucket, and limit the number of tokens in the token bucket to be less than or equal to the token bucket capacity. Before a message in the message queue needs to be processed, a token is taken out from the token bucket to process the message. When the system's message processing capacity reaches the upper limit, it is in the case of high concurrency and excessive dynamic load. At this time, the token generation rate can be reduced to delay the processing of new messages to prevent continued overload. On the contrary, when the system has sufficient capacity to process messages, the token generation rate is increased to make full use of resources. This dynamic flow control mechanism significantly improves the response time and throughput of message processing. It can be seen that the embodiment of the present invention combines the genetic algorithm and the token bucket algorithm to control the message processing rate, which can improve the network performance and thus improve the system stability while increasing the message processing rate as much as possible, especially in the face of high concurrency and dynamic load changes. The scene, through intelligent adjustment of resource allocation and flow control, realizes the self-optimization and efficient operation of the system message processing. That is, the embodiment of the present invention realizes intelligent dynamic adjustment of message processing capability and smooth flow control by integrating genetic algorithm and token bucket algorithm, thereby solving the problems of inflexible resource allocation and single flow control strategy in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of a flow chart of an adaptive message processing method in one embodiment of the present invention;
[0049] Figure 2 It is a structural block diagram of an adaptive message processing device in one embodiment of the present invention. DETAILED DESCRIPTION
[0050] In a first aspect, an embodiment of the present invention provides an adaptive message processing method, see Figure 1 The method comprises the following steps S110 to S150:
[0051] S110, allocating a token bucket for the message queue;
[0052] That is, each message queue is allocated a token bucket for speed control of message processing in the message queue.
[0053] S120, regularly using a genetic algorithm to determine token bucket parameters according to changes in network performance, wherein the token bucket parameters include a token generation rate and a token bucket capacity;
[0054] Among them, the genetic algorithm, abbreviated as GA, is a method of searching for the optimal solution by imitating the natural evolution process. Its main features are that it operates directly on structural objects, does not have the limitation of derivative and function continuity, can automatically obtain and guide the optimized search space without definite rules, and adjusts the search direction adaptively.
[0055] The token generation rate refers to the number of tokens generated per second.
[0056] The token bucket capacity refers to the upper limit of the number of tokens that can be placed in the token bucket.
[0057] It is understandable that the token generation rate can be used to control the rate of token generation. The token bucket capacity is obtained based on resource allocation. The larger the token bucket capacity, the more resources need to be allocated.
[0058] In S120, the genetic algorithm determines the token bucket parameters according to the network performance change. The network performance change can be reflected by the network performance indicators. Among them, the network performance indicators include, for example, network delay, network rate, throughput, packet loss rate, etc. Through the network performance change, it can be known whether it is currently in a high concurrency and dynamic load is too large, that is, the network stability can be known.
[0059] Specifically, when the system reaches the upper limit of its message processing capacity, it is in a high concurrency and dynamic overload situation. At this time, the token generation rate can be reduced to delay the processing of new messages and prevent further overload. On the contrary, when the system has sufficient message processing capacity, the token generation rate is increased to make full use of resources. This dynamic flow control mechanism significantly improves the response time and throughput of message processing.
[0060] S130, generating tokens according to the token bucket generation rate, and filling each generated token into the token bucket, and limiting the number of tokens in the token bucket to be less than or equal to the token bucket capacity;
[0061] Each time a token is generated, it is placed in the token bucket. It can be seen that the token generation rate and the token filling rate are the same.
[0062] S140, before processing each message in the message queue, taking a token from the token bucket;
[0063] S150: If the token is successfully retrieved, the message is processed.
[0064] It can be seen that tokens are generated at a certain rate, and then filled into the token bucket. Before a message in the message queue needs to be processed, a token must be taken out of the token bucket to process the message. If a token cannot be taken out, the message cannot be processed. It can be seen that in this way, the message processing rate of the message queue is effectively controlled.
[0065] In the embodiment of the present invention, a genetic algorithm and a token bucket algorithm are combined to control the message processing rate, which can improve the network performance and thus improve the system stability while increasing the message processing rate as much as possible. In particular, in the face of high concurrency and dynamic load change scenarios, the system can achieve self-optimization and efficient operation of message processing by intelligently adjusting resource allocation and flow control. That is, the embodiment of the present invention realizes intelligent dynamic adjustment of message processing capacity and flow smoothing control by integrating the genetic algorithm and the token bucket algorithm, solving the problems of inflexible resource allocation and single flow control strategy in the prior art.
[0066] Among them, the token bucket algorithm is a flow control and rate limiting technology widely used in computer networks and systems. Its original design intention is to solve the problem of network congestion and ensure smooth and fair data transmission. In computer networks, especially the Internet, data transmission may encounter congestion due to overload of network resources, resulting in data packet delay, loss and overall system performance degradation. In order to effectively manage network resources and improve the quality of service, namely QoS, it is necessary to implement a congestion control mechanism. The token bucket algorithm is one of the important congestion avoidance and traffic shaping technologies. The token bucket algorithm is not only used for congestion control, but also widely used in rate limiting scenarios, such as API calls, network transmission rate control, etc. It can help the system maintain a constant data transmission rate while allowing a certain degree of burst, that is, transmission that exceeds the average rate for a short period of time, but generally ensures that the transmission rate will not exceed the predetermined threshold for a long time.
[0067] In one embodiment, the method may further include:
[0068] If the token is not successfully taken out, wait until the token can be successfully taken out from the token bucket, and then process the message.
[0069] That is to say, when the token in the token bucket is empty, you need to wait. When a new token is generated and filled into the token bucket, you can take out the token and process the message.
[0070] In one embodiment, the periodic use of a genetic algorithm to determine token bucket parameters according to changes in network performance in S120 may include S1 to S7:
[0071] S1. Setting an initial population; wherein the population includes a plurality of individuals, each of which represents a set of token bucket parameters;
[0072] For example, there are 100 individuals in the initial population, and each individual represents a solution, that is, a possible value of the token bucket parameter. It can be seen that the embodiment of the present invention optimizes the token generation rate and the token bucket capacity as variables of the genetic algorithm.
[0073] Among them, each individual in the initial population can be randomly generated, that is, the token bucket parameter corresponding to each individual is randomly generated.
[0074] S2. Calculate the fitness value of each individual in the population according to the fitness function, and select the individual with the highest fitness from the population as the current optimal solution; wherein the fitness function is constructed according to a network performance indicator that can reflect the impact of the token generation rate and the token bucket capacity;
[0075] It is understandable that the fitness function can reflect the network performance. The higher the fitness value of an individual, the better the network performance of the individual, and the greater the possibility that the solution corresponding to the individual is the optimal solution. The network performance is affected by the token generation rate and the token bucket capacity. The higher the token generation rate, the faster the system can process messages. The larger the token bucket capacity, the more resources the system needs to allocate. The amount of allocated resources and the speed at which the system processes messages can affect network performance.
[0076] The fitness function is a modified fitness function based on the initial fitness function, and the modified fitness function can be:
[0077]
[0078] Among them, F is the modified fitness function, f is the initial fitness function, and f min is the minimum fitness value in the current population, fmax is the maximum fitness value in the current population, a is a constant that ensures that the denominator is not 0, and a is greater than 0.
[0079] S3, update the current population;
[0080] That is, each individual in the current population is updated to obtain an updated population.
[0081] S4, according to the fitness function, calculate the fitness value of each individual in the current population, select the individual with the highest fitness from the current population, and determine whether the fitness value of the individual with the highest fitness is higher than the fitness value of the current optimal solution; if so, take the individual with the highest fitness as the current optimal solution, otherwise, keep the current optimal solution unchanged;
[0082] That is to say, after the update, the best individual is selected, and then it is determined whether the best individual is better than the previously determined optimal solution, that is, the current optimal solution. If so, the current optimal solution is replaced, otherwise the current optimal solution remains unchanged.
[0083] S5, determining whether a preset termination condition is met;
[0084] For example, the upper limit of the number of iterations can be used as the termination condition. Of course, other termination conditions can also be set.
[0085] S6. If yes, output the current optimal solution;
[0086] S7. Otherwise, increase the number of iterations by 1 and return to S3.
[0087] It can be seen that, through multiple iterations of the above steps S1 to S7, a global optimal solution can be selected and the global optimal solution is output, thereby obtaining the token generation rate and token bucket capacity in the global optimal solution.
[0088] Furthermore, the updating of the current population in S3 may include A1 to A3:
[0089] A1. Use the non-replay excellent individual multi-copy selection strategy to select multiple individuals from the current population;
[0090] Specifically, the process of updating the current population by adopting the selection strategy of multiple copies of excellent individuals without playback in A1 may include A11 to A13:
[0091] A11. According to the roulette wheel selection algorithm, n individuals are taken from the current population without replacement;
[0092] A12, calculating the fitness value of each of the n individuals, and sorting the n individuals in descending order of fitness value;
[0093] A13. Select the first n / 3 individuals and make two copies, and make one copy of the middle n / 3 individuals. The three copies of n / 3 individuals are used as the selected individuals.
[0094] For example, set n to 60. Select 60 individuals from the current population, sort these 60 individuals in descending order of fitness value, select the top 20 individuals, copy these 20 individuals twice, and get 40 copy individuals. Copy the middle 20 individuals once, and get 20 copy individuals. Use these 60 copy individuals as the individuals selected from the current population.
[0095] It can be seen that in this way, multiple replications of excellent individuals can be achieved, and individuals with smaller fitness values in the population can be retained with a small probability.
[0096] A2. Use the intergenerational subspace optimization gene cluster strategy to optimize the genes of the current population, and perform crossover processing on the optimized individuals;
[0097] Specifically, the intergenerational subspace optimization gene cluster strategy described in A2 is used to optimize the genes of the current population, and cross processing is performed on the optimized individuals, which may include A21 to A27:
[0098] A21, dividing the entire parameter space into u subspaces, each subspace represents a gene cluster; wherein the parameter space includes all possible values of the token bucket parameter; u is an integer greater than 1;
[0099] The parameter space refers to all possible values of the token bucket parameter, that is, the parameter space includes multiple sets of token bucket parameters. The entire parameter space is divided into u subspaces, and each subspace represents a gene cluster, which is equivalent to dividing all possible values of the token bucket parameter into u classes.
[0100] A22, clustering the token bucket parameters corresponding to each individual of the current population into u gene clusters, so that each individual is divided into u subspaces;
[0101] That is, here we cluster the individuals in the current population to find out which gene cluster each individual in the current population should be classified into.
[0102] A23. Sort the individuals in the current population in descending order according to their fitness values, and select the top r individuals from the sorted individuals; where r is an integer greater than 1;
[0103] That is, sort the individuals in the current population in descending order of fitness value, and then select the top r individuals. You can also set a ratio here, and select the top individuals from the sorting results according to the ratio.
[0104] A24, assigning corresponding weights to the r individuals, and the individual with a higher fitness value is assigned a larger weight;
[0105] That is, the principle of weight distribution is: the higher the ranking, the higher the weight.
[0106] A25, multiplying the average fitness of the gene cluster to which each of the r individuals belongs by the weight of the individual to obtain r products;
[0107] That is, the average fitness value of each individual in the gene cluster to which each individual belongs is multiplied by the weight of the individual to obtain the product corresponding to the individual. In this way, r products can be obtained.
[0108] A26. Based on r products, select w individuals with the largest product; where w is an integer greater than 1 and less than r;
[0109] A27. Perform crossover processing on the w individuals to obtain individuals after crossover processing.
[0110] For example, 10 products can be obtained through A25, and 6 individuals with the largest products are selected through A26, and these 6 individuals are cross-processed in A27.
[0111] Specifically, during crossover, two individuals exchange some of their genes.
[0112] A3. The selected individuals and the individuals after the crossover process form a population, and the individuals in the population are mutated.
[0113] Among them, mutation refers to the random change of certain parameters of an individual with a certain probability to introduce new genetic mutations.
[0114] In actual scenarios, the crossover and mutation operators are changed dynamically according to the different stages of population evolution. In the initial stage of population evolution, strong crossover and weak mutation are used; when the population evolves slowly and falls into a local optimal solution, weak crossover and strong mutation are used. Subsequently, the parameters in the above process can be dynamically adjusted according to the real-time load of the system and performance feedback data.
[0115] It can be seen that after the selection and crossover processes, a certain number of individuals are obtained, and these individuals form a population. The population is mutated, and after the mutation is completed, an updated population is obtained. In summary, the genetic algorithm continuously optimizes the population by simulating the processes of natural selection, crossover and mutation, so as to facilitate the subsequent selection of better individuals.
[0116] The embodiments of the present invention have the following beneficial effects:
[0117] (1) The embodiment of the present invention utilizes the adaptive optimization characteristics of the genetic algorithm to automatically adjust the token generation rate and token bucket capacity according to different message processing tasks and system load conditions, ensuring that the system can operate in the best state at any given time point. This enables the system to flexibly respond to sudden traffic, avoid service interruptions caused by overload, and improve overall stability and reliability.
[0118] (2) Through the iterative evolution process of the genetic algorithm, the system of the embodiment of the present invention can intelligently discover and apply the most effective resource allocation strategy. For a multi-node distributed environment, the embodiment of the present invention helps to ensure that each node obtains the corresponding message data according to its processing capacity, avoids idle resources or excessive consumption, and thus improves resource utilization and processing efficiency.
[0119] (3) The embodiment of the present invention combines the token bucket algorithm to achieve effective control of the message processing rate. When the system is close to the upper limit of the processing capacity, the token issuance rate is reduced to delay the acceptance of new messages and prevent system overload. On the contrary, when the processing capacity is sufficient, the token issuance rate is increased to fully utilize system resources. This dynamic flow control mechanism significantly improves the system response time and throughput.
[0120] (4) As time goes by, the genetic algorithm continuously learns from system operation feedback and gradually optimizes token bucket parameters and resource allocation strategies, so that the system has the ability to continuously improve itself and can better adapt to unknown situations that may arise in the future without frequent human intervention.
[0121] In a second aspect, an embodiment of the present invention provides an adaptive message processing device, see Figure 2 , the device 100 comprises:
[0122] The token bucket allocation module 110 is used to allocate a token bucket to the message queue;
[0123] A parameter determination module 120, for periodically using a genetic algorithm to determine token bucket parameters according to changes in network performance, wherein the token bucket parameters include a token generation rate and a token bucket capacity;
[0124] A token filling module 130, configured to generate tokens according to the token bucket generation rate, fill each generated token into the token bucket, and limit the number of tokens in the token bucket to be less than or equal to the token bucket capacity;
[0125] A token acquisition module 140, configured to obtain a token from the token bucket before processing each message in the message queue;
[0126] The message processing module 150 is used to process the message if the token is successfully retrieved.
[0127] In one embodiment, the message processing module is further used to: if the token is not successfully taken out, wait until the token can be successfully taken out from the token bucket, and then process the message.
[0128] In one embodiment, the parameter determination module is specifically used for: S1, setting an initial population; wherein the population includes multiple individuals, each of which represents a set of token bucket parameters; S2, calculating the fitness value of each individual in the population according to the fitness function, and selecting the individual with the highest fitness from the population as the current optimal solution; wherein the fitness function is constructed based on a network performance indicator that can reflect the impact of the token generation rate and the token bucket capacity; S3, updating the current population; S4, calculating the fitness value of each individual in the current population according to the fitness function, selecting the individual with the highest fitness from the current population, and judging whether the fitness value of the individual with the highest fitness is higher than the fitness value of the current optimal solution; if so, taking the individual with the highest fitness as the current optimal solution, otherwise, keeping the current optimal solution unchanged; S5, judging whether the preset termination condition is met; S6, if so, outputting the current optimal solution; S7, otherwise, adding 1 to the number of iterations and returning to S3.
[0129] In one embodiment, the process of updating the current population by the parameter determination module includes: selecting multiple individuals from the current population using a non-playback excellent individual multi-copy selection strategy; using an intergenerational subspace optimization gene cluster strategy to perform gene optimization on the current population, and performing crossover processing on the optimized individuals; forming a population with the selected individuals and the crossover-processed individuals, and performing mutation processing on the individuals in the population.
[0130] In one embodiment, the process of the parameter determination module updating the current population using a selection strategy of multiple copies of excellent individuals without playback includes: taking out n individuals from the current population without replacement according to a roulette selection algorithm; calculating the fitness value of each of the n individuals, and sorting the n individuals in order of fitness value from high to low; selecting the front n / 3 individuals to copy two copies, copying the middle n / 3 individuals once, and using the three copies of n / 3 individuals as selected individuals.
[0131] In one embodiment, the parameter determination module uses an intergenerational subspace optimization gene cluster strategy to perform gene optimization on the current population, and performs cross processing on the optimized individuals, including: dividing the entire parameter space into u subspaces, each subspace represents a gene cluster; wherein the parameter space includes all possible values of the token bucket parameter; u is an integer greater than 1; clustering the token bucket parameters corresponding to each individual of the current population into u gene clusters, so that each individual is divided into u subspaces; and arranging each individual of the current population from high to low according to the fitness value. The individuals are sorted in order from highest to lowest, and the top r individuals are selected from the sorted individuals; wherein r is an integer greater than 1; the r individuals are assigned corresponding weights, and the individuals with higher fitness values are assigned larger weights; the fitness average of the gene cluster to which each of the r individuals belongs is multiplied by the weight of the individual to obtain r products; based on the r products, w individuals with the largest products are selected; wherein w is an integer greater than 1 and less than r; the w individuals are cross-processed to obtain individuals after cross-processing.
[0132] In one embodiment, the fitness function is a modified fitness function based on the initial fitness function, and the modified fitness function is:
[0133]
[0134] Among them, F is the modified fitness function, f is the initial fitness function, and f min is the minimum fitness value in the current population, f max is the maximum fitness value in the current population, a is a constant that ensures that the denominator is not 0, and a is greater than 0.
[0135] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0136] In a third aspect, an embodiment of the present invention provides a computer-readable medium, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor executes the method provided in the first aspect.
[0137] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.
[0138] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0139] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0140] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0141] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0142] It is understandable that the explanation, specific implementation methods, beneficial effects, examples, etc. of the relevant contents in the computer-readable medium provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0143] In a fourth aspect, an embodiment of the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the method in any embodiment of the specification.
[0144] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the computing device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0145] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, widgets, or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0147] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. An adaptive message processing method, characterized in that: include: Allocate a token bucket for the message queue; Regularly using a genetic algorithm to determine token bucket parameters according to changes in network performance, the token bucket parameters including a token generation rate and a token bucket capacity; Generate tokens according to the token bucket generation rate, and fill each generated token into the token bucket, and limit the number of tokens in the token bucket to be less than or equal to the token bucket capacity; Before processing each message in the message queue, taking a token from the token bucket; If the token is successfully retrieved, the message will be processed.
2. The method according to claim 1, characterized in that Also includes: If the token is not successfully taken out, wait until the token can be successfully taken out from the token bucket, and then process the message.
3. The method according to claim 1, characterized in that The periodic use of a genetic algorithm to determine token bucket parameters according to changes in network performance includes: S1. Setting an initial population; wherein the population includes a plurality of individuals, each of which represents a set of token bucket parameters; S2. Calculate the fitness value of each individual in the population according to the fitness function, and select the individual with the highest fitness from the population as the current optimal solution; wherein the fitness function is constructed according to a network performance indicator that can reflect the impact of the token generation rate and the token bucket capacity; S3, update the current population; S4, according to the fitness function, calculate the fitness value of each individual in the current population, select the individual with the highest fitness from the current population, and determine whether the fitness value of the individual with the highest fitness is higher than the fitness value of the current optimal solution; if so, take the individual with the highest fitness as the current optimal solution, otherwise, keep the current optimal solution unchanged; S5, determining whether a preset termination condition is met; S6. If yes, output the current optimal solution; S7. Otherwise, increase the number of iterations by 1 and return to S3.
4. The method according to claim 3, characterized in that The updating of the current population includes: A non-replay excellent individual multi-copy selection strategy is used to select multiple individuals from the current population; The intergenerational subspace optimization gene cluster strategy is used to optimize the genes of the current population, and the optimized individuals are cross-processed; The selected individuals and the individuals after the crossover process form a population, and the individuals in the population are mutated.
5. The method according to claim 4, characterized in that The process of updating the current population using the non-replay excellent individual multi-copy selection strategy includes: According to the roulette wheel selection algorithm, n individuals are taken from the current population without replacement; Calculate the fitness value of each of the n individuals, and sort the n individuals in descending order of fitness value; Select the first n / 3 individuals and make two copies, and make one copy of the middle n / 3 individuals. The three copies of n / 3 individuals are used as the selected individuals.
6. The method according to claim 4, characterized in that The method of using the intergenerational subspace optimization gene cluster strategy to optimize genes in the current population and performing crossover processing on the optimized individuals includes: The entire parameter space is divided into u subspaces, each of which represents a gene cluster; wherein the parameter space includes all possible values of the token bucket parameter; u is an integer greater than 1; Cluster the token bucket parameters corresponding to each individual in the current population into u gene clusters, so that each individual is divided into u subspaces; Sort the individuals in the current population in descending order of fitness value, and select the top r individuals from the sorted individuals; where r is an integer greater than 1; Assigning corresponding weights to the r individuals, and the individuals with higher fitness values are assigned larger weights; Multiplying the average fitness of the gene cluster to which each of the r individuals belongs by the weight of the individual to obtain r products; Based on r products, select w individuals with the largest product; where w is an integer greater than 1 and less than r; Perform crossover processing on the w individuals to obtain individuals after crossover processing.
7. The method according to claim 3, characterized in that The fitness function is a modified fitness function based on the initial fitness function. The modified fitness function is: Among them, F is the modified fitness function, f is the initial fitness function, and f min is the minimum fitness value in the current population, f max is the maximum fitness value in the current population, a is a constant that ensures that the denominator is not 0, and a is greater than 0.
8. An adaptive message processing device, characterized in that: include: A token bucket allocation module is used to allocate a token bucket to a message queue; A parameter determination module, used to periodically use a genetic algorithm to determine token bucket parameters according to changes in network performance, wherein the token bucket parameters include a token generation rate and a token bucket capacity; A token filling module, used for generating tokens according to the token bucket generation rate, and filling each token generated into the token bucket, and limiting the number of tokens in the token bucket to be less than or equal to the token bucket capacity; A token acquisition module, used for taking a token from the token bucket before processing each message in the message queue; The message processing module is used to process the message if the token is successfully retrieved.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
10. A computing device, characterized in that The method comprises a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for submitting training task to speed-limiting queue
CN112202684A
Self-learning explicit mark congestion control method and system based on token bucket
CN118055072A
Token bucket-based method, device, and system for interface throttling, and readable storage medium
WO2021114829A1