Resource allocation method and device, electronic equipment and storage medium
By rationally allocating online task resources and offline task resources in the resource pool, based on task priority and resource allocation weight, the problem of low utilization of online task resources is solved, and the effect of improving resource utilization and task processing efficiency is achieved.
Patent Information
- Application Number
- CN202410831572.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-15
AI Technical Summary
In the existing technology, the utilization rate of online task resources is low, especially when the number of online tasks is small, resulting in resource redundancy and reduced utilization.
By obtaining the offline tasks and online task resources to be processed, resources are reasonably allocated based on the relationship between task priority and resource allocation weight, ensuring that offline tasks with high task priority can be processed in a timely manner, thereby improving resource utilization.
It effectively shortens the waiting time of offline tasks, improves resource utilization and task processing efficiency, and ensures that offline tasks with higher task priority can obtain resources first and complete processing quickly.
Smart Images

Figure CN118779101A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of resource management, and in particular to a resource allocation method, device, electronic device and storage medium. Background Art
[0002] A resource pool refers to a collection of certain types of resources that are centrally managed and allocated. Through dynamic allocation and sharing of resources, flexible resource configuration can be performed according to demand to adapt to different workloads and demand changes.
[0003] In the related art, in order to meet the processing requirements of online tasks and offline tasks, the resources in the resource pool are divided into online task resources and offline task resources, so that online tasks are processed by online task resources and offline tasks are processed by offline task resources. However, when the number of online tasks occupying online task resources is small, the resource utilization rate of online task resources will be affected. Summary of the invention
[0004] In view of this, the present disclosure provides a resource allocation method, device, electronic device and storage medium to solve the problem of low resource utilization.
[0005] In a first aspect, the present disclosure provides a resource allocation method, the method comprising:
[0006] Get multiple offline tasks to be processed;
[0007] Acquire first-type resources, and determine resources to be allocated based on the first-type resources and second-type resources, where the first-type resources are resources released by preset online task resources, and the second-type resources are resources to be occupied in preset offline task resources;
[0008] Based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, the resources to be allocated are allocated to the multiple offline tasks to process the multiple offline tasks.
[0009] In a second aspect, the present disclosure provides a resource allocation device, the device comprising:
[0010] An acquisition module is used to acquire multiple offline tasks to be processed;
[0011] A resource determination module, used to obtain first-type resources and determine resources to be allocated based on the first-type resources and second-type resources, wherein the first-type resources are resources released by preset online task resources and the second-type resources are resources to be occupied in preset offline task resources;
[0012] The allocation module is used to allocate resources to be allocated to multiple offline tasks based on the corresponding relationship between preset task priorities and resource allocation weights and the task priority of each offline task, so as to process multiple offline tasks.
[0013] In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the resource allocation method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0014] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the resource allocation method of the first aspect or any corresponding embodiment thereof.
[0015] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the resource allocation method of the first aspect or any corresponding embodiment thereof.
[0016] The resource allocation method provided in this embodiment can combine the first type of resources released after the online task is completed and processed with the second type of resources, determine the resources to be allocated for multiple offline tasks, and then allocate the resources to be allocated to multiple offline tasks based on the corresponding relationship between the preset task priority and the resource allocation weight and the task priority of each offline task, so as to enable multiple unprocessed offline tasks to be processed in time and ensure that offline tasks with higher task priorities can obtain resources first and complete processing faster, thereby achieving the purpose of improving resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 is a flowchart of a resource allocation method according to an embodiment of the present disclosure;
[0019] Figure 2 is a flowchart of another resource allocation method according to an embodiment of the present disclosure;
[0020] Figure 3 is a flowchart of another resource allocation method according to an embodiment of the present disclosure;
[0021] Figure 4 is a schematic diagram of the structure of a resource allocation system according to an embodiment of the present disclosure;
[0022] Figure 5 is a structural block diagram of a resource allocation device according to an embodiment of the present disclosure;
[0023] Figure 6 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0025] In related technologies, in order to meet the processing requirements of online tasks and offline tasks, the resources in the resource pool are divided into online task resources and offline task resources. Among them, online task resources are used to process online tasks, and offline task resources are used to process offline tasks. Since the number of online tasks changes dynamically, when the number of online tasks occupying online task resources is small, it will cause resource redundancy in the online task resources, thereby affecting the resource utilization of the resource pool.
[0026] In view of this, the embodiment of the present disclosure provides a resource allocation method, which obtains multiple offline tasks to be processed, obtains first-type resources, and determines the resources to be allocated based on the first-type resources and second-type resources, wherein the first-type resources are resources released by preset online task resources, and the second-type resources are resources to be occupied in preset offline task resources. Based on the correspondence between the preset task priority and the resource allocation weight and the task priority of each offline task, the resources to be allocated are allocated to multiple offline tasks to process multiple offline tasks, thereby effectively shortening the waiting time of offline tasks, improving task processing efficiency, and thus helping to improve resource utilization.
[0027] According to an embodiment of the present disclosure, a resource allocation method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] In this embodiment, a resource allocation method is provided, which can be used in electronic devices such as tablets, computers, servers, etc. Figure 1 is a flow chart of a resource allocation method according to an embodiment of the present disclosure, such as Figure 1 As shown, the process includes the following steps:
[0029] Step S101, obtaining multiple offline tasks to be processed.
[0030] Multiple offline tasks to be processed can be determined through a task management system. Each task to be processed by the resource pool is pre-registered in the task management system to determine the task information of the corresponding task based on the registration result. The task information includes but is not limited to: the processing type of the corresponding task, the task type, the task priority, the required expected data throughput, the processing status, etc. The processing type is online processing or offline processing. The task type may include but is not limited to any of the following: computing-intensive tasks, data processing tasks, network communication tasks, interactive tasks, or resource management tasks. The processing status includes: unprocessed, processing, or completed.
[0031] In order to clarify which offline tasks need to be processed at present, a task query is performed through the task management system, and offline tasks with an unprocessed processing status are regarded as pending offline tasks, and they are acquired to obtain multiple pending offline tasks, so that the multiple unprocessed offline tasks can be processed in time and the waiting time for offline tasks can be shortened.
[0032] In some optional implementations, in order to shorten the waiting time for unprocessed offline tasks as much as possible, it is possible to determine from the task management system whether there are currently any unprocessed offline tasks according to a preset period, and obtain newly added unprocessed offline tasks to improve the efficiency of processing offline tasks.
[0033] Step S102: Acquire first type resources, and determine resources to be allocated according to the first type resources and second type resources.
[0034] Among them, the first type of resources are the resources released by the preset online task resources. That is, when the processing volume of the online task is small and the resource volume of the online task resources is large, in order to improve resource utilization and avoid affecting the normal operation of other online tasks, the first type of resources released after the online task is completed are acquired to reallocate these resources. The second type of resources are the resources to be occupied in the preset offline task resources.
[0035] In order to make full use of resources so that multiple offline tasks can be processed in time, the resources to be allocated for multiple offline tasks are determined based on the first type of resources and the second type of resources to ensure that multiple offline tasks can be processed in time and improve resource utilization.
[0036] Step S103 : allocating the resources to be allocated to the multiple offline tasks based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, so as to process the multiple offline tasks.
[0037] The correspondence between task priorities and resource allocation weights is preconfigured so that in the process of resource allocation, offline tasks with high task priorities can be allocated more resources than offline tasks with low task priorities, so that offline tasks with high task priorities can be processed within a limited time. In some optional examples, the size of the resource allocation weight can be weighed according to factors such as the importance and urgency of the task and the availability of resources.
[0038] Therefore, in order to improve the rationality of allocation of resources to be allocated, based on the correspondence between the preset task priority and the resource allocation weight and the task priority of each offline task, the resources to be allocated are allocated according to the resource allocation weights corresponding to their respective task priorities, so that the resources to be allocated are allocated to the corresponding offline tasks according to their priorities, ensuring that offline tasks with higher task priorities can obtain resources first and complete processing faster, so that the resource allocation and utilization among multiple offline tasks can be effectively balanced, thereby achieving the purpose of improving resource utilization.
[0039] The resource allocation method provided in this embodiment can combine the first type of resources released after the online task is completed and processed with the second type of resources, determine the resources to be allocated for multiple offline tasks, and then allocate the resources to be allocated to multiple offline tasks based on the corresponding relationship between the preset task priority and the resource allocation weight and the task priority of each offline task, so as to enable multiple unprocessed offline tasks to be processed in time and ensure that offline tasks with higher task priorities can obtain resources first and complete processing faster, thereby achieving the purpose of improving resource utilization.
[0040] In this embodiment, a resource allocation method is provided, which can be used for the above-mentioned electronic devices, such as tablets, computers, servers, etc. Figure 2 is a flow chart of a resource allocation method according to an embodiment of the present disclosure, such as Figure 2 As shown, the process includes the following steps:
[0041] Step S201, obtaining multiple offline tasks to be processed.
[0042] Step S202: Acquire first type resources, and determine resources to be allocated according to the first type resources and second type resources.
[0043] Step S203 , allocating the resources to be allocated to the multiple offline tasks based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, so as to process the multiple offline tasks.
[0044] Specifically, the above step S203 includes:
[0045] Step S2031, determining the task type corresponding to each offline task respectively.
[0046] Since different task types require different amounts of resources, in order to ensure that offline tasks can be effectively processed, the task type corresponding to each offline task is determined separately to determine the target task type involved in multiple offline tasks, so that in the subsequent resource allocation, targeted allocation can be made to meet the resource requirements of offline tasks of different task types.
[0047] Step S2032: determine multiple instances corresponding to the resources to be allocated, and respectively determine the task type and data throughput corresponding to each instance.
[0048] In order to reasonably allocate the resources to be allocated, multiple instances corresponding to the resources to be allocated are determined to clarify which instances are available for multiple offline tasks, so as to improve the allocation effectiveness when resources are allocated later. The instances are used to provide a running environment for offline tasks of the corresponding task type.
[0049] Determine the task type and data throughput (Operations Per Second, OPS) corresponding to each instance respectively to better understand the task type applicable to each instance, so as to perform reasonable task allocation and resource management to meet the data processing requirements of offline tasks, thereby improving the overall efficiency and performance of the system.
[0050] Step S2033, based on the task type and data throughput corresponding to each instance, as well as the expected data throughput, task type and corresponding task priority corresponding to each offline task, corresponding available instances are allocated to multiple offline tasks according to the corresponding relationship between preset task priorities and resource allocation weights.
[0051] The task type and data throughput corresponding to the instance can be used to estimate the computing power and applicable task types provided by the instance. When resources are subsequently divided, it can be quickly determined whether the current offline task can be processed based on the matching results of the task types corresponding to multiple offline tasks. The expected data throughput corresponding to the offline task can be used to clarify the data throughput required by the offline task.
[0052] To ensure the effectiveness of resource allocation, based on the task type and data throughput corresponding to each instance, as well as the expected data throughput, task type and corresponding task priority of each offline task, corresponding available instances are allocated to multiple offline tasks according to the correspondence between the preset task priority and the resource allocation weight, so that offline tasks can obtain the same available resources as their task type, and offline tasks with high task priority can be processed faster, making the resource allocation process more reasonable and efficient, thereby helping to improve the overall performance and efficiency of the system.
[0053] In some optional implementations, the above step S2023 includes:
[0054] Step a1: Determine multiple available instances corresponding to the current task type according to the task type corresponding to each instance.
[0055] In order to determine the computing power of the first offline task under the current task type, instance division is performed according to the task type corresponding to each instance, and then multiple available instances corresponding to the current task type are determined, so that when resources are subsequently allocated, the determined multiple available instances are used to provide computing power for the first offline task under the current task type, thereby ensuring that the offline task can run on a suitable instance and obtain the required computing resources.
[0056] Step a2, according to the data throughput corresponding to each available instance, the expected data throughput corresponding to the first offline task and the corresponding task priority, and according to the corresponding relationship between the preset task priority and the resource allocation weight, determine the initial instance to be allocated corresponding to the first offline task.
[0057] In order to make full use of multiple available instances and improve the efficiency of task processing, the data throughput corresponding to each available instance is matched with the expected data throughput corresponding to the first offline task, and then according to the obtained matching results, it is possible to determine which available instances can meet the task processing requirements of the first offline task from the multiple available instances, and then obtain candidate instances. According to the task priority corresponding to the first offline task, the processing importance and urgency of the first offline task can be clarified, and then the initial instance to be allocated that is adapted to the first offline task can be selected from the candidate instances. That is, if the task priority corresponding to the current first offline task under the current task type is high, and the data throughput corresponding to the candidate instance can meet its needs, more instances can be preferentially allocated to the current first offline task. On the contrary, if the task priority corresponding to the current first offline task is low, or the data throughput corresponding to the candidate instance is limited, fewer instances may be allocated to the current first offline task to ensure that other first offline tasks with higher task priorities can obtain sufficient resource support.
[0058] Step a3: determining the expected processing time of the first offline task according to the total data throughput corresponding to the initial to-be-allocated instance and the task priority corresponding to the first offline task.
[0059] If the number of initial instances to be allocated is equal to 1, the total data throughput corresponding to the initial instances to be allocated is the data throughput corresponding to them. If the number of initial instances to be allocated is greater than 1, the total data throughput is the sum of the data throughputs corresponding to multiple initial instances to be allocated. The total data throughput can be used to estimate the total computing power that the initial instances to be allocated can provide for the first offline task.
[0060] According to the task priority corresponding to the first offline task, its importance, urgency and complexity of data processing can be clarified, and then combined with the total computing power that the initial to-be-allocated instance can provide for the first offline task, the processing speed of the first offline task can be estimated, thereby determining the expected processing time for processing the first offline task. Among them, the higher the total data throughput, the shorter the corresponding expected processing time. The lower the total data throughput, the longer the corresponding expected processing time.
[0061] Step a4, dynamically adjust the initial instance to be allocated. If the sum of the expected processing time of the first offline task in the current round and the expected processing time of the first offline tasks corresponding to other target task types is the minimum, the initial instance to be allocated is used as the available instance corresponding to the first offline task.
[0062] However, since the initial instance to be allocated may not be the optimal allocation result, a dynamic adjustment method is used for resource planning so that multiple instances corresponding to the resources to be allocated can be fully utilized. The expected processing time of the first offline task corresponding to other target task types in the current round is obtained, and then the sum of the expected processing time of the first offline task is determined in combination with the expected processing time of the first offline task. If the sum of the expected processing time of the first offline task and the expected processing time of the first offline task corresponding to other target task types in the current round is the minimum, it can be considered that the initial instance to be allocated is the optimal allocation result, and then the initial instance to be allocated is used as the available instance corresponding to the first offline task allocation, so as to utilize the available instance in the first offline task, thereby helping to reasonably plan the execution time and resource allocation of tasks and improve task processing efficiency.
[0063] Step a5: if the sum of the expected duration of the first offline task in the current round and the expected duration of the first offline tasks corresponding to other target task types is not the minimum value, then readjust the initial instance to be allocated corresponding to the first offline task to determine the available instance corresponding to the first offline task allocation.
[0064] If the expected processing time of the first offline task in the current round and the sum of the expected processing times of the first offline tasks corresponding to other target task types are the minimum, it means that multiple instances corresponding to the resources to be allocated may not be fully utilized. Therefore, in order to reduce the waste of resources, the initial instance to be allocated corresponding to the first offline task is readjusted until the sum of the expected duration of the first offline task and the expected duration of the first offline tasks corresponding to other target task types is the minimum, and the initial instance to be allocated in the corresponding round is used as the available instance corresponding to the first offline task allocation to improve the utilization rate of multiple instances.
[0065] In some optional implementations, the allocation process of allocating corresponding available instances to multiple offline tasks can be converted into a restricted multiple knapsack problem, and a dynamic programming algorithm can be used to make the best decision and determine the best allocation result, thereby helping to ensure the rationality and fairness of resource allocation. That is, by considering offline tasks as items, available instances as knapsacks, the amount of resources required by each offline task as the weight of the item, and the resource capacity of each available instance as the capacity of the knapsack, the problem can be converted into a multiple knapsack problem, and in the dynamic programming algorithm, the best allocation result can be determined by defining the state transition equation and initializing the boundary conditions, which can effectively optimize resource allocation and improve resource utilization, thereby ensuring the efficiency and fairness of offline task execution.
[0066] In some optional implementations, if there is an associated offline task associated with the first offline task among multiple offline tasks, and the processing order of the associated offline task is earlier than the processing order of the first offline task, then the available instance corresponding to the associated offline task is greater than the available instance corresponding to the first offline task. The associated offline task can be understood as an upstream task of the first offline task, and can be regarded as a subtask or dependent task of the first offline task. In order to ensure the rationality and fairness of resource allocation, when determining the available instance corresponding to the associated offline task, it is necessary to make corresponding adjustments and constraints in combination with the processing order between the first offline task and the corresponding expected data throughput to ensure that the resource allocation of the associated offline task does not exceed the resource capacity of the corresponding available instance, and after the associated offline task is processed, there will be remaining resources for the first offline task to occupy, thereby ensuring that the first offline task can be successfully completed and avoiding processing interruptions due to insufficient resources.
[0067] In other optional implementations, in response to the completion of the associated offline task processing, the total data throughput corresponding to the available instance is adjusted by the preset data throughput adjustment amount to shorten the expected processing time of the first offline task, avoid the abnormality caused by the resource allocation speed of the first offline task not keeping up, and ensure that the first offline task always has resources that can prompt it to run during the processing, thereby helping to ensure the stability of the system. Among them, the data throughput adjustment amount can be a specified adjustment amount, or it can be determined based on the number of offline tasks and the number of available instances, which is not limited here. In some examples, the total data throughput of the available instance corresponding to the first offline task can be adjusted according to a preset period, which helps to simplify the adjustment mechanism of the data throughput and facilitates the adjustment efficiency. For example: if the preset period is to adjust the total data throughput every 30 seconds, and the data throughput adjustment amount is to process 50 data per second, then after determining the total data throughput corresponding to the available instance, the data throughput adjustment amount of 50 data per second is increased every 30 seconds to prompt the data processing capacity of the available instance, so that the first offline task can be completed quickly. In other examples, in order to avoid excessive increase in total data throughput, the maximum data throughput corresponding to each offline task is limited to reduce resource contention.
[0068] The resource allocation method provided in this embodiment can ensure full utilization of resources and avoid waste and idleness of resources by obtaining first-type resources and second-type resources and determining the resources to be allocated according to the resource requirements of the task. In order to improve the rationality of resource allocation, the task type and data throughput corresponding to each instance, as well as the expected data throughput, task priority and corresponding resource allocation weight of each offline task are determined, and the corresponding available instance is allocated to each offline task, thereby not only ensuring fair allocation of resources, so that offline tasks with higher priorities can obtain more resource support and achieve fair and reasonable resource allocation, but also improving the execution efficiency of tasks, so that tasks can be run on high-performance instances and completed faster.
[0069] In this embodiment, a resource allocation method is provided, which can be used for the above-mentioned electronic devices, such as tablets, computers, servers, etc. Figure 3 is a flow chart of a resource allocation method according to an embodiment of the present disclosure, such as Figure 3 As shown, the process includes the following steps:
[0070] Step S301, obtaining multiple offline tasks to be processed.
[0071] Step S302: Acquire first type resources, and determine resources to be allocated according to the first type resources and second type resources.
[0072] Step S303 : allocating the resources to be allocated to the multiple offline tasks based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, so as to process the multiple offline tasks.
[0073] Specifically, the above step S303 includes:
[0074] In some optional implementations, the above step S303 includes:
[0075] Step S3031: divide each offline task according to the corresponding task priority to obtain at least one second offline task set.
[0076] The second offline tasks in the second offline task set have the same task priority. To improve resource allocation efficiency, each offline task is divided according to the corresponding task priority, so that resources can be allocated according to the task priority later, thereby simplifying the resource allocation process.
[0077] Step S3032: According to the correspondence between the preset task priorities and the resource allocation weights, the target resources corresponding to each second offline task set are determined from the resources to be allocated.
[0078] According to the correspondence between the preset task priorities and resource allocation weights, the resource allocation weights corresponding to each task priority can be clarified. Then, when allocating the resources to be allocated, it can be ensured that the allocation of resources meets the task priority and resource allocation weight requirements to ensure the rationality and fairness of resource allocation.
[0079] Step S3033: Allocate the target resource corresponding to each second offline task set to the corresponding second offline task set to process the second offline tasks in the corresponding second offline task set.
[0080] The target resource can be understood as a resource used to process the second offline task in the corresponding second offline task set. In order to enable the second offline task in the corresponding second offline task set to be processed in time, it is allocated to the corresponding second offline task set so that the second offline task in the corresponding second offline task set has resources that can be run.
[0081] In some optional implementations, the process of processing the second offline task corresponding to the second offline task set by the target resource corresponding to the second offline task set may be as follows:
[0082] Step b1, determining the number of second offline tasks in the current second offline task set;
[0083] Step b2: if the number of offline tasks is 1, allocating the target resource corresponding to the current second offline task set to the second offline task in the current second offline task set;
[0084] Step b3: if the number of offline tasks is greater than 1, a second offline task is randomly selected from the current second offline task set as a target offline task, and the target resource corresponding to the current second offline task set is allocated to the target offline task to process the target offline task.
[0085] Specifically, the current second offline task set is any offline task set among multiple offline task sets. Since the second offline tasks in the same second offline task set are offline tasks with the same task priority. Therefore, in order to improve the processing efficiency of the second offline task, the number of second offline tasks in the current second offline task set is determined to determine the allocation method of the target resources corresponding to the current second offline task set. If the number of offline tasks is 1, it indicates that there is no resource competition in the current second offline task set. Therefore, the target resources corresponding to the current second offline task set can be directly allocated to the second offline tasks in the current second offline task set. However, if the number of offline tasks is greater than 1, it indicates that there is resource competition in the current second offline task set. Therefore, in order to improve the offline task processing efficiency and simplify the resource allocation rules, a second offline task is randomly selected from the current second offline task set as the target offline task, and the target resources corresponding to the current second offline task set are allocated to the target offline task to process the target offline task.
[0086] The resource allocation method provided in this embodiment determines the target resources required by each second offline task set from the resources to be allocated according to the corresponding relationship between the preset task priorities and the resource allocation weights, and allocates them to the corresponding second offline task sets for processing, so as to process the second offline tasks therein, which helps to ensure that the resources to be allocated can be effectively utilized and that each offline task can be carried out smoothly, thereby improving the execution efficiency and processing capacity of the tasks.
[0087] In some optional implementations, when allocating resources to be allocated, the target resources corresponding to each second offline task set can be determined respectively, and the available instances corresponding to the target resources can be determined. Then, based on the data throughput corresponding to each available instance, and the expected data throughput and the corresponding task priority corresponding to each second offline task, instance allocation is performed for multiple second offline tasks according to the correspondence between preset task priorities and resource allocation weights, and the available instances corresponding to each second offline task are determined. Resources are divided according to the corresponding available instances, which can effectively and reasonably allocate target resources, enable each second offline task to be in operation as much as possible, and effectively improve the processing efficiency of the second offline tasks.
[0088] In other optional implementations, since the resource allocation process of online task resources and offline task resources in the resource pool is dynamically adjusted, in order to timely discover the first type of resources and ensure that the offline tasks to be processed can be processed in time, it is possible to obtain multiple offline tasks to be processed, first type of resources and second type of resources according to a preset period (for example: every 5 minutes), determine the resources to be allocated, and ensure that the unprocessed offline tasks can be processed in time, thereby effectively improving resource utilization.
[0089] In this embodiment, a resource allocation system is also provided, which is used to execute any of the above-mentioned resource allocation methods and can be deployed on the above-mentioned electronic devices, such as tablets, computers, servers, etc. Figure 4 It is a structural diagram of a resource allocation system according to an embodiment of the present disclosure.
[0090] The resource allocation system includes a task management module and a resource management module. The task management module is used to register tasks, collect task metadata, evaluate corresponding task priorities and allocate resources. In the process of resource allocation, task pending data can be provided to clarify unprocessed online tasks or offline tasks, provide the association between multiple offline tasks, and the data throughput corresponding to each instance.
[0091] The resource management module is used to ensure resource deployment and audit task deployment. Through the resource management module, the resources in the resource pool can be divided into online task resources and offline task resources in advance. For online task resources, targeted adjustments can be made through the online task resource allocation module according to the online task traffic, and the first type of resources released by the online task can be audited by the resource management module and dispatched to the offline task resource allocation module for the offline tasks to be processed. For offline task resources, the built-in polling module can be used to trigger the task selection module to regularly determine multiple offline tasks to be processed from the task management module, and the first type of resources and the second type of resources can be determined through the offline task resource allocation module, and then the resources to be allocated are used to allocate resources to multiple offline tasks, and each offline task is processed according to the allocation results. In the process of allocating resources to multiple offline tasks and processing each offline task, the data throughput of the resources to be allocated can also be adjusted according to the preset data throughput adjustment amount through the data throughput adjustment module, thereby improving the data processing capability and ensuring that resources can be fully utilized.
[0092] In this embodiment, a resource allocation device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0093] This embodiment provides a resource allocation device, such as Figure 5 As shown, including:
[0094] An acquisition module 501 is used to acquire multiple offline tasks to be processed;
[0095] The resource determination module 502 is used to obtain first-type resources and determine the resources to be allocated according to the first-type resources and the second-type resources, wherein the first-type resources are resources released by preset online task resources and the second-type resources are resources to be occupied in preset offline task resources;
[0096] The allocation module 503 is used to allocate the resources to be allocated to multiple offline tasks based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, so as to process the multiple offline tasks.
[0097] In some optional implementations, the allocation module 503 includes:
[0098] A first determining unit, used to respectively determine a task type corresponding to each offline task;
[0099] A second determining unit is used to determine multiple instances corresponding to the resources to be allocated, and respectively determine the task type and data throughput corresponding to each instance, the instance is used to provide a running environment for an offline task of the corresponding task type;
[0100] The first resource allocation unit is used to allocate corresponding available instances to multiple offline tasks based on the task type and data throughput corresponding to each instance, as well as the expected data throughput, task type and corresponding task priority corresponding to each offline task, in accordance with the corresponding relationship between preset task priorities and resource allocation weights.
[0101] In some optional implementations, the first resource allocation unit includes:
[0102] A first processing unit, configured to determine, according to a task type corresponding to each instance, a plurality of available instances corresponding to a current task type;
[0103] The second processing unit is used to determine an initial instance to be allocated corresponding to the first offline task according to the data throughput corresponding to each available instance, the expected data throughput corresponding to the first offline task and the corresponding task priority, and according to the corresponding relationship between the preset task priority and the resource allocation weight, wherein the task type corresponding to the first offline task is the current task type;
[0104] A third processing unit, configured to determine an expected processing time for processing the first offline task according to a total data throughput corresponding to the initial to-be-allocated instance and a task priority corresponding to the first offline task;
[0105] A fourth processing unit is used to dynamically adjust the initial instance to be allocated, and if the sum of the expected processing time of the first offline task in the current round and the expected processing time of the first offline tasks corresponding to other target task types is a minimum value, the initial instance to be allocated is used as the available instance corresponding to the first offline task allocation;
[0106] The fifth processing unit is used to readjust the initial to-be-allocated instance corresponding to the first offline task if the sum of the expected duration of the first offline task in the current round and the expected duration of the first offline tasks corresponding to other target task types is not a minimum value, so as to determine the available instance corresponding to the allocation of the first offline task.
[0107] In some optional implementations, if there is an associated offline task associated with the first offline task among multiple offline tasks, and the processing order of the associated offline task is earlier than the processing order of the first offline task, then the available instance corresponding to the associated offline task is greater than the available instance corresponding to the first offline task.
[0108] In some optional implementations, the first resource allocation unit further includes:
[0109] The adjustment unit is used to respond to the completion of the associated offline task processing and adjust the total data throughput corresponding to the available instance through a preset data throughput adjustment amount to shorten the expected processing time of the first offline task.
[0110] In some optional implementations, the allocation module 503 includes:
[0111] A third determining unit is used to divide each offline task according to the corresponding task priority to obtain at least one second offline task set, and the task priorities corresponding to the second offline tasks in the second offline task set are the same;
[0112] A fourth determining unit, configured to determine the target resource corresponding to each second offline task set from the resources to be allocated according to the correspondence between the preset task priorities and the resource allocation weights;
[0113] The second resource allocation unit is used to allocate the target resource corresponding to each second offline task set to the corresponding second offline task set to process the second offline task in the corresponding second offline task set.
[0114] In some optional implementations, the device for processing the second offline task corresponding to the second offline task set by the target resource corresponding to the second offline task set includes:
[0115] A first processing module is used to determine the number of second offline tasks in a current second offline task set, where the current second offline task set is any one of the multiple offline task sets;
[0116] A first scheduling module, configured to allocate the target resource corresponding to the current second offline task set to the second offline task in the current second offline task set if the number of offline tasks is 1;
[0117] The second scheduling module is used to randomly select a second offline task from the current second offline task set as a target offline task if the number of offline tasks is greater than 1, and allocate the target resource corresponding to the current second offline task set to the target offline task to process the target offline task.
[0118] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0119] The resource allocation device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0120] The present disclosure also provides an electronic device having the above Figure 5 The resource allocation device shown.
[0121] See also Figure 6 , Figure 6 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present disclosure, such as Figure 6 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0122] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0123] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0124] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 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 optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device 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.
[0125] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0126] The electronic device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0127] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0128] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0129] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0130] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0131] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0132] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0133] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0134] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A resource allocation method, It is characterized in that The method comprises: Get multiple offline tasks to be processed; Acquire first-type resources, and determine resources to be allocated based on the first-type resources and second-type resources, where the first-type resources are resources released by preset online task resources, and the second-type resources are resources to be occupied in preset offline task resources; Based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, the resources to be allocated are allocated to the multiple offline tasks to process the multiple offline tasks.
2. The method according to claim 1, It is characterized in that The allocating the to-be-allocated resources to the multiple offline tasks based on the correspondence between the preset task priorities and the resource allocation weights and the task priority of each offline task includes: Determine the task type corresponding to each offline task respectively; Determine multiple instances corresponding to the resources to be allocated, and respectively determine the task type and data throughput corresponding to each instance, wherein the instance is used to provide a running environment for an offline task of the corresponding task type; Based on the task type and data throughput corresponding to each instance, and the expected data throughput, task type and corresponding task priority corresponding to each offline task, corresponding available instances are allocated to the multiple offline tasks according to the corresponding relationship between the preset task priorities and resource allocation weights.
3. The method according to claim 2, It is characterized in that The allocating corresponding available instances to the multiple offline tasks based on the task type and data throughput corresponding to each instance, and the expected data throughput, task type and corresponding task priority corresponding to each offline task, according to the corresponding relationship between the preset task priorities and resource allocation weights, includes: According to the task type corresponding to each instance, multiple available instances corresponding to the current task type are determined; According to the data throughput corresponding to each available instance, the expected data throughput corresponding to the first offline task and the corresponding task priority, and in accordance with the correspondence between the preset task priority and the resource allocation weight, an initial instance to be allocated corresponding to the first offline task is determined, and the task type corresponding to the first offline task is the current task type; Determining an expected processing time for processing the first offline task according to a total data throughput corresponding to the initial to-be-allocated instance and a task priority corresponding to the first offline task; Dynamically adjust the initial instance to be allocated, if the sum of the expected processing time of the first offline task in the current round and the expected processing time of the first offline tasks corresponding to other target task types is a minimum value, then use the initial instance to be allocated as the available instance corresponding to the first offline task allocation; If the sum of the expected duration of the first offline task in the current round and the expected duration of the first offline tasks corresponding to other target task types is not a minimum value, the initial to-be-allocated instance corresponding to the first offline task is readjusted to determine an available instance corresponding to the allocation of the first offline task.
4. The method according to claim 3, It is characterized in that If there is an associated offline task associated with the first offline task among the multiple offline tasks, and the processing order of the associated offline task is earlier than the processing order of the first offline task, the available instance corresponding to the associated offline task is greater than the available instance corresponding to the first offline task.
5. The method according to claim 4, It is characterized in that The method allocates corresponding available instances to the multiple offline tasks based on the task type and data throughput corresponding to each instance, and the expected data throughput, task type and corresponding task priority corresponding to each offline task, according to the corresponding relationship between the preset task priorities and resource allocation weights, further comprising: In response to completion of the associated offline task processing, the total data throughput corresponding to the available instance is adjusted by a preset data throughput adjustment amount to shorten the expected processing time of the first offline task.
6. The method according to claim 1, It is characterized in that The allocating the to-be-allocated resources to the multiple offline tasks based on the correspondence between the preset task priorities and the resource allocation weights and the task priority of each offline task includes: Dividing each offline task according to a corresponding task priority to obtain at least one second offline task set, wherein the task priorities corresponding to the second offline tasks in the second offline task set are the same; According to the correspondence between the preset task priorities and resource allocation weights, respectively determining the target resources corresponding to each second offline task set from the resources to be allocated; The target resource corresponding to each second offline task set is allocated to the corresponding second offline task set to process the second offline tasks in the corresponding second offline task set.
7. The method according to claim 6, It is characterized in that The method for processing a second offline task corresponding to a second offline task set by using a target resource corresponding to the second offline task set includes: Determine the number of second offline tasks in a current second offline task set, where the current second offline task set is any one of the multiple offline task sets; If the number of offline tasks is 1, allocating the target resource corresponding to the current second offline task set to the second offline task in the current second offline task set; If the number of offline tasks is greater than 1, a second offline task is randomly selected from the current second offline task set as a target offline task, and a target resource corresponding to the current second offline task set is allocated to the target offline task to process the target offline task.
8. A resource allocation device, It is characterized in that The device comprises: An acquisition module is used to acquire multiple offline tasks to be processed; A resource determination module, used to obtain first-type resources and determine resources to be allocated based on the first-type resources and second-type resources, wherein the first-type resources are resources released by preset online task resources and the second-type resources are resources to be occupied in preset offline task resources; The allocation module is used to allocate the resources to be allocated to the multiple offline tasks based on the corresponding relationship between the preset task priorities and the resource allocation weights and the task priority of each offline task, so as to process the multiple offline tasks.
9. An electronic device, It is characterized in that include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the resource allocation method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the resource allocation method according to any one of claims 1 to 7.
11. A computer program product, It is characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the resource allocation method according to any one of claims 1 to 7.
Citation Information
Cited By
Task processing method, task processing system, electronic equipment and storage medium
CN121979687A
