Task processing method and device
By acquiring task sequence status and terminal resource information, and dynamically adjusting query frequency and processing strategies, the problem of existing flow limiters being unable to distinguish task priorities is solved. Priority scheduling of task execution and adaptive optimization of resources are realized, improving the system's resource utilization efficiency and task processing stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TUYOO GAMES
- Filing Date
- 2026-02-11
- Publication Date
- 2026-05-29
AI Technical Summary
Existing local rate limiters struggle to differentiate between the priorities of different requests, resulting in an inability to effectively distinguish between important and ordinary tasks in high-concurrency or resource-constrained scenarios, leading to low system resource utilization efficiency.
By acquiring the sequence status information of the task sequence to be processed, and based on the task priority information and the available resource information of the terminal, the query frequency and processing strategy are dynamically adjusted to ensure that high-priority tasks are executed first, and differentiated resource allocation is performed according to the terminal resource status.
It implements priority-based task execution ordering and adaptive resource optimization, which improves the system's resource utilization efficiency during high concurrency and low-peak periods, ensuring the timely processing of important tasks and the stability of the system.
Smart Images

Figure CN122111607A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of task processing technology, and particularly to task processing methods. This application also relates to task processing apparatus, a computing device, and a computer-readable storage medium. Background Technology
[0002] With the development of internet technology, software systems often need to frequently call third-party APIs and access external services during operation. Since third-party APIs or external services usually have limitations on the frequency of calls or the number of concurrent requests, rate limiters are typically used to control the call frequency when performing such restricted operations.
[0003] However, most existing local rate limiters employ fixed rate limiting strategies, making it difficult to differentiate the priorities of different requests and unable to flexibly adjust based on task importance or resource consumption differences. This results in an inability to effectively distinguish between important and ordinary tasks in high-concurrency or resource-constrained scenarios, leading to low system resource utilization efficiency. Therefore, a task processing method is urgently needed to address the problems of existing technologies. Summary of the Invention
[0004] In view of this, embodiments of this application provide a task processing method. This application also relates to a task processing apparatus, a computing device, and a computer-readable storage medium, to solve the aforementioned problems existing in the prior art.
[0005] According to a first aspect of the embodiments of this application, a task processing method is provided, including: Obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed. The current task to be processed is obtained from the sequence of tasks to be processed based on the current query frequency; The target processing strategy for the current task to be processed is determined based on the available resource information corresponding to the terminal, and the current task to be processed is processed according to the target processing strategy.
[0006] According to a second aspect of the embodiments of this application, a task processing apparatus is provided, comprising: The determination module is configured to obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed. The acquisition module is configured to acquire the current task to be processed from the sequence of tasks to be processed based on the current query frequency; The processing module is configured to determine the target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal, and process the current task to be processed according to the target processing strategy.
[0007] According to a third aspect of the embodiments of this application, a computing device is provided, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the above-described task processing method.
[0008] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores a computer program / instructions, which, when executed by a processor, implement the steps of the above-described task processing method.
[0009] The task processing method provided in this application is applied to a terminal and includes: obtaining sequence status information for a sequence of tasks to be processed, and determining a current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed; obtaining the current task to be processed from the sequence of tasks to be processed based on the current query frequency; determining a target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal; and processing the current task to be processed according to the target processing strategy.
[0010] One embodiment of this application implements a task processing method. Since the task order of each task in the task sequence is determined according to the priority of each task, a priority-based task execution order can be achieved, ensuring that tasks with higher priority are executed first. The current query frequency is determined according to the sequence state information. The working state type of the terminal can be determined according to the state of the task sequence and resource consumption can be automatically adjusted. The target processing strategy of the current task can be determined according to the available resource information of the terminal, enabling differentiated resource usage. Through the above method, a priority-based task processing method with adaptive resource optimization is implemented. Attached Figure Description
[0011] Figure 1 This is a schematic diagram of the structure of a task processing method provided in an embodiment of this application; Figure 2 This is a flowchart of a task processing method provided in an embodiment of this application; Figure 3This is a schematic diagram of a processing method for adding tasks to a sequence of tasks according to an embodiment of this application; Figure 4 This is a schematic diagram of a method for determining the current query frequency provided in an embodiment of this application; Figure 5 This is a sequence diagram of a workflow for determining the target processing strategy for a current task to be processed, provided in an embodiment of this application. Figure 6 This is a timing diagram of the workflow of a task processing method applied to a game server, provided in one embodiment of this application; Figure 7 This is a schematic diagram of the structure of a task processing device provided in an embodiment of this application; Figure 8 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation
[0012] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0013] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.
[0014] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0015] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0016] First, the terms and concepts involved in one or more embodiments of this application will be explained.
[0017] Third-party APIs: These can be understood as application interfaces provided by external systems or services outside of this system. Their call frequency, concurrency, or processing capabilities are usually limited and are not directly controlled by this system.
[0018] Local rate limiter or in-process rate limiting: This refers to a rate limiting mechanism deployed within a single application node or process. It is usually implemented based on local memory and is used to limit the number of requests to protect the stable operation of the system.
[0019] Back pressure mechanism: It can be understood as a control mechanism that dynamically adjusts the request sending rate based on the current processing capacity of the system. It guides the request initiator to reduce or restore the request rate by feeding back the load status, thereby avoiding overload of the system or the called service due to excessive load.
[0020] Priority queue: A queue data structure that sorts elements according to the priority of tasks or requests, so that higher priority tasks are processed first.
[0021] In software systems, when it is necessary to call third-party application interfaces, access external services, or perform operations with call frequency limits, it is usually necessary to control the call rate of requests through a rate limiter to prevent the system or the called service from malfunctioning due to excessive load.
[0022] Currently, local rate limiters often use token bucket algorithm, leaky bucket algorithm, or time window-based counting method to implement request control.
[0023] However, with the increasing complexity of business scenarios and the diversification of third-party service call requirements, local rate limiting technology has gradually revealed certain limitations in practical applications. On the one hand, existing solutions typically use uniform rate limiting rules to process requests, making it difficult to distinguish the business priority or importance of different requests during the rate limiting process. When there are many concurrent requests in the system, important requests and ordinary requests are often under the same rate limiting control logic, which may affect the timeliness of response to critical business operations. On the other hand, existing technologies are mostly designed with the number of requests as the main control indicator, failing to adequately consider the differences in computational complexity, data scale, or resource consumption among different requests. A single counting method cannot accurately reflect the actual consumption of system resources or third-party service resources by requests, thus affecting the rationality of resource allocation to some extent.
[0024] Furthermore, rate limiting logic may rely on fixed-frequency scheduling or periodic checking mechanisms to determine whether to allow requests or process waiting queues. When request traffic fluctuates significantly, such mechanisms have limited adaptability to changes in system load. Even when there are few requests, they may continue to perform related checking operations, resulting in resource overhead. Simultaneously, existing local rate limiters typically control request access based on preset parameters, rarely considering the real-time processing capabilities of downstream systems or third-party services. When the response speed of downstream services changes, the rate limiting strategy may still allow requests according to predetermined rules, easily leading to request backlog downstream and affecting the overall system stability.
[0025] Furthermore, requests or tasks are stored using simple queues or linked lists. When more complex scheduling rules are introduced, the queues often need to be traversed or rearranged. As the number of concurrent requests increases, scheduling efficiency and system performance may be affected. Meanwhile, existing solutions primarily use integer frequencies or fixed thresholds for rate limiting parameter configuration. For scenarios requiring more granular call control, there is still room for improvement in the flexibility of parameter configuration.
[0026] Based on the above, existing local rate limiting technologies still require improvement in areas such as request priority differentiation, resource consumption variation characterization, load change awareness, and scheduling flexibility. Therefore, a task processing method is urgently needed to control and schedule requests more flexibly while ensuring system stability.
[0027] This application provides a task processing method, and also relates to a task processing apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0028] See Figure 1 , Figure 1This diagram illustrates a structural schematic of a task processing method according to an embodiment of this application. A timer determines the current sequence type based on the current state information of the task sequence to be processed, determines the sequence state information based on the number of reference states and the current sequence type, and determines the terminal's working state type when the sequence state information reaches a state switching threshold. The current query frequency is determined based on the working state type, and the current task to be processed is retrieved from the task sequence to be processed based on the current query frequency for task scheduling. A target processing strategy for the current task to be processed is determined based on the terminal's available resources (such as the number of slots in the pool). The target processing strategy may include a delay strategy or a sending strategy. The current task to be processed is scheduled and processed according to the target processing strategy. For example, in the case of a sending strategy, the current task to be processed is sent to the caller. The caller processes the task and returns a new task to be processed. A receiving channel receives the task to be processed, determines the position information of the task to be processed based on its priority information, and adds it to the task sequence to be processed based on the position information.
[0029] Using the above methods, for peak periods with a large number of pending tasks, the priority of pending tasks ensures that higher-priority tasks are processed first. The timer ensures that, when the current query frequency is high, backpressure adjustment is performed based on the terminal's available resources and the caller's response time, dynamically limiting the speed at which pending tasks are sent to the caller. For off-peak periods with a small number of pending tasks, priority information ensures that pending tasks can be quickly inserted into the pending task sequence. The timer adjusts the current query frequency to a lower frequency to conserve resources, and backpressure adjustment can quickly release pending tasks, achieving high throughput. When the caller's response speed is slow, newly received pending tasks wait in the pending task sequence according to their priority information. The timer maintains a high query frequency, while the backpressure adjustment mechanism controls the sending speed of pending tasks to the caller based on the caller's real-time processing speed. For pending tasks of different types, the processing method is determined based on the concurrency attributes and priority information of each pending task, and the backpressure adjustment mechanism supports differentiated allocation of available resources.
[0030] Figure 2 A flowchart of a task processing method according to an embodiment of this application is shown, which specifically includes the following steps: Step 202: Obtain the sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed.
[0031] The pending task sequence can be understood as a buffer structure in the local rate limiter used to temporarily store rate-limited but unprocessed pending tasks or task requests. The pending task sequence can be implemented using thread-safe data structures, such as blocking queues and circular queues. Sequence status information can be understood as the running status of the pending task sequence during a preset query period, including the number of pending tasks in the sequence. Current query frequency can be understood as the frequency at which pending tasks are retrieved from the pending task sequence for execution. Pending task order can be understood as the order in which pending tasks are retrieved from the pending task sequence. Priority information can be understood as identifiers representing the importance of each pending task; each pending task can have a preset priority identifier indicating its importance.
[0032] The importance of each pending task usually varies due to differences in task content, task type, and task time limit. Core business or more urgent tasks need to be prioritized. Therefore, the pending tasks can be sorted according to their priority information. Accordingly, the pending task sequence is constructed according to the importance of each pending task.
[0033] The number of pending tasks may be affected by the tidal effect, meaning that user request traffic is uneven in most application scenarios. Specifically, during peak periods, there may be a large number of requests queuing; during off-peak periods, the pending task sequence may be empty for extended periods. If a high query frequency is used to check the pending task sequence when it is empty, it may lead to continuous consumption of hardware resources and significant resource waste. Therefore, the query frequency corresponding to different sequence status information can be determined based on the sequence status information.
[0034] In a specific embodiment provided in this application, sequence status information for a sequence of tasks to be processed is obtained, and the current query frequency is determined based on the sequence status information. The order of each task to be processed in the sequence of tasks to be processed is determined based on the priority information corresponding to each task to be processed.
[0035] Taking a game server as an example, if the sequence of tasks to be processed includes 5 tasks to be processed, then the sequence status information of the sequence of tasks to be processed can be non-empty. Then, the query frequency of non-empty status is determined. The 5 tasks to be processed in the sequence of tasks to be processed are arranged in descending order of priority.
[0036] By constructing a sequence of pending tasks according to their priority information, important requests can be processed first by skipping the queue, thus avoiding the blocking of important or urgent pending tasks by a large number of low-priority requests in the pending task sequence, thereby improving user experience and service quality.
[0037] Meanwhile, the query frequency for retrieving pending tasks is determined based on the sequence status information of the pending task sequence, effectively addressing resource consumption during off-peak periods. However, when the terminal receives new pending tasks, the sequence status information of the pending task sequence changes accordingly, adjusting the query frequency to match the working state. Through this method, the query frequency can be dynamically adjusted based on the sequence status information of the pending task sequence, saving resource consumption.
[0038] In a specific embodiment provided in this application, the sequence of tasks to be processed is constructed by the following method: Receive tasks to be processed and obtain priority information of the tasks to be processed; Based on the priority information of the task to be processed and the priority information of each task to be processed in the sequence of tasks to be processed, the position information of the task to be processed is determined. The task to be processed is added to the task sequence based on the location information.
[0039] Position information can be understood as the insertion position of the currently received task within the sequence of tasks to be processed. Position information ensures that the position of a newly received task within the sequence conforms to its priority order.
[0040] The sequence of tasks to be processed can be constructed using a singly linked list, an unordered linked list, or a heap structure. Preferably, it can be constructed using a singly linked list. In high-concurrency scenarios, a singly linked list does not require traversing the entire sequence of tasks to find the highest priority task for execution each time a task is to be processed, thus achieving higher execution efficiency.
[0041] See Figure 3 , Figure 3This diagram illustrates a method for adding tasks to a task sequence according to an embodiment of this application. The task sequence can be constructed based on a singly linked list. The singly linked list may include a sentinel node, a tail pointer, a task submission channel, and a concurrency control channel. The sentinel node can be understood as the starting position of the singly linked list, does not store data, and is used to simplify boundary handling. The task submission channel is used to receive tasks, and the concurrency control channel is used to process the concurrency attribute information of the tasks. After receiving a task, its priority information is obtained. The task sequence includes at least one node. Starting from the sentinel node, the singly linked list is traversed. It is determined whether the priority information of the current node in the singly linked list is less than the priority information of the task. If it is less, the task is added to the current node; otherwise, it is determined whether there is a next node in the task sequence. If so, the priority information of the next node is determined to be less than the priority information of the task; otherwise, the task is inserted to the tail of the task sequence using the tail pointer.
[0042] In addition, it can also determine the terminal's working state type. If it is in a low-end state, the current query frequency of the timer will be switched to the query frequency of the peak state.
[0043] In a specific embodiment provided in one example of this application, the sequence of tasks to be processed is constructed by the following method: receiving the current task to be processed and obtaining the priority information of the current task to be processed; determining the position information of the task to be processed based on the priority information of the current task to be processed and the priority information of each task to be processed in the sequence of tasks to be processed; and adding the current task to be processed to the sequence of tasks to be processed based on the position information.
[0044] Taking a game server with 4 pending tasks as an example, the current pending task is received, and its priority information is obtained as 3. The priority of the 4 pending tasks in the pending task sequence is 9-7-2-1. Then, the position information of the pending task is determined to be 7-2. The current pending task is added to the pending task sequence, and the corresponding priority sequence of the pending task sequence is 9-7-3-2-1.
[0045] Adjusting the sequence of tasks by prioritizing them ensures that tasks are ordered according to their priority, guaranteeing that higher-priority tasks are executed first. Furthermore, the sequence can be dynamically updated and adjusted based on the priority of newly arriving tasks. While the computational complexity of this method varies across different scenarios, it effectively maintains the ordered arrangement of tasks by priority and reduces unnecessary traversal operations in common scenarios, thereby improving the overall scheduling efficiency of the rate limiting mechanism in high-concurrency task scenarios.
[0046] In a specific embodiment provided in this application, the location information of the task to be processed is determined based on the priority information of the task to be processed and the priority information of each task to be processed in the sequence of tasks to be processed, including: If a subsequence of tasks corresponding to the priority information of the task to be processed exists in the sequence of tasks to be processed, the position information of the task to be processed is determined as the starting position of the subsequence of tasks to be processed.
[0047] A subsequence of tasks to be processed can be understood as a sequence of tasks with the same priority information within the overall sequence of tasks to be processed. The starting position can be understood as the initial position of the subsequence of tasks to be processed.
[0048] If the priority information of multiple pending tasks in the pending task sequence is the same as that of a newly arrived pending task, the insertion position of the newly arrived pending task needs to be determined according to the preset insertion rules. The preset insertion rules can be inserted at the beginning, end, or middle of the pending task sequence, depending on the application scenario or the characteristics of the pending task. Here, the preset insertion rules are not limited.
[0049] In a specific embodiment provided in this application, when there is a subsequence of tasks to be processed corresponding to the priority information of the tasks to be processed in the sequence of tasks to be processed, the position information of the tasks to be processed is determined as the starting position of the subsequence of tasks to be processed.
[0050] Taking a game server's pending task sequence with a priority of 5-3-3-1 as an example, if a newly arrived pending task has a priority of 3 and a pending task subsequence of 3-3, then the position of the newly arrived pending task can be placed to the left of 3-3, i.e., the initial position of the sequence, and the resulting pending task sequence can be 5-3-3-3-1.
[0051] Using the above method, when there are multiple pending tasks with the same priority information, the pending tasks can be added to the pending task sequence according to preset rules, ensuring that the insertion of newly arrived pending tasks conforms to the priority sorting rules.
[0052] In a specific embodiment provided in this application, obtaining sequence state information for a sequence of tasks to be processed, and determining the current query frequency based on the sequence state information, includes: The current sequence type of the task sequence to be processed is determined based on the current status information of the task sequence to be processed; Based on the current sequence type and the number of reference states of the task sequence to be processed, determine the sequence state information of the task sequence to be processed, and update the number of reference states; The working state type of the terminal is determined based on the sequence state information and the state switching threshold, and the current query frequency is determined based on the working state type.
[0053] The current status information can be understood as the running status of the currently queried sequence of tasks to be processed. The current sequence type can include non-empty and empty types. Correspondingly, a non-empty type means that the sequence contains at least one task to be processed, while an empty type means that the sequence does not contain any tasks to be processed. The reference status count can be understood as the number of consecutive occurrences or statistical results of empty sequences in the historical query sequence of tasks to be processed. The reference status count can be obtained by counting using a counter. The status switching threshold is a preset number used to switch working states. When the reference status count reaches the preset number, it indicates that the sequence of tasks to be processed is empty for a preset number of queries, and the system is in a low period. At this time, user request traffic is low, and the terminal's working state type can be switched to idle state.
[0054] In most application scenarios, the volume of user requests is uneven, categorized into peak and off-peak periods. The query frequency for retrieving pending tasks can be adjusted during different periods. The determination of peak and off-peak periods can be based on sequence status information. If the queue of pending tasks is empty in a preset continuous query, it indicates that the system is currently in a low-traffic period, and the query frequency can be adjusted accordingly. The query frequency can be set according to the needs of the application scenario and is not limited here.
[0055] See Figure 4 , Figure 4A schematic diagram of a method for determining the current query frequency is shown. The terminal's working state type can include peak state and valley state. Peak state is applied to scenarios with pending tasks, resulting in a higher current query frequency and greater resource consumption. Valley state is a resource-efficient processing mode. Switching between working state types can be achieved by querying whether the pending task sequence is empty. When the sequence status information reaches the state switching threshold, it indicates that the pending task sequence is empty for a certain period, thus the terminal's working state type can be switched to valley state. When pending tasks arrive, it switches back to peak state. The current status information indicates whether the pending task sequence is empty in the current state. The current status information can be statistically counted and updated using a reference status count. After reaching the state switching threshold, the working state type is switched, and the current query frequency is adjusted accordingly.
[0056] In one specific embodiment of this application, obtaining sequence status information for a sequence of tasks to be processed and determining the current query frequency based on the sequence status information includes: determining the current sequence type of the task sequence to be processed based on the current status information of the task sequence to be processed; determining the sequence status information of the task sequence to be processed based on the current sequence type and the number of reference states of the task sequence to be processed, and updating the number of reference states; determining the working state type of the terminal based on the sequence status information and a state switching threshold, and determining the current query frequency based on the working state type.
[0057] Taking a state transition threshold of 10 times as an example, if the current state information of the task sequence to be processed is 0 tasks, then the current sequence type of the task sequence to be processed is empty. If the reference state count is 9, then the state information of the task sequence to be processed is idle, and the reference state count is updated to 10. Therefore, the terminal's working state type is a low-end state, and the query frequency in this case is 5 times per second. If the terminal's working state type is a peak state, the query frequency in this case is 10 times per second.
[0058] By adaptively adjusting the query frequency, resource consumption can be reduced in large-scale application scenarios by decreasing the query frequency during off-peak or idle periods.
[0059] Step 204: Obtain the current task to be processed from the sequence of tasks to be processed based on the current query frequency.
[0060] The currently pending task can be understood as the highest priority task in the pending task sequence, which can be understood as the task that the terminal plans to process or send to a downstream third party.
[0061] The current query frequency is determined based on the work status type. Tasks are retrieved according to different query frequencies for subsequent processing.
[0062] In one specific embodiment of this application, the current task to be processed is obtained from the sequence of tasks to be processed based on the current query frequency.
[0063] Taking a sequence of tasks with a priority of 5-3-3-1 as an example, the peak query frequency is 10 times per second. Based on the above query frequency, the task with priority of 5 is selected as the current task and retrieved.
[0064] Determining the query frequency based on system status and retrieving the highest priority pending tasks according to the query frequency can reduce unnecessary resource consumption, and prioritize the processing of more important pending tasks, thereby improving the flexibility of task processing.
[0065] Step 206: Determine the target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal, and process the current task to be processed according to the target processing strategy.
[0066] The available resource information of a terminal can be understood as the status information of the terminal's ability to carry out or execute tasks to be processed in the current or future period of time. Available resource information can be used to characterize the resources required for the terminal to execute the current task to be processed, and can be determined based on the number of available slots, slot occupancy, or the corresponding task execution status. The target processing strategy can be understood as the processing strategy for the task to be processed, which may include sending the task to a third party or delaying it.
[0067] Available resource information can characterize the terminal's ability to carry or execute pending tasks. To ensure the stability of the terminal and the system, different processing strategies are executed under different system states to ensure that the processing of pending tasks is always within the terminal's carrying capacity.
[0068] In a specific embodiment provided in this application, the target processing strategy for the current task to be processed is determined based on the available resource information corresponding to the terminal, and the current task to be processed is processed according to the target processing strategy.
[0069] Taking a game server as an example, obtain the available resource information of the game server, determine the target processing strategy for the current task based on the game server's current capacity to support or execute the task to be processed, and process the current task according to the target processing strategy.
[0070] By combining the terminal's carrying capacity to determine the execution strategy of the current tasks to be processed, the scheduling and execution of tasks can be matched with the actual resource status of the terminal, avoiding problems such as task blocking, execution delay or failure caused by allocating tasks when terminal resources are insufficient, and improving the stability of task processing and scheduling.
[0071] In a specific embodiment provided in this application, determining the target processing strategy for the currently pending task based on the available resource information corresponding to the terminal includes: The preset period threshold of the current task to be processed is determined based on the concurrency attribute information of the current task to be processed. The waiting period information of the currently pending tasks is statistically analyzed. If the waiting period information is greater than or equal to the preset period threshold, the processing status information of the terminal is determined based on the available resource information and the concurrency attribute information. The target processing strategy for the current task to be processed is determined based on the processing status information.
[0072] Concurrency attribute information can be understood as cost information required to execute the current pending task. It can be the traffic multiplier information for processing the current pending task, or it can be understood as the resource consumption required to process the current pending task. The preset period threshold can be understood as the preset duration that the current pending task needs to wait. The waiting period information can be understood as the actual duration that the current pending task has waited. The processing status information can be understood as the load status of the terminal, and can be used to characterize whether the current pending task has been processed.
[0073] Assuming all pending tasks incur the same cost leads to an unreasonable allocation of available resources, with lightweight tasks being overwhelmed by heavyweight ones, resulting in a decrease in overall system throughput. In reality, the resource consumption costs differ depending on the task type. For example, batch query tasks require more computing resources than single-word query tasks, and computational tasks require more time than query tasks. Furthermore, the bandwidth usage varies depending on the file size being uploaded.
[0074] Therefore, the computational resources required to execute the current pending task can be represented based on the concurrency attribute information. For resources with high concurrency attributes, an additional preset periodic threshold can be set as the waiting time for the current pending task. After the actual waiting time of the current pending task reaches the preset periodic threshold, it can be further determined whether the current load of the terminal supports the execution of the current pending task.
[0075] When multiple interfaces exist on the terminal, the rate limiting frequency of each interface varies. The traffic multiplier information can be determined based on the ratio of the rate limiting of the interface with the fastest response to the rate limiting of the interface with the slowest response. In cases where there are slow-responding requests in the business, the concurrency attribute information can prevent long-time requests from causing system overload.
[0076] In a specific embodiment provided in this application, determining the target processing strategy for the currently pending task based on the available resource information corresponding to the terminal includes: determining a preset period threshold for the currently pending task based on the concurrency attribute information of the currently pending task; statistically analyzing the waiting period information of the currently pending task; and, if the waiting period information is greater than or equal to the preset period threshold, determining the processing status information of the terminal based on the available resource information and the concurrency attribute information; and determining the target processing strategy for the currently pending task based on the processing status information.
[0077] The preset period threshold can be set according to the needs of the application scenario. In a specific embodiment provided in this application, the preset period threshold can be determined based on the product of concurrency attribute information and fixed parameters. For example: If the concurrency attribute information is 1, then no additional waiting period is required; If the concurrency attribute information is 2, then it will take 2 × 10 = 20 waiting cycles before execution; If the concurrency attribute information is 3, then it will take 3 × 10 = 30 waiting cycles before execution.
[0078] In the example above, tasks with a concurrency attribute greater than 1 are considered to have a high traffic multiplier. In practical applications, the criteria for judging tasks with a high traffic multiplier can be set according to the actual needs of the application scenario, and are not limited here.
[0079] If the waiting period meets the preset period threshold, the processing status information of the terminal is determined based on the available resource information and the concurrency attribute information of the current pending task.
[0080] By introducing concurrency attribute information, a dual control mechanism based on the traffic multiple of the current pending task can be implemented. Determining the preset waiting time of the current pending task based on the traffic multiple information can ensure that tasks with high traffic multiples wait for a sufficiently long time interval. After the waiting time interval is met, the load status of the terminal is judged based on the available resources of the terminal, so as to avoid the current pending task with a high traffic multiple from being executed when the system load is high, thus avoiding overload.
[0081] In a specific embodiment provided in this application, determining the processing status information of the terminal based on the available resource information and the concurrency attribute information includes: Obtain the total capacity information and the current occupancy information of the terminal; The available resource information of the terminal is determined based on the current occupancy information and the concurrency attribute information; The processing status information of the terminal is determined based on the available resource information and the total capacity information.
[0082] Total capacity information can be understood as the terminal's concurrent carrying capacity, which is the upper limit of the terminal's ability to simultaneously handle and execute tasks within the same time period. It can also be used to characterize the number of processing slots that the terminal can allocate to pending tasks, and can be the number of slots pre-set by the system. Correspondingly, current occupancy information can be understood as characterizing the concurrent carrying capacity of the terminal currently occupied by tasks. Current occupancy information can correspond to the number of slots that have been allocated and are currently occupied.
[0083] Based on the terminal's current occupancy information and concurrency attribute information, the terminal's system load status at the current moment can be determined as available resource information. Then, it is determined whether the available resource information exceeds the terminal's total capacity information to determine the terminal's processing status information. The terminal's processing status information can be used to determine whether the currently pending task is allowed to be executed.
[0084] In a specific embodiment provided in this application, determining the processing status information of the terminal based on the available resource information and the concurrency attribute information includes: obtaining the total capacity information of the terminal and the current occupancy information of the terminal; determining the available resource information of the terminal based on the current occupancy information and the concurrency attribute information; and determining the processing status information of the terminal based on the available resource information and the total capacity information.
[0085] Taking the slot capacity as the representation of total capacity information, and taking the concurrent attribute information of the current task to be processed as 4 as an example, the total capacity information of the terminal is obtained as 10, and the current occupied information is 3. Then the available resource information = 3 × 4, and the available resource information is 12. The processing status information of the terminal is determined based on the judgment of the available resource information and the total capacity information.
[0086] Available resource information reflects the resources required to execute the current task. If the available resource information is high, it indicates that the current task requires a lot of resources. In this case, by comparing the total terminal capacity information and the available resource information, we can avoid executing the current task with a high traffic volume when the system is under high load, thus avoiding overload and improving the stable operation of task processing.
[0087] In one specific embodiment provided in this application, the processing status information includes an occupied status and an idle status; Determining the target processing strategy for the current task to be processed based on the processing status information includes: If the processing status information is in an occupied state, the target processing strategy for the currently pending task is determined to be a delay strategy. If the processing status information is in an idle state, the target processing strategy for the current task to be processed is determined to be a sending strategy.
[0088] The occupied state can be understood as the current terminal's concurrent carrying capacity has been allocated or consumed to a predetermined threshold, and the terminal has no available processing slots for executing new tasks. Correspondingly, the delay strategy can be understood as a processing strategy that, when the terminal's processing capacity is insufficient to immediately execute the current task to be processed, limits, delays, or prevents the current task to be processed from being sent downstream, thereby slowing down the task input rate and preventing terminal overload. The idle state can be understood as the current terminal's concurrent carrying capacity is not fully occupied, and there is still at least one available processing slot for executing new tasks. Correspondingly, the sending strategy can be understood as a processing strategy that, when the terminal has available processing capacity, directly sends the current task to be processed to the downstream or execution unit for processing.
[0089] By acquiring the terminal's processing status information, it is determined whether the terminal currently has available concurrent processing capacity. When the processing status information is in an occupied state, it indicates that the terminal's current concurrent capacity is occupied and it does not have the ability to immediately process new tasks; when the processing status information is in an idle state, it indicates that the terminal still has at least a portion of available concurrent capacity and can handle new task processing requests. Based on the above determination results, different target processing strategies are matched to the currently pending tasks, thereby achieving adaptive adjustment of the task inflow rate and the terminal's processing capacity.
[0090] In one specific embodiment provided in this application, the processing status information includes an occupied status and an idle status; Determining the target processing strategy for the current task to be processed based on the processing status information includes: If the processing status information is in an occupied state, the target processing strategy for the currently pending task is determined to be a delay strategy. If the processing status information is in an idle state, the target processing strategy for the current task to be processed is determined to be a sending strategy.
[0091] When employing a delay strategy, the operations that can be performed on the currently pending task include temporarily storing it in a local pending queue, delaying its transmission downstream, returning a busy or rate-limiting message, and waiting for the processing status to change from occupied to idle before execution. When employing a sending strategy, the currently pending task can be sent, scheduled, or executed immediately, and the corresponding concurrent capacity will be released after the task is completed. Specific implementation methods for different target processing strategies can be set according to the needs of the actual application scenario and are not limited here.
[0092] See Figure 5 , Figure 5 This diagram illustrates a workflow sequence diagram for determining a target processing strategy for a currently pending task according to an embodiment of this application. The task processing method can be applied to the rate limiting mechanism of a game server. The caller sends multiple pending tasks to a third-party service through a local rate limiter. The rate limiter internally has a slot pool with multiple processing slots to limit the number of tasks sent to the third-party service simultaneously. Each slot represents the number of concurrently processed execution slots, allocated by the rate limiter before the task is sent and released after the task is processed.
[0093] When the caller initiates the current pending task 1, the rate limiter detects that there are idle slots in the slot pool. Therefore, the current processing status is idle, and the target processing strategy is the send strategy. Thus, slot 1 is allocated to the current pending task 1, and the task request 1 of the current pending task 1 is sent to a third-party service for processing. After the current pending task 1 is processed, the occupied slot 1 is released. Subsequently, when the caller initiates the current pending task 2, the rate limiter similarly allocates slot 2 to the current pending task 2 and sends it to a third-party service. After task 2 is processed, slot 2 is released.
[0094] When the caller continuously initiates pending tasks 3 through 10, the rate limiter sequentially allocates corresponding free slots to each pending task and sends them to a third-party service for processing. During this process, multiple pending tasks can be sent and processed concurrently, and each processing slot is released sequentially after the corresponding task is completed.
[0095] When the caller continues to initiate the current pending task 11, the rate limiter detects that all processing slots are currently occupied. Therefore, the current processing status is occupied. In this occupied state, the rate limiter cannot allocate a new processing slot to the current pending task 11. Therefore, the target processing strategy for the current pending task 11 is determined to be a delay strategy, so that the current pending task 11 is not sent to the third-party service for the time being.
[0096] As the third-party service completes processing the previous task, the corresponding processing slot is released. Upon detecting the existence of an idle processing slot, the rate limiter switches the processing status from occupied to idle and allocates the released processing slot to the currently waiting task 11, thereby sending the currently waiting task 11 to the third-party service for processing. After the currently waiting task 11 completes processing, the processing slot it occupied is released.
[0097] By using the above method, concurrent sending of currently pending tasks is allowed when there are enough processing slots, and task sending is restricted by a delay strategy when processing slots are full. This achieves dynamic control over the task sending process, avoids overloading of third-party services due to excessive concurrent requests, and improves the stability and reliability of system operation.
[0098] In a specific embodiment provided in this application, processing the currently pending task according to the target processing strategy includes: Acquire downstream status information, wherein the downstream status information is determined based on the response time of the downstream system; The response status information of the terminal is determined based on the downstream status information; The current task to be processed is processed based on the response status information and the target processing strategy.
[0099] Downstream status information can be understood as a description of the current processing load or processing capacity consumption of a downstream system. This information can be from a third-party API, reflecting its current processing pressure. Downstream status information can be determined based on the downstream system's response latency, request failure rate or abnormal return ratio, rate limiting or response rejection, the number of concurrent requests, or the processing queue length or queuing status. Therefore, the method for determining downstream status information can be customized based on project characteristics or application scenarios, and is not limited here. Response status information can be understood as the actual speed at which the terminal sends task requests for currently pending tasks to the downstream system.
[0100] When sending task requests for currently pending tasks to downstream systems, sending requests at a fixed rate ignores the actual processing capacity of the downstream systems. As the response speed of the downstream systems slows down, task requests will accumulate. If the queues of the downstream systems overflow, overload will occur, causing a large number of task request failures and impacting service quality. It could even lead to a cascading failure, causing the downstream systems to crash completely. Therefore, the current processing capacity of the downstream systems can be obtained based on their status information, and the rate at which task requests are sent to the downstream systems can be dynamically adjusted according to their actual status to prevent system overload.
[0101] In a specific embodiment provided in this application, processing the current task to be processed according to the target processing strategy includes: obtaining downstream status information, wherein the downstream status information is determined based on the response time of the downstream system; determining the response status information of the terminal based on the downstream status information; and processing the current task to be processed based on the response status information and the target processing strategy.
[0102] Taking the determination of downstream status information based on the response latency of the downstream system as an example, the actual speed at which the terminal sends the currently pending task to the downstream system can be determined based on the response latency of the downstream system, and the task request for the currently pending task can be sent to the downstream system based on the actual speed and the target processing strategy for the currently pending task.
[0103] By introducing downstream status information, the current workload of the downstream system can be perceived, enabling the terminal to dynamically adjust the sending speed according to the downstream processing capacity. This avoids continuously sending requests when the downstream system is under high load, thereby reducing the call failure rate, reducing retry overhead, improving the overall system stability, and increasing the success rate of third-party service calls.
[0104] In a specific embodiment provided in this application, determining the terminal's response status information based on the downstream status information includes: Obtain downstream status information and determine the slot release speed based on the downstream status information; The response status information is determined based on the slot release speed and the preset release speed.
[0105] The slot release speed can be understood as the actual sending speed at which the terminal sends the task request for the currently pending task from the slot to the downstream, while the preset release speed can be understood as the theoretical sending speed at which the terminal sends the task request for the currently pending task from the slot to the downstream.
[0106] By acquiring downstream status information, the current processing load of the downstream system is perceived, and the sending behavior of the currently pending tasks is dynamically adjusted based on the downstream status information, thereby forming a negative feedback adjustment mechanism between the task sending side and the actual processing capacity of the downstream system.
[0107] Specifically, when the processing load of the downstream system increases, the downstream status information reflects an increase in response latency, an increase in failure rate, or the occurrence of rate limiting responses. This downstream status information, as a feedback signal, is used to suppress the sending behavior of currently pending tasks, reducing or delaying task requests for currently pending tasks sent to the downstream system. When the processing load of the downstream system decreases, the downstream status information reflects a decrease in response latency or an increase in processing success rate. This downstream status information, as a feedback signal, is used to restore or enhance the sending behavior of currently pending tasks. In this way, the task sending speed of currently pending tasks is adjusted inversely with the change in the processing load of the downstream system, thus constituting a backpressure regulation principle based on downstream status information.
[0108] In a specific embodiment provided in this application, determining the response status information of the terminal based on the downstream status information includes: acquiring the downstream status information; determining the slot release speed based on the downstream status information; and determining the response status information based on the slot release speed and a preset release speed.
[0109] Taking a preset release rate of 10 times / second as an example, the task processing status of the downstream system is obtained as the downstream status information. Based on the downstream status information, the slot release rate of the terminal to release task requests to the downstream system is determined. By comparing 10 times / second with the slot release rate, the actual speed at which the task to be processed is sent to the downstream system can be determined as the response status information.
[0110] By employing the aforementioned backpressure adjustment mechanism, task sending behavior can adaptively adjust according to the real-time processing capacity of downstream systems. This avoids continuously applying request pressure to downstream systems when their load is high, thereby reducing the probability of request failures and timeouts, and minimizing invalid retries and resource waste. Simultaneously, when the downstream system load is low, task sending can be resumed promptly, fully utilizing downstream processing capacity, improving overall task processing efficiency and system throughput, and ultimately enhancing the system's stability and robustness in high-concurrency scenarios.
[0111] In a specific embodiment provided in this application, determining the response state information based on the slot release speed and a preset release speed includes: If the slot release speed is greater than or equal to the preset release speed, the response status information is determined based on the preset release speed. If the slot release speed is less than the preset release speed, the response status information is determined based on the slot release speed.
[0112] The task completion status is quantitatively characterized by monitoring the slot release speed, and the slot release speed is compared with a preset release speed to generate response status information reflecting changes in downstream processing capacity. When the slot release speed is greater than or equal to the preset release speed, it indicates that the current task processing progress is not lower than expected, and the downstream service has stable or sufficient processing capacity. In this case, the response status information is determined based on the preset release speed to avoid frequent status changes due to instantaneous fluctuations. When the slot release speed is less than the preset release speed, it indicates that the task processing progress is lower than expected, and the downstream service processing capacity is declining. In this case, the response status information is determined based on the slot release speed so that the response status information can reflect the declining trend of downstream processing capacity in a timely manner.
[0113] By using the above methods, the response status information can maintain a stable reference value when the downstream system has sufficient processing capacity, and can change with the actual processing speed when the processing capacity decreases, thereby achieving adaptive perception of the downstream processing status.
[0114] In a specific embodiment provided in this application, determining the response status information based on the slot release speed and a preset release speed includes: determining the response status information based on the preset release speed when the slot release speed is greater than or equal to the preset release speed; and determining the response status information based on the slot release speed when the slot release speed is less than the preset release speed.
[0115] Taking a preset release rate of 10 times / second as an example, if the downstream status information (response time) is 50ms, the slot release rate is 20 times / second. Since the slot release rate is greater than the preset release rate, the preset release rate is used as the response status information in this case. If the downstream status information (response time) is 500ms, the slot release rate is 2 times / second. Since the slot release rate is less than the preset release rate, the slot release rate is used as the response status information in this case.
[0116] By comparing the slot release rate with a preset release rate to generate response status information, the system can dynamically perceive downstream processing capacity based on changes in task completion rate, avoiding misjudgments caused by relying solely on fixed thresholds to determine downstream status. When the slot release rate is not lower than the preset release rate, the response status information is generated based on the preset release rate, effectively suppressing frequent state switching caused by short-term jitter and improving system stability. When the slot release rate is lower than the preset release rate, the response status information changes with the actual slot release rate, promptly reflecting the decline in downstream processing capacity, thereby triggering rate limiting or backpressure strategies in advance and reducing the risk of request backlog and call failures.
[0117] By employing the above methods, backpressure adjustment of the relationship between task processing rate and downstream processing capacity is achieved, enabling the task sending strategy to adaptively adjust according to changes in downstream processing capacity, thereby improving the stability, reliability, and overall processing efficiency of the system under high concurrency and load fluctuation scenarios.
[0118] One embodiment of this application implements a task processing method. Since the task order of each task in the task sequence is determined according to the priority of each task, it can support task priority for task processing, ensuring that important tasks are executed first. The current query frequency is determined according to the sequence status information, and resource consumption can be automatically adjusted according to the status of the task sequence. The target processing strategy of the current task is determined according to the available resource information of the terminal, which can realize differentiated resource occupation. Through the above method, a task processing method based on priority scheduling and adaptive resource optimization is realized.
[0119] The following is in conjunction with the appendix Figure 6 Taking the application of the task processing method provided in this application in a game server as an example, the task processing method will be further explained. Figure 6 The diagram illustrates a workflow timing diagram of a task processing method applied to a game server according to an embodiment of this application.
[0120] The scheduling process is applied to the rate-limiting mechanism of the game server's local rate limiter. The caller sends pending tasks to a third-party service through the local rate limiter in the game server. The local rate limiter is used to schedule and process the pending tasks under limited processing resources. The local rate limiter internally sets up a pending task queue, a slot pool, and a timed triggering mechanism. The slot pool includes multiple processing slots to limit the number of tasks sent to the third-party service simultaneously.
[0121] When the rate limiter receives a pending task from the caller, it adds the task to the pending task queue and obtains the priority information corresponding to the task. Based on the priority information, it inserts the task into the corresponding position in the queue. Subsequently, during scheduling, a timer is used to obtain the current status information of the pending task queue based on the current query frequency. The current status information includes the current queue type and the number of pending tasks in the queue. The current query frequency is determined based on the current status information.
[0122] During scheduling, the rate limiter retrieves the currently pending task from the queue of pending tasks and obtains the corresponding concurrency attribute information. Simultaneously, it retrieves the currently available resource information from the slot pool. If there are idle processing slots in the slot pool, the rate limiter occupies the corresponding processing slot and, based on the concurrency attribute information and the currently available resource information, determines the target processing strategy for the currently pending task as the sending strategy, thereby sending the task request of the currently pending task to a third-party service for processing. After the currently pending task is processed, the rate limiter releases the processing slot occupied by the currently pending task and continues the scheduling process to retrieve the next pending task from the queue for processing.
[0123] If there are no available slots in the slot pool, the rate limiter determines the current processing status as occupied and sets the target processing strategy for the currently pending task to a delay strategy, preventing the task from being sent to the third-party service. When a processing slot in the slot pool is released, the rate limiter detects the change in the current processing status from occupied to idle and allocates the released processing slot to the waiting task, thereby sending the task to the third-party service for processing.
[0124] One embodiment of this application implements a task processing method. Since the order of each task in the task sequence is determined according to its priority, it can support task priority and ensure that important tasks are executed first. The current query frequency is determined according to the sequence status information, and resource consumption can be automatically adjusted according to the status of the task sequence. The target processing strategy for the current task is determined according to the available resource information of the terminal, and differentiated resource usage can be achieved. The above method realizes a task processing method based on priority scheduling and adaptive resource optimization.
[0125] Corresponding to the above method embodiments, this application also provides a task processing apparatus embodiment. Figure 7 A schematic diagram of the structure of a task processing device according to an embodiment of this application is shown. Figure 7 As shown, the device includes: The determination module 702 is configured to obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed. The acquisition module 704 is configured to acquire the current task to be processed from the sequence of tasks to be processed based on the current query frequency; The processing module 706 is configured to determine the target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal, and process the current task to be processed according to the target processing strategy.
[0126] One embodiment of this application implements a task processing device. Since the order of each task in the sequence of tasks to be processed is determined according to the priority of each task, it can support task priority and ensure that important tasks are executed first. The current query frequency is determined according to the sequence status information, and resource consumption can be automatically adjusted according to the status of the sequence of tasks to be processed. The target processing strategy of the current task to be processed is determined according to the available resource information of the terminal, and differentiated resource occupation can be achieved. Through the above method, a task processing method based on priority scheduling and adaptive resource optimization is realized.
[0127] The above is an illustrative scheme of a task processing device according to this embodiment. It should be noted that the technical solution of this task processing device and the technical solution of the task processing method described above belong to the same concept. For details not described in detail in the technical solution of the task processing device, please refer to the description of the technical solution of the task processing method described above.
[0128] Figure 8 A structural block diagram of a computing device 800 according to an embodiment of this application is shown. The components of the computing device 800 include, but are not limited to, a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and a database 850 is used to store data.
[0129] The computing device 800 also includes an access device 840, which enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 840 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0130] In one embodiment of this application, the aforementioned components of the computing device 800 and Figure 8 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 8 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0131] The computing device 800 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 800 can also be a mobile or stationary server.
[0132] The processor 820 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the above-described task processing method.
[0133] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the task processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the task processing method described above.
[0134] An embodiment of this specification also provides a computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the task processing method described above.
[0135] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the task processing method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the task processing method described above.
[0136] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0137] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0138] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0139] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0140] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A task processing method, characterized in that, Applied to terminals, including: Obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed. The current task to be processed is obtained from the sequence of tasks to be processed based on the current query frequency; The target processing strategy for the current task to be processed is determined based on the available resource information corresponding to the terminal, and the current task to be processed is processed according to the target processing strategy.
2. The method as described in claim 1, characterized in that, The sequence of tasks to be processed is constructed using the following method: Receive tasks to be processed and obtain priority information of the tasks to be processed; Based on the priority information of the task to be processed and the priority information of each task to be processed in the sequence of tasks to be processed, the position information of the task to be processed is determined. The task to be processed is added to the task sequence based on the location information.
3. The method as described in claim 2, characterized in that, Based on the priority information of the task to be processed and the priority information of each task in the task sequence, the location information of the task to be processed is determined, including: If a subsequence of tasks corresponding to the priority information of the task to be processed exists in the sequence of tasks to be processed, the position information of the task to be processed is determined as the starting position of the subsequence of tasks to be processed.
4. The method as described in claim 1, characterized in that, Obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, including: The current sequence type of the task sequence to be processed is determined based on the current status information of the task sequence to be processed; Based on the current sequence type and the number of reference states of the task sequence to be processed, determine the sequence state information of the task sequence to be processed, and update the number of reference states; The working state type of the terminal is determined based on the sequence state information and the state switching threshold, and the current query frequency is determined based on the working state type.
5. The method as described in claim 1, characterized in that, Determine the target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal, including: The preset period threshold of the current task to be processed is determined based on the concurrency attribute information of the current task to be processed. The waiting period information of the currently pending tasks is statistically analyzed. If the waiting period information is greater than or equal to the preset period threshold, the processing status information of the terminal is determined based on the available resource information and the concurrency attribute information. The target processing strategy for the current task to be processed is determined based on the processing status information.
6. The method as described in claim 5, characterized in that, The processing status information of the terminal is determined based on the available resource information and the concurrency attribute information, including: Obtain the total capacity information and the current occupancy information of the terminal; The available resource information of the terminal is determined based on the current occupancy information and the concurrency attribute information; The processing status information of the terminal is determined based on the available resource information and the total capacity information.
7. The method as described in claim 5, characterized in that, The processing status information includes occupied status and idle status; Determining the target processing strategy for the current task to be processed based on the processing status information includes: If the processing status information is in an occupied state, the target processing strategy for the currently pending task is determined to be a delay strategy. If the processing status information is in an idle state, the target processing strategy for the current task to be processed is determined to be a sending strategy.
8. The method as described in claim 1, characterized in that, Processing the current task to be processed according to the target processing strategy includes: Acquire downstream status information, wherein the downstream status information is determined based on the response time of the downstream system; The response status information of the terminal is determined based on the downstream status information; The current task to be processed is processed based on the response status information and the target processing strategy.
9. The method as described in claim 8, characterized in that, The response status information of the terminal is determined based on the downstream status information, including: Obtain downstream status information and determine the slot release speed based on the downstream status information; The response status information is determined based on the slot release speed and the preset release speed.
10. The method as described in claim 9, characterized in that, The response status information is determined based on the slot release speed and the preset release speed, including: If the slot release speed is greater than or equal to the preset release speed, the response status information is determined based on the preset release speed. If the slot release speed is less than the preset release speed, the response status information is determined based on the slot release speed.
11. A task processing device, characterized in that, include: The determination module is configured to obtain sequence status information for the sequence of tasks to be processed, and determine the current query frequency based on the sequence status information, wherein the order of each task to be processed in the sequence of tasks to be processed is determined according to the priority information corresponding to each task to be processed. The acquisition module is configured to acquire the current task to be processed from the sequence of tasks to be processed based on the current query frequency; The processing module is configured to determine the target processing strategy for the current task to be processed based on the available resource information corresponding to the terminal, and process the current task to be processed according to the target processing strategy.
12. A computing device, characterized in that, include: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 10.
13. A computer-readable storage medium storing a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 10.