Task scheduling method and device, electronic equipment and storage medium
By implementing a task scheduling method on the financial database server, the targets are reasonably selected based on the current and historical resource occupancy data of the database, the problem of database resource spikes in high concurrency scenarios is solved and the stability of financial services is improved.
Patent Information
- Application Number
- CN202411582425.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-28
AI Technical Summary
In a highly concurrent financial data processing scenario, when multiple resource-intensive tasks are executed concurrently, it will cause spikes in database resource indicators, which may cause database downtime and affect the continuity and stability of financial services.
A task scheduling method is proposed. By responding to the addition of the task to be executed, the current resource occupancy data of the database and the historical resource occupancy data of each alternative task in the task queue are obtained, and the target execution task is determined according to the preset resource occupancy threshold to avoid resource overload.
It effectively avoids database resource occupancy exceeding the security threshold, reduces service interruptions and performance degradation caused by resource problems, and improves the continuity and stability of financial services.
Smart Images

Figure CN119536939A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, is applicable to the field of financial technology, and particularly relates to a task scheduling method and device, an electronic device, and a storage medium. Background Art
[0002] At present, in various business systems, databases, as core components, bear important responsibilities for data storage and processing. Especially in high-concurrency scenarios such as finance and e-commerce, a large number of scheduled tasks and batch jobs need to be executed, and these tasks often access database resources in a centralized manner. For example, in e-commerce systems, tasks such as order status updates, inventory counts, and data statistics and analysis need to be processed regularly; in financial systems, batch operations such as bill generation, risk control analysis, and list settlement need to be performed.
[0003] In the related technology, the traditional financial data processing task scheduling method mainly relies on preset cron expressions or fixed time intervals to trigger task execution. However, when multiple resource-intensive financial data processing tasks (such as clearing tasks, report generation tasks, etc.) are executed concurrently in the same time period, it will cause spikes in core indicators such as database CPU usage and memory usage. In severe cases, it may cause database downtime, affecting the continuity and stability of financial business. Therefore, how to reasonably schedule tasks and thus improve the continuity and stability of financial business has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a task scheduling method and device, an electronic device and a storage medium, aiming to reasonably schedule tasks and thereby improve the continuity and stability of financial services.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a task scheduling method, which is applied to a financial database server. The method includes:
[0006] In response to obtaining the to-be-executed task, adding the to-be-executed task to a task queue as an alternative task;
[0007] Acquire current resource occupancy data in the database, and historical resource occupancy data corresponding to each candidate task in the task queue;
[0008] Determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each candidate task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold;
[0009] Execute the target execution task.
[0010] In some embodiments, the current resource occupancy data includes the current processor occupancy, the current memory occupancy, and the current session occupancy of the database, the historical resource occupancy data includes the historical processor occupancy, the historical memory occupancy, and the historical session occupancy when each of the candidate tasks is executed, and determining at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each of the candidate tasks includes:
[0011] Determine, according to the historical resource occupancy data of each candidate task, a predicted processor occupancy, a predicted memory occupancy, and a predicted session occupancy of each candidate task;
[0012] A first prediction value is calculated based on the current processor occupancy and the predicted processor occupancy corresponding to each candidate task;
[0013] A second predicted value is calculated according to the current memory occupancy rate and the predicted memory occupancy rate corresponding to each candidate task;
[0014] A third prediction value is calculated according to the current session occupancy rate and the predicted session occupancy rate corresponding to each candidate task;
[0015] At least one of the target execution tasks is determined based on comparison of the first prediction value, the second prediction value, and the third prediction value with the resource occupancy threshold.
[0016] In some embodiments, the historical resource occupancy data includes multiple historical processor occupancy rates, multiple historical memory occupancy rates, and multiple historical session occupancy rates of multiple executions of the candidate task, and determining the predicted processor occupancy rate, predicted memory occupancy rate, and predicted session occupancy rate of each candidate task according to the historical resource occupancy data of each candidate task includes:
[0017] Calculating an average processor occupancy of a plurality of the historical processor occupancies of each candidate task, and using the average processor occupancy as the predicted processor occupancy;
[0018] Calculating an average memory occupancy of a plurality of the historical memory occupancy rates of each candidate task, and using the average memory occupancy rate as the predicted memory occupancy rate;
[0019] The session occupancy average value of the multiple historical session occupancies of each candidate task is calculated, and the session occupancy average value is used as the predicted session occupancy rate.
[0020] In some embodiments, when there is one target execution task, the resource occupation threshold includes a processor occupation threshold, a memory occupation threshold, and a session occupation threshold, and comparing the first prediction value, the second prediction value, and the third prediction value with the resource occupation threshold to determine at least one target execution task includes:
[0021] comparing the first prediction value with the processor occupancy threshold, comparing the second prediction value with the memory occupancy threshold, and comparing the third prediction value with the session occupancy threshold;
[0022] If the first prediction value is smaller than the processor occupancy threshold, the second prediction value is smaller than the memory occupancy threshold, and the third prediction value is smaller than the session occupancy threshold, the corresponding candidate task is determined as the target execution task.
[0023] In some embodiments, when there are multiple target execution tasks, the method further includes:
[0024] Calculating the occupancy and value of the predicted processor occupancy, the predicted memory occupancy, and the predicted session occupancy of each of the candidate tasks, and sorting the candidate tasks according to the occupancy and value of each of the candidate tasks;
[0025] Starting from the candidate task with the smallest occupancy and value, the cumulative processor occupancy is calculated according to the predicted processor occupancy corresponding to the candidate task and the current processor occupancy, the cumulative memory occupancy is calculated according to the predicted memory occupancy corresponding to the candidate task and the current memory occupancy, and the cumulative session occupancy is calculated according to the predicted session occupancy corresponding to the candidate task and the current session occupancy;
[0026] When the cumulative processor occupancy rate is less than the processor occupancy threshold, the cumulative memory occupancy rate is less than the memory occupancy threshold, and the cumulative session occupancy rate is less than the session occupancy threshold, the candidate task is determined as the target execution task;
[0027] When the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the candidate task is determined as the target execution task, and the determination of subsequent candidate tasks is stopped.
[0028] In some embodiments, when there are multiple target execution tasks, the method further includes:
[0029] Obtaining the time when each candidate task enters the task queue;
[0030] Sorting the candidate tasks in ascending order according to the time when the candidate tasks entered the task queue;
[0031] Starting from the candidate task that enters the task queue earliest, the cumulative processor occupancy is calculated according to the predicted processor occupancy corresponding to the candidate task and the current processor occupancy, the cumulative memory occupancy is calculated according to the predicted memory occupancy corresponding to the candidate task and the current memory occupancy, and the cumulative session occupancy is calculated according to the predicted session occupancy corresponding to the candidate task and the current session occupancy;
[0032] When the cumulative processor occupancy rate is less than the processor occupancy threshold, the cumulative memory occupancy rate is less than the memory occupancy threshold, and the cumulative session occupancy rate is less than the session occupancy threshold, the candidate task is determined as the target execution task;
[0033] When the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the determination of subsequent candidate tasks is stopped.
[0034] In some embodiments, after executing the target execution task, the method further includes:
[0035] In response to the target execution task being completed, obtaining actual resource occupancy data during the execution of the target execution task;
[0036] The historical resource occupancy data of the target execution task is updated based on the actual resource occupancy data.
[0037] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a task scheduling device, the device comprising:
[0038] A response module, configured to, in response to obtaining a task to be executed, add the task to be executed to a task queue as an alternative task;
[0039] An acquisition module, used to acquire current resource occupancy data in a database and historical resource occupancy data corresponding to each candidate task in the task queue;
[0040] a determination module, configured to determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each candidate task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold;
[0041] An execution module is used to execute the target execution task.
[0042] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0043] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0044] The task scheduling method and device, electronic device and storage medium proposed in the present application add the to-be-executed task to the task queue as an alternative task in response to obtaining the to-be-executed task; obtain the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue; determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data and the historical resource occupancy data of each alternative task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold; and execute the target execution task.
[0045] First, in response to obtaining the task to be executed, the task to be executed is added to the task queue as an alternative task, and the alternative tasks are preliminarily analyzed to establish a basic management mechanism for task scheduling. Then, the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue are obtained, and the current resource occupancy data of the database and the historical resource occupancy data of the alternative tasks in the task queue are monitored in real time to provide data support for subsequent scheduling decisions. Next, a comprehensive analysis is performed based on the preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each alternative task, and at least one target execution task is determined in the task queue, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold. Through the preset resource occupancy threshold, the method can predict and avoid the database resource occupancy rate exceeding the safety threshold before the task is executed, and reduce service interruption and performance degradation caused by resource problems. Through the above method, tasks can be reasonably scheduled, thereby improving the continuity and stability of financial services. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 is a flowchart of a task scheduling method provided in an embodiment of the present application;
[0047] Figure 2 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0048] Figure 3 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0049] Figure 4 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0050] Figure 5 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0051] Figure 6 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0052] Figure 7 is another flow chart of the task scheduling method provided in the embodiment of the present application;
[0053] Figure 8 is a structural diagram of a task scheduling device provided in an embodiment of the present application;
[0054] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0058] First, some nouns involved in this application are analyzed:
[0059] Task Scheduling: It is a concept in computer science. It involves the process of managing and optimizing the execution order of tasks (or jobs, processes) in a computer system; it involves deciding which tasks (or jobs, processes) should be executed when and how. Tasks can be understood as units of work that need to be processed by computers. They can be programs, services, or any computing activities that require resources such as CPU time, memory, I / O, etc. Scheduling itself refers to a process in the operating system that is responsible for allocating CPU time to each task to ensure that they can be executed in an orderly manner according to a certain strategy. The scheduler is a component in the operating system that selects the next task to be executed according to a specific scheduling algorithm. The task queue is a list of tasks waiting to be executed. In the process of task scheduling, the tasks to be executed are placed in this queue, waiting for the scheduler to decide their execution order according to the scheduling strategy.
[0060] Based on this, the embodiments of the present application provide a task scheduling method and device, an electronic device and a storage medium, which aim to achieve efficient scheduling of database resources while ensuring normal execution of tasks.
[0061] The task scheduling method and device, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the task scheduling method in the embodiments of the present application is described.
[0062] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0063] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0064] The task scheduling method provided in the embodiment of the present application relates to the field of computer technology. The task scheduling method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the task scheduling method, etc., but is not limited to the above forms.
[0065] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0066] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0067] Figure 1 is an optional flowchart of the task scheduling method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S104.
[0068] Step S101, in response to obtaining a task to be executed, adding the task to be executed to a task queue as a candidate task.
[0069] Step S102, obtaining current resource occupancy data in the database and historical resource occupancy data corresponding to each candidate task in the task queue.
[0070] Step S103, determining at least one target execution task in the task queue according to a preset resource occupancy threshold, current resource occupancy data, and historical resource occupancy data of each candidate task.
[0071] Step S104, executing the target execution task.
[0072] Steps S101 to S104 shown in the embodiment of the present application, by responding to the acquisition of the task to be executed, adding the task to be executed to the task queue as an alternative task, preliminarily analyzing the alternative tasks, and establishing a basic management mechanism for task scheduling. Then, the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue are obtained, and the current resource occupancy data of the database and the historical resource occupancy data of the alternative tasks in the task queue are monitored in real time to provide data support for subsequent scheduling decisions. Next, a comprehensive analysis is performed based on the preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each alternative task, and at least one target execution task is determined in the task queue, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold. Through the preset resource occupancy threshold, the method can prejudge and avoid the database resource occupancy rate exceeding the safety threshold before the task is executed, and reduce service interruption and performance degradation caused by resource problems. Through the above method, efficient scheduling of database resources can be achieved under the premise of ensuring the normal execution of tasks.
[0073] In step S101 of some embodiments, the tasks to be executed can be obtained by: timing trigger acquisition based on a preset cron expression, trigger acquisition based on a business event, or trigger acquisition based on an associated task completion event. The tasks to be executed include, but are not limited to, financial data processing tasks such as transaction data clearing tasks, risk indicator calculation tasks, compliance review tasks, and regulatory report generation tasks.
[0074] When adding a task to be executed to a task queue, a task identifier is generated for the task to be executed, and the task identifier is used to uniquely identify the task during the scheduling process. At the same time, the basic attribute information of the task to be executed is recorded, and the basic attribute information includes: task type identification, expected execution time information, etc., wherein the task type identification is used to distinguish different types of tasks.
[0075] In step S102 of some embodiments, the current resource usage data includes one or more of the following: database CPU usage, database memory usage, the number of currently active database sessions, database I / O usage, and database lock wait data. For example, the current database CPU usage is 45%, the memory usage is 60%, and the number of active sessions is 100.
[0076] The historical resource usage data includes one or more of the following: the historical CPU usage, historical memory usage, historical execution time, and historical I / O usage of the candidate task. For example, for the transaction clearing task, its historical execution data shows that the average CPU usage is 30% and the average execution time is 20 minutes.
[0077] In specific implementation, a fixed resource data collection cycle can be set, such as collecting current resource occupancy data every 5 minutes, and calculating the average resource usage rate in the last 15 minutes, and using the average usage rate as the current resource occupancy data. At the same time, when obtaining the historical resource occupancy data of the candidate task, it can be calculated based on the most recent N execution records to ensure the timeliness of the historical data.
[0078] In step S103 of some embodiments, which tasks can be executed are determined based on a preset resource occupancy threshold, current resource occupancy data, and historical resource occupancy data of each candidate task to ensure that the resource occupancy rate of the database will not exceed the preset threshold when executing these tasks. It is estimated whether the total resource occupancy of the database will exceed the threshold when executing each candidate task, and only those candidate tasks that will not cause excessive resource occupancy after execution will be selected as target execution tasks. For example, if the CPU usage rate of the database is close to the threshold, tasks with lower resource requirements will be selected for execution first to avoid exceeding resource limits, avoid the risk of resource competition and excessive occupancy in advance, and prevent newly started tasks from causing an increase in the overall system load and affecting other running services.
[0079] It is understandable that the preset resource usage threshold needs to take into account database performance and stability requirements to ensure that services remain responsive and consistent under all circumstances. Historical data and trend analysis can reveal the peaks and valleys of resource usage, providing a basis for setting resource usage thresholds. Through dynamic adjustment and adaptive mechanisms, the database server can automatically adjust the resource usage threshold based on real-time monitoring and prediction models to adapt to the changing business load. The preset resource usage threshold is designed to achieve efficient resource utilization while ensuring system performance and business continuity.
[0080] See also Figure 2In some embodiments, the current resource occupancy data includes the current processor occupancy, the current memory occupancy and the current session occupancy of the database, and the historical resource occupancy data includes the historical processor occupancy, the historical memory occupancy and the historical session occupancy when each candidate task is executed. Step S103 may include but is not limited to steps S201 to S205:
[0081] Step S201, determining the predicted processor occupancy, predicted memory occupancy and predicted session occupancy of each candidate task according to the historical resource occupancy data of each candidate task.
[0082] Step S202: Calculate a first prediction value based on the current processor occupancy and the predicted processor occupancy corresponding to each candidate task.
[0083] Step S203: Calculate a second predicted value according to the current memory occupancy rate and the predicted memory occupancy rate corresponding to each candidate task.
[0084] Step S204: Calculate a third prediction value according to the current session occupancy rate and the predicted session occupancy rate corresponding to each candidate task.
[0085] Step S205: Determine at least one target execution task based on comparing the first prediction value, the second prediction value, and the third prediction value with the resource occupancy threshold.
[0086] In step S201 of some embodiments, the historical resource occupancy data of each candidate task in the past execution includes the historical processor occupancy rate, the historical memory occupancy rate and the historical session occupancy rate. Based on these historical resource occupancy data, the predicted processor occupancy rate, the predicted memory occupancy rate and the predicted session occupancy rate that may be consumed when the candidate task is executed again can be predicted. If an candidate task occupied an average of 20% of the historical processor occupancy rate and 30% of the historical memory occupancy rate when it was executed in the past, then these data can be used to predict the resource occupancy of the candidate task when it is executed in the future.
[0087] See also Figure 3 In some embodiments, the historical resource occupancy data includes multiple historical processor occupancy rates, multiple historical memory occupancy rates, and multiple historical session occupancy rates of multiple executions of the candidate task. Step S201 may include but is not limited to steps S301 to S303:
[0088] Step S301 , calculating an average processor occupancy value of a plurality of historical processor occupancies of each candidate task, and taking the average processor occupancy value as a predicted processor occupancy value.
[0089] Step S302, calculating an average memory occupancy value of multiple historical memory occupancy values of each candidate task, and using the average memory occupancy value as a predicted memory occupancy value.
[0090] Step S303: Calculate the average session occupancy of multiple historical session occupancies of each candidate task, and use the average session occupancy as the predicted session occupancy.
[0091] In step S301 of some embodiments, multiple historical processor occupancy rates of each candidate task are summarized and analyzed, and a more accurate predicted processor occupancy rate can be obtained by calculating the average value of these historical data. This method takes into account the variability in the task execution process, reduces the impact of accidental peaks or valleys through the average value, and provides a more stable and reliable prediction basis.
[0092] In step S302 of some embodiments, the average of multiple historical memory occupancy rates of each candidate task is calculated to obtain a predicted memory occupancy rate, which helps to more accurately predict the task's demand for memory resources, thereby making more reasonable resource allocation decisions during scheduling.
[0093] In step S303 of some embodiments, the predicted session occupancy rate is obtained by calculating the average of multiple historical session occupancy rates of each candidate task, which helps to predict the impact of task execution on session resources and ensure the stability and responsiveness of the database in a high concurrency environment.
[0094] Through the above steps S301 to S303, the processor occupancy average value of multiple historical processor occupancies of each candidate task is calculated, and the processor occupancy average value is used as the predicted processor occupancy rate; the memory occupancy average value of multiple historical memory occupancies of each candidate task is calculated, and the memory occupancy average value is used as the predicted memory occupancy rate; the session occupancy average value of multiple historical session occupancies of each candidate task is calculated, and the session occupancy average value is used as the predicted session occupancy rate, thereby reducing the influence of accidental factors and improving the accuracy of resource occupancy prediction.
[0095] In step S202 of some embodiments, the current processor occupancy of the current database is combined with the predicted processor occupancy corresponding to each candidate task to calculate a first predicted value, which represents the level that the processor occupancy of the database may reach if the candidate task is executed. For example, if the current processor occupancy is 50% and the predicted processor occupancy of a candidate task is 20%, then the first predicted value will be 70%, indicating that the processor occupancy may reach 70% after executing the candidate task.
[0096] In step S203 of some embodiments, the current memory occupancy rate is combined with the predicted memory occupancy rate corresponding to each candidate task to obtain a second prediction value, which helps predict the usage of memory resources after executing the candidate task. For example, if the current memory occupancy rate is 60%, and the predicted memory occupancy rate of a candidate task is 15%, then the second prediction value will be 75%.
[0097] In step S204 of some embodiments, the current session occupancy rate is combined with the predicted session occupancy rate corresponding to each candidate task to calculate a third prediction value, which predicts the usage of session resources after executing the candidate task. For example, if the current session occupancy rate is 40% and the predicted session occupancy rate of a candidate task is 10%, then the third prediction value will be 50%.
[0098] In step S205 of some embodiments, the first predicted value, the second predicted value, and the third predicted value are compared with a preset resource occupancy threshold. If any predicted value exceeds the corresponding resource occupancy threshold, the corresponding standby task will not be selected as the target execution task. Only those candidate tasks whose predicted values are all below the resource occupancy threshold will be determined as the target execution task. In this way, it can be ensured that the target execution task will not cause the database resources to exceed the safety threshold, thereby maintaining the stability and performance of the database.
[0099] See also Figure 4 In some embodiments, when the target execution task is one, the resource occupation threshold includes a processor occupation threshold, a memory occupation threshold, and a session occupation threshold. Step S205 may include but is not limited to steps S401 to S402:
[0100] Step S401: compare the first predicted value with a processor occupancy threshold, compare the second predicted value with a memory occupancy threshold, and compare the third predicted value with a session occupancy threshold.
[0101] Step S402: if the first predicted value is less than the processor occupancy threshold, the second predicted value is less than the memory occupancy threshold, and the third predicted value is less than the session occupancy threshold, the corresponding candidate task is determined as the target execution task.
[0102] In step S401 of some embodiments, the predicted values are compared with the thresholds for the processor resources, memory resources and session resources of the database, respectively. For example, if the processor occupancy threshold is 80%, the first predicted value is compared with 80%; if the memory occupancy threshold is 85%, the second predicted value is compared with 85%; if the session occupancy threshold is 75%, the third predicted value is compared with 75%.
[0103] In step S402 of some embodiments, only when the three predicted values of a candidate task are all less than the corresponding resource occupancy threshold, the candidate task is determined as the target execution task. For example, if the first predicted value of a candidate task is 70% less than the processor occupancy threshold of 80%, the second predicted value is 75% less than the memory occupancy threshold of 85%, and the third predicted value is 65% less than the session occupancy threshold of 75%, then the candidate task is determined as the target execution task.
[0104] Through the above steps S401 to S402, a comprehensive evaluation of the candidate tasks in multiple resource dimensions is achieved, ensuring that the selected target execution tasks will not cause any type of database resources to exceed the safety threshold during execution, thereby ensuring the stable operation of the database.
[0105] See also Figure 5 In some embodiments, when there are multiple target execution tasks, the task scheduling method provided in the embodiment of the present application may also include but is not limited to steps S501 to S504:
[0106] Step S501, calculate the occupancy and value of the predicted processor occupancy, the predicted memory occupancy and the predicted session occupancy of each candidate task, and sort the candidate tasks according to the occupancy and value of each candidate task.
[0107] Step S502, starting from the alternative task with the smallest occupancy and value, calculate the cumulative processor occupancy according to the predicted processor occupancy corresponding to the alternative task and the current processor occupancy, calculate the cumulative memory occupancy according to the predicted memory occupancy corresponding to the alternative task and the current memory occupancy, and calculate the cumulative session occupancy according to the predicted session occupancy corresponding to the alternative task and the current session occupancy.
[0108] Step S503: when the cumulative processor occupancy is less than the processor occupancy threshold, the cumulative memory occupancy is less than the memory occupancy threshold, and the cumulative session occupancy is less than the session occupancy threshold, the candidate task is determined as the target execution task.
[0109] Step S504, when the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the candidate task is determined as the target execution task, and the determination of subsequent candidate tasks is stopped.
[0110] In step S501 of some embodiments, for each candidate task in the task queue, its predicted processor occupancy, predicted memory occupancy and predicted session occupancy are added together to obtain the occupancy sum value. For example, for candidate task A, its predicted processor occupancy is 20%, predicted memory occupancy is 15%, and predicted session occupancy is 10%, then its occupancy sum value is 45%; for candidate task B, its predicted processor occupancy is 15%, predicted memory occupancy is 10%, and predicted session occupancy is 5%, then its occupancy sum value is 30%. Then, the candidate tasks in the task queue are sorted from small to large according to the occupancy sum value. In the above example, candidate task B will be ranked before candidate task A.
[0111] In step S502 of some embodiments, first obtain the candidate task at the head of the queue after sorting, add its predicted processor occupancy to the current processor occupancy to obtain the cumulative processor occupancy, add its predicted memory occupancy to the current memory occupancy to obtain the cumulative memory occupancy, and add its predicted session occupancy to the current session occupancy to obtain the cumulative session occupancy. For example, the current processor occupancy is 40%, the current memory occupancy is 50%, and the current session occupancy is 30%. For candidate task B, it is calculated that the cumulative processor occupancy is 55% (40% + 15%), the cumulative memory occupancy is 60% (50% + 10%), and the cumulative session occupancy is 35% (30% + 5%).
[0112] In step S503 of some embodiments, the cumulative occupancy rate of the candidate task currently being judged is compared with the corresponding resource occupancy threshold. For example, if the processor occupancy threshold is 80%, the memory occupancy threshold is 85%, and the session occupancy threshold is 75%, then the cumulative processor occupancy rate of 55%, the cumulative memory occupancy rate of 60%, and the cumulative session occupancy rate of 35% of candidate task B are compared with these thresholds respectively. Since the three cumulative occupancy rates are all less than the corresponding thresholds, candidate task B is determined as the target execution task.
[0113] In step S504 of some embodiments, if any cumulative occupancy rate of a candidate task exceeds the corresponding resource occupancy threshold, the judgment process for subsequent candidate tasks is terminated. For example, when candidate task A is judged, the calculated cumulative processor occupancy rate is 75% (55% + 20%), the cumulative memory occupancy rate is 75% (60% + 15%), and the cumulative session occupancy rate is 45% (35% + 10%). Although these cumulative occupancy rates still do not exceed the corresponding thresholds, if the predicted occupancy rate of the next candidate task C in the queue may cause the cumulative occupancy rate to exceed the threshold, the judgment of candidate task C will be stopped after the judgment of candidate task A is completed.
[0114] Through the above steps S501 to S504, by sorting and accumulating the resource occupancy of the candidate tasks, the goal of maximizing the concurrent execution of multiple tasks is achieved while ensuring that the database resource usage does not exceed the safety threshold.
[0115] See also Figure 6 In some embodiments, when there are multiple target execution tasks, the task scheduling method provided in the embodiment of the present application may also include but is not limited to steps S601 to S604:
[0116] Step S601, obtaining the time when each candidate task enters the task queue, and sorting the candidate tasks in ascending order according to the time when the candidate tasks enter the task queue.
[0117] Step S602, starting from the candidate task that enters the task queue earliest, calculate the cumulative processor occupancy according to the predicted processor occupancy corresponding to the candidate task and the current processor occupancy, calculate the cumulative memory occupancy according to the predicted memory occupancy corresponding to the candidate task and the current memory occupancy, and calculate the cumulative session occupancy according to the predicted session occupancy corresponding to the candidate task and the current session occupancy.
[0118] Step S603: when the cumulative processor occupancy is less than the processor occupancy threshold, the cumulative memory occupancy is less than the memory occupancy threshold, and the cumulative session occupancy is less than the session occupancy threshold, the candidate task is determined as the target execution task.
[0119] Step S604: when the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the determination of subsequent candidate tasks is stopped.
[0120] In step S601 of some embodiments, the timestamp information of each candidate task when it is added to the task queue is recorded, and the candidate tasks are sorted based on the timestamp information, with the tasks with earlier timestamps being placed at the front of the queue. For example, the entry time of candidate task A is 10:00:00, the entry time of candidate task B is 10:00:30, and the entry time of candidate task C is 10:01:00, then the sorted order is A, B, C.
[0121] In step S602 of some embodiments, starting from the first candidate task after sorting, the cumulative resource occupancy of each candidate task after execution is calculated in sequence. For example, the current processor occupancy is 40%, the current memory occupancy is 50%, and the current session occupancy is 30%. For the candidate task A that enters the queue earliest (predicted processor occupancy is 15%, predicted memory occupancy is 10%, and predicted session occupancy is 5%), it is calculated that: the cumulative processor occupancy is 55%, the cumulative memory occupancy is 60%, and the cumulative session occupancy is 35%.
[0122] In step S603 of some embodiments, the cumulative occupancy rate of the candidate task currently being judged is compared with the corresponding resource occupancy threshold. For example, if the processor occupancy threshold is 80%, the memory occupancy threshold is 85%, and the session occupancy threshold is 75%, and the three cumulative occupancy rates of candidate task A are all less than the corresponding thresholds, then candidate task A is determined as the target execution task, and the next candidate task B is judged.
[0123] In step S604 of some embodiments, if any cumulative occupancy rate exceeds the corresponding resource occupancy threshold when judging a candidate task, the judgment of subsequent candidate tasks is stopped. For example, when judging candidate task B, if its cumulative processor occupancy rate reaches 85%, exceeding the processor occupancy threshold of 80%, the candidate task C is no longer judged.
[0124] Through the above steps S601 to S604, scheduling is performed based on the time order in which tasks enter the queue. Under the premise of ensuring that the use of database resources does not exceed the safety threshold, the target execution task is selected according to the first-in-first-out principle, thereby ensuring the fairness and timeliness of task scheduling.
[0125] Through the above steps S201 to S205, at least one target execution task is determined based on the comparison between the first prediction value, the second prediction value and the third prediction value and the resource occupancy threshold, so as to achieve refined management and prediction of database resource occupancy, and ensure that when executing the target execution task, the current processor, memory and session occupancy of the database will not exceed the preset safety threshold, thereby effectively avoiding performance degradation and financial service interruption caused by resource overload.
[0126] In step S104 of some embodiments, tasks are executed for one or more determined targets, taken out of the task queue, and formally started. During the execution process, resource usage can be continuously monitored to ensure that the execution of tasks does not cause the database resource occupancy rate to exceed the resource occupancy threshold. If the database resource occupancy rate approaches or exceeds the resource occupancy threshold during the execution process, the execution of certain tasks can be suspended or delayed to protect the stability and performance of the database.
[0127] See also Figure 7 In some embodiments, after step S104, the following steps may also be performed, including but not limited to steps S701 to S702:
[0128] Step S701, in response to the target execution task being completed, obtaining actual resource occupancy data during the execution of the target execution task.
[0129] Step S702: updating the historical resource occupancy data of the target execution task based on the actual resource occupancy data.
[0130] In step S701 of some embodiments, resource occupancy data of the target execution task during the entire execution process is obtained, and the resource occupancy data includes: the actual processor occupancy rate, the actual memory occupancy rate, and the actual session occupancy rate during the execution process of the target execution task. For example, the actual processor occupancy rate, the actual memory occupancy rate, and the actual session occupancy rate of a target execution task during the execution process are 30%, 25%, and 15%.
[0131] In step S702 of some embodiments, the actual resource occupancy data obtained during this execution is added to the historical resource occupancy data set of the target execution task. Specifically, the actual processor occupancy rate of 30%, the actual memory occupancy rate of 25%, and the actual session occupancy rate of 15% of this execution are recorded in the historical resource occupancy data of the task, which is used for more accurate resource occupancy prediction in subsequent task scheduling.
[0132] Through the above steps S701 to S702, by collecting the actual resource occupancy during task execution and updating historical data in a timely manner, the accuracy of resource occupancy prediction during subsequent task scheduling is improved, which helps to achieve more reasonable task scheduling.
[0133] The task scheduling method and device, electronic device and storage medium proposed in the present application add the to-be-executed task to the task queue as an alternative task in response to obtaining the to-be-executed task; obtain the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue; determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data and the historical resource occupancy data of each alternative task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold; and execute the target execution task.
[0134] First, in response to obtaining the task to be executed, the task to be executed is added to the task queue as an alternative task, and the alternative tasks are preliminarily analyzed to establish a basic management mechanism for task scheduling. Then, the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue are obtained, and the current resource occupancy data of the database and the historical resource occupancy data of the alternative tasks in the task queue are monitored in real time to provide data support for subsequent scheduling decisions. Next, a comprehensive analysis is performed based on the preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each alternative task, and at least one target execution task is determined in the task queue, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold. Through the preset resource occupancy threshold, the method can predict and avoid the database resource occupancy rate exceeding the safety threshold before the task is executed, and reduce service interruption and performance degradation caused by resource problems. Through the above method, efficient scheduling of database resources can be achieved under the premise of ensuring the normal execution of tasks.
[0135] See also Figure 8 The embodiment of the present application also provides a task scheduling device, which can implement the above-mentioned task scheduling method, and the device includes:
[0136] A response module, configured to, in response to obtaining a task to be executed, add the task to be executed to a task queue as a candidate task;
[0137] The acquisition module is used to obtain the current resource occupancy data in the database and the historical resource occupancy data corresponding to each candidate task in the task queue;
[0138] A determination module, configured to determine at least one target execution task in the task queue according to a preset resource occupancy threshold, current resource occupancy data, and historical resource occupancy data of each candidate task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold;
[0139] The execution module is used to execute the target execution task.
[0140] The specific implementation of the task scheduling device is substantially the same as the specific implementation of the above-mentioned task scheduling method, and will not be described in detail here.
[0141] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned task scheduling method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0142] See also Fig. 9 , Fig. 9The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0143] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0144] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the task scheduling method of the embodiment of this application;
[0145] Input / output interface 903, used to implement information input and output;
[0146] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0147] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0148] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0149] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned task scheduling method is implemented.
[0150] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0151] The task scheduling method and device, electronic device and storage medium proposed in the present application add the to-be-executed task to the task queue as an alternative task in response to obtaining the to-be-executed task; obtain the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue; determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data and the historical resource occupancy data of each alternative task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold; and execute the target execution task.
[0152] First, in response to obtaining the task to be executed, the task to be executed is added to the task queue as an alternative task, and the alternative tasks are preliminarily analyzed to establish a basic management mechanism for task scheduling. Then, the current resource occupancy data in the database and the historical resource occupancy data corresponding to each alternative task in the task queue are obtained, and the current resource occupancy data of the database and the historical resource occupancy data of the alternative tasks in the task queue are monitored in real time to provide data support for subsequent scheduling decisions. Next, a comprehensive analysis is performed based on the preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each alternative task, and at least one target execution task is determined in the task queue, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold. Through the preset resource occupancy threshold, the method can predict and avoid the database resource occupancy rate exceeding the safety threshold before the task is executed, and reduce service interruption and performance degradation caused by resource problems. Through the above method, tasks can be reasonably scheduled, thereby improving the continuity and stability of financial services.
[0153] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0154] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0155] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0156] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0157] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0158] It should be understood that in the present application, "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.
[0159] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0160] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0161] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0162] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0163] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.
Claims
1. A task scheduling method, characterized in that: Applied to a financial database server, the method comprises: In response to obtaining the to-be-executed task, adding the to-be-executed task to a task queue as an alternative task; Acquire current resource occupancy data in the database, and historical resource occupancy data corresponding to each candidate task in the task queue; Determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each candidate task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold; Execute the target execution task.
2. The task scheduling method according to claim 1, characterized in that: The current resource occupancy data includes the current processor occupancy rate, the current memory occupancy rate and the current session occupancy rate of the database, the historical resource occupancy data includes the historical processor occupancy rate, the historical memory occupancy rate and the historical session occupancy rate when each candidate task is executed, and determining at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data and the historical resource occupancy data of each candidate task, including: Determine, according to the historical resource occupancy data of each candidate task, a predicted processor occupancy, a predicted memory occupancy, and a predicted session occupancy of each candidate task; A first prediction value is calculated based on the current processor occupancy and the predicted processor occupancy corresponding to each candidate task; A second predicted value is calculated according to the current memory occupancy rate and the predicted memory occupancy rate corresponding to each candidate task; A third prediction value is calculated according to the current session occupancy rate and the predicted session occupancy rate corresponding to each candidate task; At least one of the target execution tasks is determined based on comparison of the first prediction value, the second prediction value, and the third prediction value with the resource occupancy threshold.
3. The task scheduling method according to claim 2, characterized in that: The historical resource occupancy data includes multiple historical processor occupancy rates, multiple historical memory occupancy rates, and multiple historical session occupancy rates of multiple executions of the candidate tasks, and determining the predicted processor occupancy rate, predicted memory occupancy rate, and predicted session occupancy rate of each candidate task according to the historical resource occupancy data of each candidate task, including: Calculating an average processor occupancy of a plurality of the historical processor occupancy rates of each candidate task, and using the average processor occupancy rate as the predicted processor occupancy rate; Calculating an average memory occupancy of a plurality of the historical memory occupancy rates of each candidate task, and using the average memory occupancy rate as the predicted memory occupancy rate; The session occupancy average value of the multiple historical session occupancies of each candidate task is calculated, and the session occupancy average value is used as the predicted session occupancy rate.
4. The task scheduling method according to claim 2, characterized in that: When there is one target execution task, the resource occupation threshold includes a processor occupation threshold, a memory occupation threshold, and a session occupation threshold, and the comparing the first prediction value, the second prediction value, and the third prediction value with the resource occupation threshold to determine at least one target execution task includes: comparing the first prediction value with the processor occupancy threshold, comparing the second prediction value with the memory occupancy threshold, and comparing the third prediction value with the session occupancy threshold; If the first prediction value is smaller than the processor occupancy threshold, the second prediction value is smaller than the memory occupancy threshold, and the third prediction value is smaller than the session occupancy threshold, the corresponding candidate task is determined as the target execution task.
5. The task scheduling method according to claim 2, characterized in that: When there are multiple target execution tasks, the method further includes: Calculating the occupancy and value of the predicted processor occupancy, the predicted memory occupancy, and the predicted session occupancy of each of the candidate tasks, and sorting the candidate tasks according to the occupancy and value of each of the candidate tasks; Starting from the candidate task with the smallest occupancy and value, the cumulative processor occupancy is calculated according to the predicted processor occupancy corresponding to the candidate task and the current processor occupancy, the cumulative memory occupancy is calculated according to the predicted memory occupancy corresponding to the candidate task and the current memory occupancy, and the cumulative session occupancy is calculated according to the predicted session occupancy corresponding to the candidate task and the current session occupancy; When the cumulative processor occupancy rate is less than the processor occupancy threshold, the cumulative memory occupancy rate is less than the memory occupancy threshold, and the cumulative session occupancy rate is less than the session occupancy threshold, the candidate task is determined as the target execution task; When the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the candidate task is determined as the target execution task, and the determination of subsequent candidate tasks is stopped.
6. The task scheduling method according to claim 2, characterized in that: When there are multiple target execution tasks, the method further includes: Obtaining the time when each candidate task enters the task queue, and sorting the candidate tasks in ascending order according to the time when the candidate task enters the task queue; Starting from the candidate task that enters the task queue earliest, the cumulative processor occupancy is calculated according to the predicted processor occupancy corresponding to the candidate task and the current processor occupancy, the cumulative memory occupancy is calculated according to the predicted memory occupancy corresponding to the candidate task and the current memory occupancy, and the cumulative session occupancy is calculated according to the predicted session occupancy corresponding to the candidate task and the current session occupancy; When the cumulative processor occupancy rate is less than the processor occupancy threshold, the cumulative memory occupancy rate is less than the memory occupancy threshold, and the cumulative session occupancy rate is less than the session occupancy threshold, the candidate task is determined as the target execution task; When the cumulative processor occupancy is greater than the processor occupancy threshold, the cumulative memory occupancy is greater than the memory occupancy threshold, and the cumulative session occupancy is greater than the session occupancy threshold, the determination of subsequent candidate tasks is stopped.
7. The task scheduling method according to claim 1, characterized in that: After executing the target execution task, the method further includes: In response to the target execution task being completed, obtaining actual resource occupancy data during the execution of the target execution task; The historical resource occupancy data of the target execution task is updated based on the actual resource occupancy data.
8. A task scheduling device, characterized in that: The device comprises: A response module, configured to, in response to obtaining a task to be executed, add the task to be executed to a task queue as an alternative task; An acquisition module, used to acquire current resource occupancy data in a database and historical resource occupancy data corresponding to each candidate task in the task queue; a determination module, configured to determine at least one target execution task in the task queue according to a preset resource occupancy threshold, the current resource occupancy data, and the historical resource occupancy data of each candidate task, so that the database resource occupancy rate of the database when executing the target execution task is less than the resource occupancy threshold; An execution module is used to execute the target execution task.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the task scheduling method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the task scheduling method according to any one of claims 1 to 7 is implemented.