Task processing method and device, equipment, medium and product
By introducing a priority scheduler into the task processing system, dynamically adjusting the current limit value of the token bucket, the task processing timeliness caused by limited resources in downstream systems is solved, and the reasonable allocation of resources and the improvement of task processing efficiency is achieved.
Patent Information
- Application Number
- CN202411846309.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-03-21
AI Technical Summary
In the task distribution scenario, due to the limited hardware resources of the downstream system, different tasks seize resources, affecting the task processing timeliness, and it is difficult to achieve reasonable resource utilization.
The priority scheduler is introduced to manage the current limit value of multiple token buckets, and dynamically adjust the current limit value according to the priority of the task queue to ensure that resources are assigned to the task queue with high priority. The current limit value of each task queue matches the actual task request situation.
By dynamically adjusting the current limit value, we ensure the processing time of high-priority tasks, realize the reasonable allocation of resources, and improve task processing efficiency.
Smart Images

Figure CN119668878A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a task processing method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] In the task distribution scenario, usually, a task queue is introduced between the upstream system that generates tasks and the downstream system that processes tasks. The upstream system, downstream system and task queue can form a task processing system. The task queue is used to temporarily store the tasks generated by the upstream system, and the number of tasks processed by the downstream system is limited. In this way, the traffic of task requests is peak-cut and traffic shaping is performed to reduce the task processing pressure of the downstream system and ensure the normal operation of task distribution.
[0003] However, when the number of tasks is large, due to the limited hardware resources of the downstream system, different tasks compete for resources with each other, affecting the task processing timeliness and making it difficult to achieve reasonable resource utilization. Summary of the invention
[0004] The present disclosure provides a task processing method. The method can ensure that resources are preferentially allocated to high-priority task queues, and the current limit value of each task queue matches the actual task processing situation, thereby achieving reasonable allocation of resources. The present disclosure also provides a device, an electronic device, a computer-readable storage medium, and a computer program product corresponding to the above method.
[0005] In a first aspect, the present disclosure provides a task processing method, which is applied to a task processing system, wherein the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities, and multiple token buckets, wherein the priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the multiple current limiters are used to limit the current for task requests of the multiple task queues; the method includes:
[0006] The priority scheduler respectively obtains the number of tokens applied by the multiple current limiters to the multiple token buckets in the first unit time;
[0007] The priority scheduler determines the flow limiting values of the multiple token buckets in the second unit time in sequence according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets in the first unit time in the order of the priorities of the multiple task queues from high to low; wherein the second unit time is the next unit time of the first unit time, and the flow limiting value is the number of tokens generated in the second unit time;
[0008] The priority scheduler updates the current limiting values within the second unit time to the multiple token buckets.
[0009] In a second aspect, the present disclosure provides a task processing device, which is deployed in a task processing system, wherein the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities, and multiple token buckets, wherein the priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the multiple current limiters are used to limit the current for task requests of the multiple task queues; the device includes:
[0010] An acquisition module, used for respectively acquiring the number of tokens applied by the multiple current limiters from the multiple token buckets within a first unit time;
[0011] A determination module, configured to sequentially determine the flow limiting values of the multiple token buckets within a second unit time according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets within a first unit time in the order of the priorities of the multiple task queues from high to low; wherein the second unit time is the next unit time of the first unit time, and the flow limiting value is the number of tokens generated within the second unit time;
[0012] An updating module is used to update the current limiting value within the second unit time to the multiple token buckets.
[0013] In a third aspect, the present disclosure provides an electronic device, the electronic device comprising a processor and a memory. The processor and the memory communicate with each other. The processor is used to execute instructions stored in the memory so that the electronic device performs the task processing method in the first aspect or any implementation of the first aspect.
[0014] In a fourth aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, wherein the instructions instruct an electronic device to execute the task processing method described in the first aspect or any one of the implementations of the first aspect.
[0015] In a fifth aspect, the present disclosure provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the task processing method described in the first aspect or any one of the implementations of the first aspect.
[0016] Based on the implementations provided in the above aspects, the present disclosure can be further combined to provide more implementations.
[0017] It can be seen from the above technical solutions that the present disclosure has the following advantages:
[0018] The present disclosure provides a task processing method, which is applied to a task processing system, wherein the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities, and multiple token buckets. The priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the current limiters are used to limit the current of task requests of the multiple task queues.
[0019] Specifically, the priority scheduler respectively obtains the number of tokens applied for by multiple limiters to multiple token buckets in the first unit time, and determines the current limiting values of the multiple token buckets in the second unit time in sequence according to the number of tokens applied for by multiple limiters to multiple token buckets in the first unit time, in order of the priorities of the multiple task queues from high to low, wherein the second unit time is the next unit time of the first unit time, and the current limiting value is the number of tokens generated in the second unit time. Then, the priority scheduler updates the current limiting values of the multiple token buckets in the second unit time.
[0020] In this method, a priority scheduler is added to the task processing system to dynamically adjust the current limit value in each unit time. Since the priority scheduler assigns current limit values to different task queues based on the priority of the task queue, and the current limit value of each task queue in the next unit time is related to the number of token applications in the previous unit time that characterizes the actual task request traffic, it ensures that resources are allocated to high-priority task queues first, and the current limit value of each task queue matches the actual task request situation, so as to achieve reasonable allocation of resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical method of the embodiments of the present disclosure, the drawings required for use in the embodiments are briefly introduced below.
[0022] Figure 1 A schematic diagram of the architecture of a task processing system provided by an embodiment of the present disclosure;
[0023] Figure 2 A flowchart of a task processing method provided by an embodiment of the present disclosure;
[0024] Figure 3 A schematic diagram of a process of applying for a token provided in an embodiment of the present disclosure;
[0025] Figure 4 A schematic diagram of a flow chart for updating a current limiting value provided in an embodiment of the present disclosure;
[0026] Figure 5 A schematic diagram of the structure of a task processing device provided by an embodiment of the present disclosure;
[0027] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] The terms "first" and "second" in the embodiments of the present disclosure are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0029] First, some technical terms and application scenarios involved in the embodiments of the present disclosure are introduced.
[0030] The task processing system can be understood as a system for generating and processing tasks. In the task distribution scenario, the task processing system can be composed of an upstream system that generates tasks, a task queue, and a downstream system that processes tasks. The task queue is used to temporarily store the tasks generated by the upstream system, and the number of tasks processed by the downstream system is limited. In this way, the traffic of task requests is peak-cut and traffic shaping is performed to reduce the task processing pressure of the downstream system and ensure the normal operation of task distribution.
[0031] Tasks can be divided into different priorities, for example, according to the processing time requirements, importance, task source, etc. However, due to the limited hardware resources of the downstream system (such as storage resources, central processing unit (CPU) resources, network bandwidth resources, etc.), in the above method, tasks of different priorities compete for resources with each other. If there are too many low-priority tasks, high-priority tasks are often blocked by a large number of low-priority tasks, which may affect the processing time of high-priority tasks and make it difficult to achieve reasonable resource utilization.
[0032] Taking the task processing system as a point of interest (POI) data management system as an example, POI can be understood as information used to describe a geographic location. For example, POI can include the name, category, longitude and latitude, classification and other information of the geographic location. In the POI data management system, the upstream system that generates tasks can be the system that generates POI data, and the downstream system that processes tasks can be the system that consumes (can also be understood as updating) POI data. Since there are many asynchronous and large-scale upstream systems in the POI data management system, there is a resource competition relationship between the data production links of the upstream systems, and the business peak periods of different task queues are inconsistent. The method of limiting the number of tasks processed by the downstream system with a fixed current limit value results in low resource utilization, and the processing timeliness of high-priority tasks cannot be ensured, and the task processing efficiency is low.
[0033] In view of this, the present disclosure provides a task processing method, which is applied to a task processing system, wherein the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities, and multiple token buckets. The priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the current limiters are used to limit the current of the task requests of the multiple task queues.
[0034] Specifically, the priority scheduler respectively obtains the number of tokens applied for by multiple limiters to multiple token buckets in the first unit time, and determines the current limiting values of the multiple token buckets in the second unit time in sequence according to the number of tokens applied for by multiple limiters to multiple token buckets in the first unit time, in order of the priorities of the multiple task queues from high to low, wherein the second unit time is the next unit time of the first unit time, and the current limiting value is the number of tokens generated in the second unit time. Then, the priority scheduler updates the current limiting values of the multiple token buckets in the second unit time.
[0035] In this method, a priority scheduler is added to the task processing system to dynamically adjust the current limit value in each unit time. Since the priority scheduler assigns current limit values to different task queues based on the priority of the task queue, and the current limit value of each task queue in the next unit time is related to the number of token applications in the previous unit time that characterizes the actual task request traffic, it ensures that resources are allocated to high-priority task queues first, and the current limit value of each task queue matches the actual task request situation, so as to achieve reasonable allocation of resources.
[0036] To facilitate understanding of the technical solution provided by the embodiments of the present disclosure, the following is a description with reference to the accompanying drawings. Figure 1 The schematic diagram of the architecture of a task processing system is shown, and the task processing system 10 includes a priority scheduler 101, multiple current limiters 102, multiple task queues 103 and multiple token buckets 104, which are described below respectively.
[0037] A plurality of task queues 103, for example, task queue P0, task queue P1, ..., task queue Pn, are task queues with different priorities, which are used to receive and store tasks generated by the upstream system. In other words, tasks with different priorities are stored in the plurality of task queues 103, for example, the task queue P0 stores the task with the highest priority, the task queue P1 stores the task with the second highest priority, and the task queue Pn stores the task with the lowest priority. After the upstream system generates a task, according to the task priority, the task is delivered to different task queues 103, and a plurality of task queues 103 are utilized to isolate tasks with different priorities, so as to avoid tasks with different priorities from blocking each other.
[0038] Multiple current limiters 102, such as current limiter P0, current limiter P1, ... current limiter Pn, are used to limit the current for task requests of multiple task queues 103. In the embodiment of the present disclosure, multiple current limiters 102 correspond to multiple task queues 103 one by one, that is, one current limiter 102 is used to limit the current for task requests of one task queue 103, for example, current limiter P0 is used to limit the current for task requests of task queue P0, current limiter P1 is used to limit the current for task requests of task queue P1, and current limiter Pn is used to limit the current for task requests of task queue Pn.
[0039] Among them, the task request can be used to request the processing of tasks in multiple task queues 103, and the current limiter 102 can generate a response to allow the task request or reject the task request. In some embodiments, when the upstream system generates a task and stores the task in the task queue 103, a task request is automatically generated. If the current limiter 102 generates a response to allow the task request, the downstream system can perform task processing. In other embodiments, the task request can also be generated by the downstream system. When the downstream system has a task processing demand, the downstream system generates a task request. If the current limiter 102 generates a response to allow the task request, the downstream system can perform task processing. In this way, through the current limiting of multiple current limiters 102, the number of tasks processed by the downstream system is avoided to be too large.
[0040] In the disclosed embodiment, the task request of the task processing system 10 can be of different types. In some embodiments, the task request can be a request related to data, such as a request to consume data. In other embodiments, the task request can also be a request related to a message, such as a request to read a message.
[0041] The current limiter 102 implements current limiting with the help of a token bucket 104. The token bucket 104 generates tokens at a certain rate, and each task request needs to consume a certain number (recorded as 1 in the embodiment of the present disclosure) of tokens before it can be processed. If the number of tokens in the token bucket 104 is insufficient, the task request will be rejected. In this way, the task processing rate of the downstream system is controlled to prevent system crashes caused by excessive task requests.
[0042] The multiple task queues 103 correspond to the multiple token buckets 104 one by one. For example, the multiple token buckets 104 may be token buckets P0, token buckets P1, ..., token buckets Pn, token buckets P0 correspond to the task queue P0, the task request of the task queue P0 consumes the tokens in the token bucket P0, and when the current limiter P0 performs current limiting on the task request of the task queue P0, it generates a response to allow the task request or reject the task request based on the tokens in the token bucket P0. Similarly, token buckets P1 correspond to the task queue P1, and token buckets Pn correspond to the task queue Pn.
[0043] The priority scheduler 101 is used to manage the flow limit values of multiple token buckets 104, where the flow limit value can be understood as the number of tokens generated per unit time of the token bucket 104. In other words, the priority scheduler 101 can dynamically adjust the number of tokens generated per unit time of multiple token buckets 104 to fully utilize resources.
[0044] In some possible implementations, the token bucket 104 can be implemented using a remote dictionary server (redis), that is, the token bucket 104 can be a redis token bucket, and data related to the token bucket 104 (such as the number of tokens, current limiting value, etc.) can be stored in redis. Since redis has a distributed feature, each current limiter 102 and priority scheduler 101 can be deployed in a distributed manner on multiple servers.
[0045] In the redis token bucket, the redis counter is used to count the number of tokens that the current limiter applies for from the token bucket. In other words, when the current limiter applies for 1 token from the token bucket, the count value of the redis counter is increased by 1.
[0046] In some embodiments, the priority scheduler 101 and the plurality of current limiters 102 may be deployed in the task processing system 10 in the form of a software development kit (SDK), thereby implementing current limiting logic for a plurality of token buckets at a relatively low access cost.
[0047] based on Figure 1 The task processing system 10 shown in the figure, the present disclosure also provides a task processing method. The task processing method provided by the present disclosure is introduced below in conjunction with an embodiment. Figure 2 The flowchart of a task processing method provided by an embodiment of the present disclosure is shown, and the method specifically includes:
[0048] S201: The priority scheduler obtains the number of tokens applied for by multiple flow limiters from multiple token buckets within the first unit time respectively.
[0049] The unit time can be understood as the frequency of the priority scheduler dynamically assigning the current limit value, and multiple token buckets generate the number of tokens of the current limit value assigned by the priority scheduler in each unit time. For example, the unit time can be 1 second, and the priority scheduler dynamically assigns the current limit value within each second to multiple token buckets, and multiple token buckets generate the number of tokens of the current limit value assigned by the priority scheduler in each second. When the priority scheduler assigns a current limit value of 100 to token bucket A in the Nth second, token bucket A generates 100 tokens in the Nth second.
[0050] The current limiter determines whether to allow the task request to be executed in combination with the token in the token bucket. Taking the first task queue as an example, the first task queue is one of the multiple task queues, the first task queue corresponds to the first token bucket, and the first task queue corresponds to the first current limiter. Within the first unit time, when a task request from the first task queue is received, the first current limiter can apply for a token from the first token bucket. If there are tokens in the first token bucket that have been generated but not yet consumed, the first current limiter can generate a response allowing the task request based on the applied token. If all the tokens in the first token bucket have been consumed, the first current limiter cannot apply for a token from the first token bucket, and generates a response rejecting the task request.
[0051] Based on the above current limiting logic, the number of tokens applied by multiple current limiters to multiple token buckets in the first unit time can be used to characterize the task request flow of multiple task queues in the first unit time. For example, current limiter A corresponds to token bucket A, token bucket A corresponds to task queue A, the number of tokens applied by current limiter A to token bucket A in the first unit time is 20, current limiter B corresponds to token bucket B, the number of tokens applied by current limiter B to token bucket B in the first unit time is 40, then the task request flow of task queue A in the first unit time is less than the task request flow of task queue B in the first unit time.
[0052] S202: The priority scheduler determines the flow limiting values of the multiple token buckets in the second unit time in sequence according to the order of the priorities of the multiple task queues from high to low and according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets in the first unit time.
[0053] The second unit time is the next unit time of the first unit time. In other words, the second unit time is adjacent to the first unit time, and the second unit time is after the first unit time. For example, the unit time is 1 second, the first unit time is the Nth second, and the second unit time is the N+1th second, where N is an integer greater than 0.
[0054] The current limit value is the number of tokens generated in the second unit time. Taking the first task queue as an example, the priority scheduler determines that the current limit value of the first token bucket in the second unit time is M, and the first token bucket can generate at most M tokens in the second unit time.
[0055] In the disclosed embodiment, since the task queues have different priorities, the tasks stored in the high-priority task queues usually have higher requirements for processing time efficiency. Therefore, when dynamically allocating the current limiting values of each task queue, the current limiting values of the high-priority task queues are preferentially allocated. For example, the multiple task queues include task queue A, task queue B, and task queue C, and the order of priority from high to low is task queue A, task queue B, and task queue C. The priority scheduler can first allocate the current limiting value to task queue A, then allocate the current limiting value to task queue B, and finally allocate the current limiting value to task queue C. In this way, limited resources are preferentially allocated to high-priority tasks, thereby improving the processing time efficiency of high-priority tasks.
[0056] In addition, the priority scheduler combines the task request flow of multiple task queues in the first unit time and assigns flow limiting values to different task queues, so that the flow limiting value of each task queue matches the actual task request flow, ensuring the overall task request flow of the task processing system is stable.
[0057] S203: The priority scheduler updates the current limiting values within the second unit time to the multiple token buckets.
[0058] After determining the current limiting values of multiple token buckets within the second unit time, the priority scheduler can also update the current limiting values of multiple token buckets. In this way, within the second unit time, multiple token buckets can generate tokens with corresponding current limiting values to achieve dynamic current limiting.
[0059] In this method, a priority scheduler is added to the task processing system to dynamically adjust the current limit value in each unit time. Since the priority scheduler assigns current limit values to different task queues based on the priority of the task queue, and the current limit value of each task queue in the next unit time is related to the number of token applications in the previous unit time that characterizes the actual task request traffic, it ensures that resources are allocated to high-priority task queues first, and the current limit value of each task queue matches the actual task request situation, so as to achieve reasonable allocation of resources.
[0060] The specific implementation process of the above-mentioned task processing method is introduced below. In the embodiment of the present disclosure, the current limiter can apply for tokens from the token bucket in different ways. Taking the third current limiter as an example, the third current limiter is one of the multiple current limiters, the third current limiter corresponds to the third task queue, and the third task queue corresponds to the third token bucket. In some embodiments, for the task request of the third task queue, the third current limiter can apply to the third token bucket for the same number of tokens as the number of task requests. In other words, since in the embodiment of the present disclosure, one task request consumes one token, the third current limiter can only apply to the third token bucket for the same number of tokens as the number of tokens required to process the task request, so that the third receiver receives a task request, that is, applies for a token from the third token bucket once.
[0061] In other embodiments, considering the frequent interactions between the current limiter and the token bucket in the above token application method, tokens can also be pulled in batches. Figure 3 As shown, the third current limiter receives a first task request within a first unit time, and in response to the number of tokens in the local token library of the third current limiter being not zero, the third current limiter generates a response allowing the first task request based on the tokens in the local token library. In response to the number of tokens in the local token library of the third current limiter being zero, the third current limiter applies for a set number of tokens from the third token bucket, and performs the following steps: storing the set number of tokens in the local token library, and, based on the tokens in the local token library, generating a response allowing the first task request. In response to the number of tokens in the local token library of the third current limiter being zero, and the number of tokens applied by the third current limiter to the third token bucket in the first unit time being greater than the current limiting value of the third token bucket in the first unit time, the third current limiter generates a response rejecting the first task request.
[0062] The first task request is used to request processing of tasks in the third task queue, the tokens in the local token library are tokens stored locally in the third current limiter, and the set quantity is an integer greater than 1.
[0063] That is to say, the third current limiter can apply for multiple tokens from the third token bucket at one time. Since the set number of tokens that the third current limiter applies for from the third token bucket at one time can be greater than the task request of the third task queue, there can be remaining tokens in the local token library of the third current limiter. For example, if the third current limiter applies for 10 tokens from the third token bucket, and the number of task requests of the third task queue is 4, then 6 tokens are stored in the local token library of the third current limiter.
[0064] For the first task request received by the third limiter within the first unit time, for example, a task request automatically generated after the upstream system generates a task, or a task request generated by the downstream system based on the task processing requirements, the third limiter first checks the tokens in the local token library. If there is a local token inventory, the local tokens are consumed to allow the first task request. If there is no local token inventory, a set number of tokens are applied to the third token bucket locally as tokens in the local token inventory. For example, the third limiter uses a second-level timestamp to generate an identifier (key) to apply to the third token bucket for a set number of tokens to distinguish multiple token applications, and then, the local tokens are still consumed to allow the first task request. If there is no local token inventory, and the tokens generated by the third token bucket in the first unit time are all consumed, and the number of tokens is insufficient, the first task request is rejected.
[0065] In this way, in the scenario of redis token bucket, tokens are applied for in batches from the token bucket through the current limiter, which reduces the redis request pressure, shortens the judgment time caused by redis input / output (I / O), and improves the efficiency of dynamically allocating current limit values.
[0066] The embodiments of the present disclosure do not impose any restrictions on the set number, and the set number can be configured in combination with specific business scenarios. Normally, when the unit time is 1 second and the limiter is distributed and deployed on multiple servers, the maximum query rate per second (queries-per-second, QPS) between the limiter and the token library is the limit value of the second / set number + the number of servers of the limiter. If the set number is small, it will cause an increase in QPS and increase the pressure on redis. At the same time, the set number × the number of servers of the limiter should be less than the limit value of the second. If the set number is large, it will cause an increase in the number of tokens applied for locally but not used, resulting in a waste of tokens. Therefore, when configuring the set number, a balance should be struck between token waste and redis pressure.
[0067] Furthermore, the disclosed embodiment also provides a current limiting logic when a token bucket fails. Specifically, in response to a token bucket failure in multiple token buckets and the number of tokens in the local token library of the third current limiter is zero, the third current limiter generates a response to reject the first task request.
[0068] That is to say, in the disclosed embodiment, when the token bucket fails, for example, redis fails, the current limiting logic is downgraded to single-machine current limiting, and the local token library is used as a backup. If all the tokens in the local token library are consumed, the first task request is rejected. In this way, the current limiting logic is completely ineffective, ensuring the stability of the task processing system.
[0069] The following takes the first task queue as an example to illustrate the process of determining the current limiting value of the first token bucket in the second unit time in the embodiment of the present disclosure. The first task queue corresponds to the first token bucket, and the first task queue corresponds to the first current limiter. The number of tokens applied by the first current limiter to the first token bucket in the first unit time is the first token number. In specific implementation, the priority scheduler determines the first current limiting value of the first token bucket in the first unit time, and determines the remaining current limiting value of the first token bucket in the second unit time. Then, the priority scheduler determines the current limiting value of the first token bucket in the second unit time based on the first token number, the first current limiting value and the remaining current limiting value.
[0070] Among them, the remaining current limit value is the difference between the preset total current limit value and the current limit value of the token bucket corresponding to the task queue with a higher priority than the first task queue in the second unit time. In the embodiment of the present disclosure, the remaining current limit value can be understood as the maximum current limit value that the priority scheduler can allocate to the first token bucket in the second unit time.
[0071] That is to say, the priority scheduler traverses the task queues of each priority from high to low, and recursively assigns the current limit value to the task queues of each priority. For the task queue with the highest priority, the remaining current limit value is the preset total current limit value, for the task queue with the second highest priority, the remaining current limit value is the difference between the preset total current limit value and the current limit value of the task queue with the highest priority in the second unit time, and for the task queue with the third highest priority, the remaining current limit value is the difference between the preset total current limit value and the current limit values of the task queues with the highest priority and the second highest priority in the second unit time.
[0072] For example, the preset total current limiting value is 400, and multiple task queues include task queue A, task queue B and task queue C. The order of priority from high to low is task queue A, task queue B and task queue C. The remaining current limiting value of task queue A is 400, and the current limiting value allocated by the priority scheduler to task queue A in the second unit time is 150, and the remaining current limiting value of task queue B is 250. The current limiting value allocated by the priority scheduler to task queue B in the second unit time is 100, and the remaining current limiting value of task queue C is 150.
[0073] Usually, the preset total current limit value matches the number of hardware resources of the downstream system. In other words, the more hardware resources the downstream system has, the larger the preset total current limit value can be. In actual applications, it can be configured in combination with specific business scenarios.
[0074] In this way, when the priority scheduler dynamically allocates current limit values for each task queue, it will give priority to allocating resources to high-priority tasks to avoid high-priority tasks being blocked by low-priority tasks.
[0075] In some possible implementations, the priority scheduler may assign a current limiting value to the task queue based on a greedy strategy. Specifically, in response to the first token number being greater than or equal to the first current limiting value, the priority scheduler determines the current limiting value of the first token bucket in the second unit time as the smaller of the following two values: the sum of the first token number and the number of scheduling tokens corresponding to the first unit time, and the remaining current limiting value.
[0076] In response to the first token number being less than the first current limit value, the priority scheduler determines the current limit value of the first token bucket in the second unit time as the larger of the following two values: the difference between the first token number and the scheduling token number corresponding to the first unit time, and zero.
[0077] In an embodiment of the present disclosure, the number of scheduling tokens corresponding to the first unit time can be the token number adjustment value of the first unit time. In other words, the number of scheduling tokens can be understood as the scheduling step, and the number of scheduling tokens can be used to indicate the amplitude of adjusting the current limiting value per unit time.
[0078] That is to say, by comparing the number of tokens applied for by the first limiter to the first token bucket and the current limiting value allocated to the first token bucket within the first unit time, it is determined whether the current limiting value allocated to the first token bucket within the first unit time meets the task request flow of the first task queue.
[0079] If the first token number is greater than or equal to the first current limiting value, it indicates that the current limiting value allocated to the first token bucket in the first unit time does not meet the task request flow of the first task queue. In this case, the first task queue "occupies" the remaining current limiting value, and the priority scheduler sets the current limiting value of the first token bucket in the second unit time to min(first token number + scheduling token number, remaining current limiting value), that is, the current limiting value of the first token bucket in the second unit time is determined as the smaller value between "the sum of the first token number and the scheduling token number" and "the remaining current limiting value".
[0080] If the first token number is less than the first current limiting value, it indicates that the current limiting value allocated to the first token bucket in the first unit time satisfies the task request flow of the first task queue and there is some surplus. In this case, the first task queue "returns" the remaining current limiting value, and the priority scheduler sets the current limiting value of the first token bucket in the second unit time to max(first token number - scheduling token number, 0), that is, the current limiting value of the first token bucket in the second unit time is determined as the larger value between "the difference between the first token number and the scheduling token number" and 0.
[0081] In this way, the priority scheduler dynamically adjusts the flow limit value of the task queue in the next unit time based on the actual task request flow of the task queue in the previous unit time, so that the flow limit value of the task queue in the next unit time matches the actual task request flow of the task queue in the previous unit time. The flow limit value of the task queue in the next unit time fits the actual task request flow, and the flow limit value of each task queue is more reasonable.
[0082] In some embodiments, the number of scheduling tokens may be a fixed value, in other words, the priority scheduler adjusts the current limit value of the task queue in multiple unit times with a fixed scheduling step. In other embodiments, the number of scheduling tokens may meet the following condition: the number of scheduling tokens corresponding to multiple consecutive unit times increases successively.
[0083] If a fixed number of scheduling tokens is used, when the task request flow of the highest priority task queue drops suddenly (for example, it drops to 0), it takes the total flow limit value / number of scheduling tokens per unit time to allocate hardware resources to the task queues with lower priorities, and the adjustment speed is slow. Therefore, a number of scheduling tokens that increases in sequence in multiple consecutive unit times is set, for example, the number of scheduling tokens is increased in the form of an exponential function, the adjustment time is optimized, and the adjustment can be completed in a shorter time.
[0084] In addition, in actual applications, you can also configure the maximum or minimum flow limit value of each task queue in combination with specific business scenarios, and flexibly configure each task queue. For example, the minimum flow limit value allocated to low-priority task queues is 20 to prevent task requests from being unable to be processed in low-priority task queues.
[0085] Furthermore, the plurality of task queues may further include a second task queue, the second task queue corresponding to the second token bucket, and the second task queue being the task queue with the lowest priority among the plurality of task queues. The priority scheduler may further determine the difference between the remaining current limiting value of the second token bucket in the second unit time and the current limiting value of the second token bucket in the second unit time, and in response to the difference being greater than zero, the priority scheduler updates the current limiting value of the second token bucket in the second unit time according to the difference.
[0086] That is to say, after the priority scheduler allocates the current limit values for all task queues within the second unit time, if there are still remaining current limit values, the remaining current limit values will be allocated to the task queue with the lowest priority. In this way, the total current limit values are allocated to the task queues, and the remaining resources are allocated to the low-priority tasks while ensuring the processing time of the high-priority tasks, avoiding the idle running of resources.
[0087] As mentioned above, the priority scheduler can be deployed in a distributed manner on multiple servers. In this case, the priority scheduler can update the current limit value within the second unit time to multiple token buckets through optimistic locking.
[0088] Among them, optimistic locking is a strategy for managing concurrency control. Since the priority schedulers are deployed in a distributed manner, the priority schedulers on multiple servers can all calculate the current limit value for each task queue in each unit time, and can all update the current limit value to each token bucket. Therefore, there may be concurrency conflicts between the priority schedulers on multiple servers. In this case, the priority scheduler updates the current limit value to multiple token buckets through optimistic locking, so that only the priority scheduler on one server can be updated successfully, thereby improving throughput and avoiding concurrency conflicts and repeated updates.
[0089] The embodiments of the present disclosure do not limit the specific implementation methods for implementing optimistic locking. For example, the priority scheduler can implement optimistic locking by adding a version number, checking a timestamp, comparing and swapping (CAS), and other methods.
[0090] Furthermore, considering possible failures of the token bucket, in addition to the above-mentioned method of dynamically allocating the current limit value, the embodiment of the present disclosure also provides a method of fixing the current limit value. Specifically, Figure 4 As shown, in response to a token bucket failure in a plurality of token buckets, the priority scheduler updates preset current limiting values corresponding to the plurality of current limiters to the plurality of current limiters.
[0091] That is to say, when the token bucket fails, for example, redis fails and distributed current limiting is unavailable, disaster recovery downgrade is performed, and the preset current limiting value is updated to the current limiter so that the current limiter can limit the current at the preset current limiting value, avoiding the increase in task request traffic of the task processing system caused by the change in the number of servers of the current limiter when redis fails. At the same time, when redis recovers, the priority scheduler returns to the method of dynamically adjusting the allocation of current limiting values. There may be an imbalance in the allocation at the moment of switching between the two methods, but it can be adjusted to the ideal state in a short time.
[0092] Combination of the above Figures 1 to 4 The task processing method provided by the embodiment of the present disclosure is introduced in detail. The following will introduce the device and equipment provided by the embodiment of the present disclosure in conjunction with the accompanying drawings.
[0093] See also Figure 5The structural schematic diagram of the task processing device shown in the figure, the device 50 is deployed in the task processing system, the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities and multiple token buckets, the priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the multiple current limiters are used to limit the current for the task requests of the multiple task queues; the device 50 includes:
[0094] An acquisition module 501 is used to respectively acquire the number of tokens applied by the multiple current limiters from the multiple token buckets within a first unit time;
[0095] A determination module 502 is used to determine the flow limiting values of the multiple token buckets in a second unit time in order of the priorities of the multiple task queues from high to low, according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets in a first unit time; wherein the second unit time is the next unit time of the first unit time, and the flow limiting value is the number of tokens generated in the second unit time;
[0096] The updating module 503 is configured to update the current limiting values within the second unit time to the multiple token buckets.
[0097] It should be noted that the acquisition module 501, the determination module 502 and the update module 503 may be modules deployed in a priority scheduler.
[0098] In some possible implementations, the multiple task queues include a first task queue, the first task queue corresponds to a first token bucket, the first task queue corresponds to a first current limiter, and the number of tokens applied by the first current limiter to the first token bucket in a first unit time is a first token number; the determination module 502 is specifically used to:
[0099] Determine a first current limiting value of the first token bucket within the first unit time, and determine a remaining current limiting value of the first token bucket within the second unit time; wherein the remaining current limiting value is the difference between a preset total current limiting value and a current limiting value of the token bucket corresponding to a task queue having a higher priority than the first task queue within the second unit time;
[0100] The current limit value of the first token bucket in the second unit time is determined according to the first token number, the first current limit value, and the remaining current limit value.
[0101] In some possible implementations, the determining module 502 is specifically configured to:
[0102] In response to the first token number being greater than or equal to the first current limiting value, the current limiting value of the first token bucket in the second unit time is determined as the smaller value of the following two values: the sum of the first token number and the number of scheduling tokens corresponding to the first unit time, and the remaining current limiting value; wherein the number of scheduling tokens corresponding to the first unit time is the token number adjustment value of the first unit time;
[0103] In response to the first token number being less than the first current limit value, the current limit value of the first token bucket in the second unit time is determined to be the larger value of the following two values: the difference between the first token number and the scheduling token number corresponding to the first unit time, and zero.
[0104] In some possible implementations, the multiple task queues further include a second task queue, the second task queue corresponds to the second token bucket, and the second task queue is the task queue with the lowest priority among the multiple task queues; the determination module 502 is further used to:
[0105] Determine a difference between a remaining current limiting value of the second token bucket in the second unit time and a current limiting value of the second token bucket in the second unit time;
[0106] In response to the difference value being greater than zero, the current limit value of the second token bucket in the second unit time is updated according to the difference value.
[0107] In some possible implementations, the number of scheduling tokens satisfies the following condition: the number of scheduling tokens corresponding to multiple consecutive unit times increases sequentially.
[0108] In some possible implementations, the priority scheduler is distributedly deployed on multiple servers, and the update module 503 is specifically used to:
[0109] The current limiting values within the second unit time are updated to the multiple token buckets through optimistic locking.
[0110] In some possible implementations, the updating module 503 is further configured to:
[0111] In response to a token bucket failure in the plurality of token buckets, preset current limiting values corresponding to the plurality of current limiters are updated to the plurality of current limiters.
[0112] In some possible implementations, the plurality of current limiters include a third current limiter, the third current limiter corresponds to a third task queue, and the third task queue corresponds to a third token bucket; the apparatus 50 further includes a response module, the response module being configured to:
[0113] receiving a first task request within a first unit time; wherein the first task request is used to request processing of a task in the third task queue;
[0114] In response to the number of tokens in the local token library of the third current limiter being not zero, generating a response allowing the first task request based on the tokens in the local token library; wherein the tokens in the local token library are tokens stored locally in the third current limiter;
[0115] In response to the number of tokens in the local token library of the third limiter being zero, applying for a set number of tokens from the third token bucket, performing the following steps: storing the set number of tokens in the local token library, and, based on the tokens in the local token library, generating a response allowing the first task request; wherein the set number is an integer greater than 1;
[0116] In response to the number of tokens in the local token library of the third limiter being zero, and the number of tokens applied for by the third limiter to the third token bucket within the first unit time being greater than the current limiting value of the third token bucket within the first unit time, a response rejecting the first task request is generated.
[0117] It should be noted that the above-mentioned response module may be a module deployed in the third current limiter.
[0118] In some possible implementations, the response module is further configured to:
[0119] In response to a token bucket failure in the plurality of token buckets and the number of tokens in the local token store of the third rate limiter being zero, the third rate limiter generates a response of rejecting the first task request.
[0120] The task processing device 50 according to the embodiment of the present disclosure may correspond to executing the method described in the embodiment of the present disclosure, and the above and other operations and / or functions of each module / unit of the task processing device 50 are respectively to implement Figure 2 For the sake of brevity, the corresponding processes of each method in the illustrated embodiment are not described in detail here.
[0121] The present disclosure also provides an electronic device. The electronic device is specifically used to implement Figure 5 The functions of the task processing device 50 in the illustrated embodiment.
[0122] Figure 6 A schematic diagram of the structure of an electronic device 600 is provided. Figure 6 As shown, the electronic device 600 includes a bus 601, a processor 602, a communication interface 603 and a memory 604. The processor 602, the memory 604 and the communication interface 603 communicate with each other via the bus 601.
[0123] The bus 601 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0124] The processor 602 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0125] The communication interface 603 is used for communicating with the outside. For example, the communication interface 603 can be used for communicating with a terminal.
[0126] The memory 604 may include a volatile memory, such as a random access memory (RAM). The memory 604 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0127] The memory 604 stores executable codes, and the processor 602 executes the executable codes to perform the aforementioned task processing method.
[0128] Specifically, in implementing Figure 5 In the case of the embodiment shown, and Figure 5 When each module or unit of the task processing device 30 described in the embodiment is implemented by software, the execution Figure 5 The software or program code required for the functions of each module / unit in the system may be partially or completely stored in the memory 604. The processor 602 executes the program code corresponding to each unit stored in the memory 604 to perform the aforementioned task processing method.
[0129] The embodiment of the present disclosure also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the task processing method applied to the task processing device 50.
[0130] The embodiment of the present disclosure also provides a computer program product, which includes one or more computer instructions. When the computer instructions are loaded and executed on a computing device, the process or function described in the embodiment of the present disclosure is generated in whole or in part.
[0131] 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 one website, computer or data center to another website, computer or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0132] When the computer program product is executed by a computer, the computer executes any of the aforementioned task processing methods. The computer program product may be a software installation package, and when any of the aforementioned task processing methods is required, the computer program product may be downloaded and executed on the computer.
[0133] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to each embodiment of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.
[0135] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0136] In the context of the disclosed embodiments, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0137] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0138] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0139] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0140] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0141] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A task processing method, characterized in that: Applied to a task processing system, the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities, and multiple token buckets, the priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the multiple current limiters are used to limit the current for task requests of the multiple task queues; the method includes: The priority scheduler respectively obtains the number of tokens applied by the multiple current limiters to the multiple token buckets in the first unit time; The priority scheduler determines the flow limiting values of the multiple token buckets in the second unit time in sequence according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets in the first unit time in the order of the priorities of the multiple task queues from high to low; wherein the second unit time is the next unit time of the first unit time, and the flow limiting value is the number of tokens generated in the second unit time; The priority scheduler updates the current limiting values within the second unit time to the multiple token buckets.
2. The method according to claim 1, characterized in that The multiple task queues include a first task queue, the first task queue corresponds to a first token bucket, the first task queue corresponds to a first current limiter, and the number of tokens applied by the first current limiter to the first token bucket in a first unit time is a first token number; The priority scheduler determines the current limiting values of the multiple token buckets in the second unit time in sequence according to the order of the priorities of the multiple task queues from high to low and according to the number of tokens applied for by the multiple current limiters to the multiple token buckets in the first unit time, including: The priority scheduler determines a first current limiting value of the first token bucket within the first unit time, and determines a remaining current limiting value of the first token bucket within the second unit time; wherein the remaining current limiting value is a difference between a preset total current limiting value and a current limiting value of a token bucket corresponding to a task queue with a priority higher than the first task queue within the second unit time; The priority scheduler determines a current limit value of the first token bucket in the second unit time according to the first token number, the first current limit value, and the remaining current limit value.
3. The method according to claim 2, characterized in that The priority scheduler determines the current limit value of the first token bucket in the second unit time according to the first token number, the first current limit value and the remaining current limit value, including: In response to the first token number being greater than or equal to the first current limiting value, the priority scheduler determines the current limiting value of the first token bucket in the second unit time as the smaller value of the following two values: the sum of the first token number and the number of scheduling tokens corresponding to the first unit time, and the remaining current limiting value; wherein the number of scheduling tokens corresponding to the first unit time is the token number adjustment value of the first unit time; In response to the first token number being less than the first current limiting value, the priority scheduler determines the current limiting value of the first token bucket in the second unit time as the larger of the following two values: the difference between the first token number and the scheduling token number corresponding to the first unit time, and zero.
4. The method according to claim 2, characterized in that: The multiple task queues also include a second task queue, the second task queue corresponds to a second token bucket, and the second task queue is a task queue with the lowest priority among the multiple task queues; the method also includes: The priority scheduler determines a difference between a remaining current limit value of the second token bucket in the second unit time and a current limit value of the second token bucket in the second unit time; In response to the difference value being greater than zero, the priority scheduler updates a current limit value of the second token bucket within the second unit time according to the difference value.
5. The method according to claim 3, characterized in that: The number of scheduling tokens meets the following condition: the number of scheduling tokens corresponding to multiple consecutive unit times increases sequentially.
6. The method according to claim 1, characterized in that The priority scheduler is distributedly deployed on multiple servers, and the priority scheduler updates the current limiting values within the second unit time to the multiple token buckets, including: The priority scheduler updates the current limiting values within the second unit time to the multiple token buckets through optimistic locking.
7. The method according to claim 1, characterized in that The method further comprises: In response to a token bucket failure in the plurality of token buckets, the priority scheduler updates preset current limiting values corresponding to the plurality of current limiters to the plurality of current limiters.
8. The method according to any one of claims 1 to 7, characterized in that: The plurality of current limiters include a third current limiter, the third current limiter corresponds to a third task queue, and the third task queue corresponds to a third token bucket; the method further includes: The third current limiter receives a first task request within a first unit time; wherein the first task request is used to request processing of a task in the third task queue; In response to the number of tokens in the local token library of the third current limiter being not zero, the third current limiter generates a response allowing the first task request based on the tokens in the local token library; wherein the tokens in the local token library are tokens stored locally in the third current limiter; In response to the number of tokens in the local token library of the third limiter being zero, the third limiter applies for a set number of tokens from the third token bucket, and performs the following steps: storing the set number of tokens in the local token library, and, based on the tokens in the local token library, generating a response allowing the first task request; wherein the set number is an integer greater than 1; In response to the number of tokens in the local token library of the third limiter being zero, and the number of tokens applied for by the third limiter to the third token bucket within the first unit time being greater than the limiting value of the third token bucket within the first unit time, the third limiter generates a response to reject the first task request.
9. The method according to claim 8, characterized in that The method further comprises: In response to a token bucket failure in the plurality of token buckets and the number of tokens in the local token store of the third rate limiter being zero, the third rate limiter generates a response of rejecting the first task request.
10. A task processing device, characterized in that: The device is deployed in a task processing system, the task processing system includes a priority scheduler, multiple current limiters, multiple task queues with different priorities and multiple token buckets, the priority scheduler is used to manage the current limiting values of the multiple token buckets, the multiple task queues correspond to the multiple token buckets one-to-one, the multiple current limiters correspond to the multiple task queues one-to-one, and the multiple current limiters are used to limit the current for task requests of the multiple task queues; the device includes: An acquisition module, used for respectively acquiring the number of tokens applied by the multiple current limiters from the multiple token buckets within a first unit time; A determination module, configured to sequentially determine the flow limiting values of the multiple token buckets within a second unit time according to the number of tokens applied for by the multiple flow limiters to the multiple token buckets within a first unit time in the order of the priorities of the multiple task queues from high to low; wherein the second unit time is the next unit time of the first unit time, and the flow limiting value is the number of tokens generated within the second unit time; An updating module is used to update the current limiting value within the second unit time to the multiple token buckets.
11. An electronic device, characterized in that: The electronic device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the electronic device performs the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The method comprises instructions, wherein the instructions instruct an electronic device to execute the method as claimed in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises computer readable instructions for implementing the method according to any one of claims 1 to 9.