Resource allocation method and device, electronic equipment and storage medium

By distinguishing the types of target resource occupancy tasks and adopting corresponding allocation strategies, the problem of unbalanced resource allocation in multi-cluster management scenarios is solved, and resource utilization is improved.

CN119883631AActive Publication Date: 2025-04-25CHINA TELECOM CORP LTD

Patent Information

Application Number
CN202411974209.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

In the multi-cluster management scenario, it is difficult for the existing technology to effectively allocate resources, resulting in unbalanced resource allocation and reducing resource utilization.

Method used

By distinguishing the types of target resource occupancy tasks, quickly locate and allocate cluster resources for tasks that occupy resources with preset time, and gradually allocate resources through task queues to avoid excessive resource occupancy.

Benefits of technology

The dynamic allocation of resources of multiple clusters is achieved, the purpose of balancing resources is allocated, the resource utilization rate is improved, and the problem of low resource utilization rate caused by unbalanced cluster resource allocation is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883631A_ABST
    Figure CN119883631A_ABST
Patent Text Reader

Abstract

The invention discloses a resource allocation method and device, electronic equipment and a storage medium. The method comprises the steps that a target resource occupation task is acquired, and the target resource occupation task is used for requesting to occupy resources in multiple clusters; under the condition that the task type of the target resource occupation task is a first type, determining a first cluster successfully matched with the target resource occupation task from a plurality of clusters, and allocating resources of the first cluster to the target resource occupation task; under the condition that the task type of the target resource occupation task is a second type, storing the target resource occupation task to a task queue corresponding to the second type, and under the condition that a preset condition is met, determining a second cluster successfully matched with the target resource occupation task from a plurality of clusters, and allocating resources of the second cluster to the target resource occupation task. According to the invention, the technical problem of low resource utilization rate caused by unbalanced cluster resource allocation in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computers and resource allocation, and in particular to a resource allocation method, device, electronic equipment and storage medium. Background Art

[0002] With the rapid development of cloud computing, virtualization and big data technologies, communication services are usually deployed in cloud environments in order to achieve more efficient and flexible computing resource management and utilization. In this context, cloud deployment of communication services has become a trend, which can not only improve the efficiency of business operations, but also enhance the elasticity and scalability of services through resource sharing. However, the problem of resource allocation in cloud environments has also become prominent, especially in multi-cluster management scenarios, where the necessity and challenges of resource allocation have become more significant.

[0003] In the related technology, resources can be allocated through bidding instances, but because bidding instances are usually concentrated in one cluster, it is difficult to allocate resources to different clusters, which may cause some tasks to occupy too many resources and unbalanced resource allocation, thereby reducing resource utilization.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a resource allocation method, device, electronic device and storage medium to at least solve the technical problem of low resource utilization caused by unbalanced cluster resource allocation in the related art.

[0006] According to one aspect of an embodiment of the present invention, a resource allocation method is provided, comprising: obtaining a target resource occupying task, wherein the target resource occupying task is used to request to occupy resources in multiple clusters; when the task type of the target resource occupying task is a first type, determining a first cluster that successfully matches the target resource occupying task from multiple clusters, and allocating resources of the first cluster to the target resource occupying task, wherein the first type is used to characterize that the time for resource occupation by the target resource occupying task is preset; when the task type of the target resource occupying task is a second type, storing the target resource occupying task in a task queue corresponding to the second type, and when a preset condition is met, determining a second cluster that successfully matches the target resource occupying task from multiple clusters, and allocating resources of the second cluster to the target resource occupying task.

[0007] Optionally, determining a first cluster that successfully matches the target resource occupying task from multiple clusters includes: determining a first candidate cluster that matches the target resource occupying task from multiple clusters; when the number of first candidate clusters is one, determining the first candidate cluster as the first cluster; when the number of first candidate clusters is multiple, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters, wherein the cluster evaluation indicators include at least one of the following: processor allocation ratio, memory allocation ratio, central processing unit allocation ratio and comprehensive allocation ratio, and the comprehensive allocation ratio is obtained by summarizing the processor allocation ratio, memory allocation ratio and central processing unit allocation ratio.

[0008] Optionally, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters; when the number of second candidate clusters is one, determining the second candidate cluster as the first cluster; when the number of second candidate clusters is multiple, determining the first cluster from multiple second candidate clusters based on a balanced allocation strategy.

[0009] Optionally, when there is no first cluster among multiple clusters that successfully matches the target resource-occupying task, the above method also includes: determining a third cluster and a preset resource-occupying task from multiple clusters, wherein the resources of the third cluster have been allocated to the second type of resource-occupying tasks, and the task type of the preset resource-occupying task is the second type; releasing the resources in the third cluster allocated to the preset resource-occupying task; and allocating the resources of the third cluster to the target resource-occupying task.

[0010] Optionally, determining a third cluster and a preset resource-occupying task from multiple clusters includes: determining a third candidate cluster from multiple clusters, resources of the third candidate cluster have been allocated to the second type of resource-occupying tasks; determining a resource evaluation indicator of the allocated resources of the third candidate cluster, wherein the allocated resources are used to characterize the resources allocated to the second type of resource-occupying tasks; and determining the third cluster and the preset resource-occupying task based on the resource evaluation indicator of the allocated resources.

[0011] Optionally, based on the resource evaluation indicators of the allocated resources, a third cluster and a preset resource occupation task are determined, including: when the resource evaluation indicators of the allocated resources are different, determining the third candidate cluster where the allocated resources corresponding to the minimum resource evaluation indicator are located as the third cluster, and determining the allocated resources corresponding to the minimum resource evaluation indicator as the preset resource occupation task; when the resource evaluation indicators of the allocated resources are the same, determining the third cluster from multiple third candidate clusters based on a balanced allocation strategy.

[0012] Optionally, when the task type of the target resource-occupying task is the first type, the above method also includes: storing the target resource-occupying task in a task queue corresponding to the first type; reading the current resource-occupying task from the task queue corresponding to the first type; determining the current cluster that successfully matches the current resource-occupying task from multiple clusters, and allocating resources of the current cluster to the current resource-occupying task.

[0013] Optionally, the above method also includes: when detecting that a new cluster has joined multiple clusters, determining the balance variance of the updated multiple clusters, wherein the updated multiple clusters include multiple clusters and the new cluster; based on the balance variance, determining the resource occupying tasks to be migrated from the multiple clusters, wherein the new balance variance obtained after the resource occupying tasks to be migrated are migrated to the new cluster is less than the balance variance; and migrating the resource occupying tasks to be migrated to the new cluster.

[0014] According to another aspect of an embodiment of the present invention, a resource allocation device is also provided, including: an acquisition module, used to acquire a target resource occupying task, wherein the target resource occupying task is used to request to occupy resources in multiple clusters; a first allocation module, used to determine a first cluster that successfully matches the target resource occupying task from multiple clusters when the task type of the target resource occupying task is a first type, and allocate resources of the first cluster to the target resource occupying task, wherein the first type is used to characterize that the time for resource occupation by the target resource occupying task is preset; a second allocation module, used to store the target resource occupying task in a task queue corresponding to the second type when the task type of the target resource occupying task is a second type, and determine a second cluster that successfully matches the target resource occupying task from multiple clusters when a preset condition is met, and allocate resources of the second cluster to the target resource occupying task.

[0015] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.

[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.

[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.

[0018] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.

[0019] According to another aspect of the embodiments of the present invention, a computer program is further provided. When the computer program is executed by a processor, the methods in the embodiments of the present invention are implemented.

[0020] In an embodiment of the present invention, a target resource occupying task is obtained, wherein the target resource occupying task is used to request to occupy resources in multiple clusters; when the task type of the target resource occupying task is the first type, a first cluster that successfully matches the target resource occupying task is determined from multiple clusters, and the resources of the first cluster are allocated to the target resource occupying task; when the task type of the target resource occupying task is the second type, the target resource occupying task is stored in a task queue corresponding to the second type, and when a preset condition is met, a second cluster that successfully matches the target resource occupying task is determined from multiple clusters, and the resources of the second cluster are allocated to the target resource occupying task. It is easy to notice that by distinguishing target resource occupying tasks of different task types, for tasks that occupy resources for a preset time, cluster resources can be quickly located and allocated, and for tasks that need to wait for resources, resources can be gradually allocated through the task queue to avoid excessive resource occupation, thereby realizing dynamic allocation of multiple cluster resources, achieving the purpose of balanced resource allocation, and thus achieving the technical effect of improving resource utilization, thereby solving the technical problem of low resource utilization caused by unbalanced cluster resource allocation in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0022] Figure 1 is a hardware structure block diagram of a computer terminal for implementing a resource allocation method according to an embodiment of the present application;

[0023] Figure 2 is a flow chart of a resource allocation method according to an embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of an optional resource allocation method according to an embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of an optional resource allocation method for a newly added cluster according to an embodiment of the present invention;

[0026] Figure 5 is a schematic diagram of a resource allocation device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] According to an embodiment of the present invention, an embodiment of a resource allocation method 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.

[0030] The resource allocation method embodiment provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a resource allocation method. Figure 1As shown, the computer terminal 10 may include one or more (102a, 102b, ..., 102n are used to illustrate) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0031] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0032] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the resource allocation method in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the IP address allocation method of the above-mentioned application program is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 10 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 a combination thereof.

[0033] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .

[0034] Figure 2 is a flow chart of a resource allocation method according to an embodiment of the present invention. Figure 2 As shown, the method comprises the following steps:

[0035] Step S202, obtaining the target resource occupying task.

[0036] The target resource occupation task is used to request to occupy resources in multiple clusters.

[0037] The above-mentioned target resource occupation task can be used to request to occupy resources in multiple clusters. Through the target resource occupation task, the problem of cross-cluster resource allocation and optimization of resource utilization efficiency can be solved. The target resource occupation task can be a data processing task, a backup task, or a distributed computing task, etc. The content of the target resource occupation task is not limited here and can be determined as needed.

[0038] The target resource-occupying tasks can be applications or workloads that need to be executed in the computing environment. These tasks consume computing resources, such as memory and accelerator resources. In cloud computing or container orchestration scenarios, the target resource-occupying tasks can be applications, services, or data processing tasks submitted by users. Effective scheduling of target resource-occupying tasks is essential for optimizing resource usage and improving system performance.

[0039] The allocation of target resource-occupying tasks is crucial in cloud computing and cluster management scenarios. By allocating these tasks properly, resources can be effectively utilized and waste or over-allocation of resources can be avoided. Intelligent resource allocation can achieve efficient resource utilization and improve the overall performance of the system. In a multi-cluster or multi-node environment, balanced task allocation can avoid overloading some clusters or nodes while other clusters or nodes are idle. Load balancing helps maintain system stability and responsiveness, ensuring that all clusters or nodes are effectively utilized. In a cloud environment, resource usage is often directly related to cost. By strategically allocating target resource-occupying tasks, such as giving priority to using lower-cost spot instances, operating costs can be effectively controlled while ensuring service quality and response time. It can also ensure that critical tasks or high-priority target resource-occupying tasks can obtain sufficient resources to maintain a high-quality service level. This not only affects the completion speed of the task, but also the end-user experience. Automatically adjust resource allocation when the task volume of the target resource-occupying tasks changes, such as adding resources during peak demand periods and reducing resources during low demand periods, to achieve elastic scaling of the system. And through cross-cluster task allocation, when a cluster or node fails, tasks can be quickly switched to other healthy clusters or nodes, improving the system's fault tolerance and disaster recovery speed. According to different business strategies, such as priority and performance requirements, the target resource-occupying tasks are allocated to matching clusters or nodes to run, improving computing efficiency.

[0040] In an optional embodiment, the task to be processed will be added to a pending scheduling queue, and the target resource occupying task can be obtained from the pending scheduling queue. Alternatively, the target resource occupying task can also be obtained through a scheduler. Alternatively, a task request automatically submitted by a user or a system can be received, and a task identifier can be obtained by parsing the task request to obtain the target resource occupying task.

[0041] Step S204: when the task type of the target resource occupying task is the first type, determine a first cluster that successfully matches the target resource occupying task from multiple clusters, and allocate resources of the first cluster to the target resource occupying task.

[0042] The first type is used to indicate that the resource occupation time of the target resource occupation task is preset.

[0043] The target resource occupation tasks can be divided into different task types according to the demand for resources and different operations. For example, in a container orchestration system such as K8s, the target resource occupation tasks can be divided into regular instance tasks, bidding instance tasks, batch tasks, fixed time tasks, elastic scaling tasks, etc. The task types of the target resource occupation tasks are not limited here and can be determined as needed. Different allocation strategies can be adopted according to different task types. For example, for regular instance tasks, it is necessary to ensure a stable supply of resources to avoid service interruption. For batch and fixed time tasks, resources in non-peak hours can be used to avoid idle resources and improve the overall utilization efficiency of resources. Elastic scaling tasks can automatically adjust resources according to real-time loads to ensure stable services even when the load fluctuates greatly. By distinguishing task types, the risk tolerance of different tasks can also be considered. For example, more stable resources can be provided for critical tasks, while non-critical tasks can be interrupted when resources are tight.

[0044] The first type mentioned above can be used to characterize that the target resource occupying task has a preset resource occupying time. The first type of target resource occupying task can be a regular instance task, a fixed time task, etc., such as database operation, log cleaning, etc. The first type of target resource occupying task is not limited here and can be determined as needed. Regular instance tasks may refer to applications, services or jobs running on non-preemptive resources. These tasks will be guaranteed resources when they are started and will not be interrupted due to fluctuations in resource prices or changes in resource demand. It provides stable services with guaranteed resource usage, which is suitable for services that require high availability and stable operation. Regular instance tasks are usually billed at a fixed price and are not affected by the time or amount of resource usage.

[0045] In the computing field, the above-mentioned cluster can be a collection of multiple nodes, which are connected together through a network and work together to complete the target resource occupation task or provide services. Through the computing power and storage resources of multiple nodes in the cluster, higher performance, higher availability, larger storage capacity and better scalability services are provided. The cluster can be a high-performance computing cluster, a distributed cluster, a load balancing cluster, a high-availability cluster, a container cluster, etc. The cluster is not limited here and can be determined as needed. The first cluster among the multiple clusters can successfully match the target resource occupation task to process the target resource occupation task.

[0046] In an optional embodiment, when it is determined that the task type of the target resource occupying task is the first type, the first cluster can be selected according to the current resource utilization of the cluster. By monitoring the resource usage of each cluster,

[0047] When receiving a target resource occupation task of the first type, the resource utilization of the clusters will be compared according to the task requirements, and the cluster whose current resource utilization is lower than the preset threshold will be selected as the first cluster, which can effectively avoid the problem of excessive resource concentration and improve the overall resource utilization. Then the target resource occupation task will be started on the first cluster.

[0048] In another optional embodiment, the first cluster can also be matched from multiple clusters through a service quality priority strategy. The specific requirements and service quality of the task can be considered. Among multiple clusters, the network delay, storage speed, hardware configuration and historical performance data of the cluster can be comprehensively considered to determine whether the first cluster can provide services for the first type of target resource occupation task. For example, if the target resource occupation task has a high requirement for network delay, the cluster with the lowest network delay is given priority. This method ensures that critical tasks are guaranteed in terms of response time and performance. The target resource occupation task is then started on the first cluster.

[0049] In another optional embodiment, a cluster list can also be maintained, which records the clusters to which new tasks are assigned. The cluster list may include cluster identifiers and task type identifiers. When a target resource occupying task of the first type is received, the corresponding cluster identifier is selected based on the task type identifier to determine the first cluster. The correspondence between the cluster identifier and the task type identifier can be set manually or automatically generated by the system. For example, for the target resource occupying task of the first type, the first cluster can also be selected based on the task execution time, which helps to balance the task load between clusters and avoid clusters being in a high load state or idle state for a long time. By polling or time-based weight adjustment, the matching strategy can be further optimized to ensure balance between clusters. The target resource occupying task is then started on the first cluster.

[0050] Step S206, when the task type of the target resource occupying task is the second type, the target resource occupying task is stored in a task queue corresponding to the second type, and when a preset condition is met, a second cluster that successfully matches the target resource occupying task is determined from multiple clusters, and resources of the second cluster are allocated to the target resource occupying task.

[0051] The above-mentioned second type of target resource occupation tasks may be batch processing tasks, data backup tasks, spot instance tasks, etc. The second type of target resource occupation tasks are not limited here and can be determined as needed. Among them, the spot instance task may be a task that runs on the spot instance resources. Spot instance is a resource provided by a cloud service provider. The price of spot instance resources is low, but the stability and availability of resources are low. It is suitable for batch processing tasks or background jobs that can tolerate interruptions or unstable resources. For example, a spot instance task may be to perform data analysis or machine learning model training. Such tasks can usually tolerate interruptions because they can be designed to be recoverable from breakpoints and are suitable for running on spot instances to save costs.

[0052] In an optional embodiment, when it is determined that the task type of the target resource occupying task is the second type, the target resource occupying task can be first stored in the task queue corresponding to the second type, so that when there are available resources or the cost reaches the expected, the target resource occupying task of the second type is allocated appropriate cluster resources. Specifically, the task type can be identified by the task tag, and when the task tag is read as the second type, the target resource occupying task of the second type is stored in the task queue corresponding to the second type in sequence according to the timestamp. Alternatively, according to the priority of the target resource occupying task, the target resource occupying task is stored in the task queue corresponding to the second type according to the priority. The priority can be determined based on the urgency of the task, resource requirements or business value, etc., or it can be determined artificially, or it can be set according to a preset storage rule. Thus, the queue can be sequentially dequeued according to the order of tasks in the queue.

[0053] Furthermore, the state of the task queue and the resource state and cost of the cluster can be checked to allocate appropriate cluster resources to the second type of target resource occupying tasks. Optionally, for the second type of target resource occupying tasks in the task queue, by evaluating whether the resources of the cluster meet the requirements of the task, and comparing the costs, a cluster with the lowest cost and resources that meet the requirements is selected as the second cluster. After the second cluster is determined, the task is removed from the task queue, and the task is started on the second cluster to allocate the required resources.

[0054] Alternatively, a second cluster that successfully matches the target resource occupying task can be determined from multiple clusters based on a preset matching rule, and then the target resource occupying task can be started on the second cluster. Alternatively, historical data and machine learning models can be combined to predict future resource requirements. When a target resource occupying task of the second type is received, a second cluster is selected based on current resource data and prediction results, and the task is started on the second cluster to allocate the required resources.

[0055] In an embodiment of the present invention, a target resource occupying task is obtained, wherein the target resource occupying task is used to request to occupy resources in multiple clusters; when the task type of the target resource occupying task is the first type, a first cluster that successfully matches the target resource occupying task is determined from multiple clusters, and the resources of the first cluster are allocated to the target resource occupying task; when the task type of the target resource occupying task is the second type, the target resource occupying task is stored in a task queue corresponding to the second type, and when a preset condition is met, a second cluster that successfully matches the target resource occupying task is determined from multiple clusters, and the resources of the second cluster are allocated to the target resource occupying task. It is easy to notice that by distinguishing target resource occupying tasks of different task types, for tasks that occupy resources for a preset time, cluster resources can be quickly located and allocated, and for tasks that need to wait for resources, resources can be gradually allocated through the task queue to avoid excessive resource occupation, thereby realizing dynamic allocation of multiple cluster resources, achieving the purpose of balanced resource allocation, and thus achieving the technical effect of improving resource utilization, thereby solving the technical problem of low resource utilization caused by unbalanced cluster resource allocation in related technologies.

[0056] Optionally, determining a first cluster that successfully matches the target resource occupying task from multiple clusters includes: determining a first candidate cluster that matches the target resource occupying task from multiple clusters; when the number of first candidate clusters is one, determining the first candidate cluster as the first cluster; when the number of first candidate clusters is multiple, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters, wherein the cluster evaluation indicators include at least one of the following: processor allocation ratio, memory allocation ratio, central processing unit allocation ratio and comprehensive allocation ratio, and the comprehensive allocation ratio is obtained by summarizing the processor allocation ratio, memory allocation ratio and central processing unit allocation ratio.

[0057] In an optional embodiment, a first candidate cluster matching the target resource occupying task can be determined from multiple clusters according to a preset mapping rule. The preset mapping rule can be a mapping relationship between a task identifier and a cluster. The mapping relationship can be determined manually or obtained based on analysis of historical allocation data. Alternatively, the usage parameters of the cluster resources can be compared with the resource requirement parameters of the target resource occupying task, and a hash value or regular expression comparison can be performed. When the similarity of the resource parameters of the two is greater than a preset threshold, the first candidate cluster is determined. Thus, when the number of the first candidate clusters is one, the first candidate cluster can be determined to be the first cluster.

[0058] In the case where there are multiple first candidate clusters, the first cluster can be determined from the multiple first candidate clusters based on the cluster evaluation indicators of the multiple first candidate clusters. Specifically, a weighted score can be calculated for each cluster in the multiple first candidate clusters based on the cluster evaluation indicator, and then the first cluster can be selected according to the weighted scores of each cluster of the first candidate cluster. Alternatively, the first cluster can also be predicted from the multiple first candidate clusters according to the first matching model. The first matching model predicts the first cluster by learning the relationship between the cluster evaluation indicator and the historical first cluster. The first matching model can be a decision tree, a random forest, a cluster analysis model, etc. The first matching model is not limited here and can be determined as needed. The first cluster can be used to implement a first type of target resource occupation task to meet the resource requirements of the target resource occupation task.

[0059] The cluster evaluation index includes at least one of the following: processor allocation ratio, memory allocation ratio, central processing unit allocation ratio and comprehensive allocation ratio. The cluster evaluation index is not limited here and can be determined as needed. Among them, the comprehensive allocation ratio is obtained by summarizing the processor allocation ratio, memory allocation ratio and central processing unit allocation ratio. The processor allocation ratio can be used to characterize the situation where the processor is allocated for use. The memory allocation ratio can be used to show the situation where the memory is allocated for use. The central processing unit allocation ratio can be used to characterize the situation where the central processing unit is allocated for use. The comprehensive allocation ratio can be used to evaluate the resource utilization efficiency of the cluster.

[0060] For example, the CPU allocation percentage can be determined by the following formula:

[0061]

[0062] Where P1 is the CPU allocation ratio, t k is the CPU usage of the kth running task in the cluster, T is the total number of CPUs in the cluster, and n is the total number of tasks running in the cluster.

[0063] For example, the memory allocation ratio can be determined by the following formula:

[0064]

[0065] Where P2 is the memory allocation ratio, t k is the memory usage of the kth running task in the cluster, T is the total memory of the cluster, and n is the total number of tasks running in the cluster;

[0066] For example, the processor allocation percentage can be determined by the following formula:

[0067]

[0068] Where P3 is the processor allocation ratio, t k is the processor occupancy of the kth running task in the cluster, T is the total number of processors, and n is the total number of running tasks.

[0069] For example, the comprehensive allocation ratio can be determined by the following formula:

[0070]

[0071] In the formula, x is the comprehensive allocation ratio, P1 is the CPU allocation ratio, P2 is the memory allocation ratio, and P3 is the processor allocation ratio.

[0072] In this way, the fairness and rationality of resource allocation can be ensured, avoiding excessive concentration of resources in certain clusters, which would lead to resource waste and uneven system load. It is particularly suitable for processing resource-intensive tasks, such as deep learning model training, large-scale data processing and other scenarios.

[0073] Optionally, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters; when the number of second candidate clusters is one, determining the second candidate cluster as the first cluster; when the number of second candidate clusters is multiple, determining the first cluster from multiple second candidate clusters based on a balanced allocation strategy.

[0074] In an optional embodiment, a weighted score can be calculated for each cluster in the multiple first candidate clusters based on the cluster evaluation index, and then for the clusters whose weighted scores of each cluster of the first candidate cluster are greater than the preset scores, these clusters are determined to be second candidate clusters. Alternatively, the first cluster can also be predicted from the multiple first candidate clusters according to the second matching model. The second matching model predicts the second candidate cluster by learning the relationship between the cluster evaluation index and the historical second candidate clusters. The second matching model can be a decision tree, a random forest, a cluster analysis model, etc. The second matching model is not limited here and can be determined as needed.

[0075] And when the number of the second candidate clusters is one, the second candidate cluster is determined as the first cluster. When the number of the second candidate clusters is multiple, a balanced allocation strategy can be used to determine the first cluster from multiple second candidate clusters. The balanced allocation strategy can be determined based on minimum difference selection, weighted random selection, resource utilization ratio, etc. The minimum difference selection method is to compare the difference between the clusters in the second candidate cluster and the cluster resource allocation target or the average resource utilization rate, and select the cluster with the smallest difference as the first cluster. The weighted random selection assigns a weight to each cluster in the second candidate cluster, and the weight can be determined based on indicators such as the current resource utilization rate, resource price or historical performance of the cluster. Then, a cluster is selected as the first cluster through a weighted random algorithm. This method helps to take into account cost-effectiveness and cluster performance while maintaining balance. The resource utilization ratio is to calculate the resource utilization ratio of each cluster in the second candidate cluster, and select the cluster whose ratio is closest to the preset balanced ratio as the first cluster.

[0076] This method further refines the resource allocation process and ensures balanced distribution of resources. It can effectively improve system stability and user experience for scenarios that require high-concurrency processing, such as online trading systems and real-time data analysis.

[0077] Optionally, when there is no first cluster among multiple clusters that successfully matches the target resource-occupying task, the above method also includes: determining a third cluster and a preset resource-occupying task from multiple clusters, wherein the resources of the third cluster have been allocated to the second type of resource-occupying tasks, and the task type of the preset resource-occupying task is the second type; releasing the resources in the third cluster allocated to the preset resource-occupying task; and allocating the resources of the third cluster to the target resource-occupying task.

[0078] In multiple clusters, there are tasks to be assigned in the regular instance task queue, but no cluster's resources can directly meet their needs. At the same time, there are some clusters whose resources are largely occupied by the bid instance tasks, resulting in high resource utilization. Therefore, the first type of target resource occupying tasks can be executed with the help of the cluster used to implement the second type of target resource occupying tasks. For example, for regular instance tasks, if there is no cluster that meets the resource requirement conditions, the cluster that can shut down the bid instance task is calculated to use the cluster for regular instance tasks. The bid instance of the cluster that meets the resource requirements of the regular instance task can be shut down through the balanced allocation strategy. After the closure, the cluster is assigned to the current regular instance task to execute the regular instance task.

[0079] In an optional embodiment, the third cluster and the preset resource occupying task may be determined from multiple clusters according to a preset cluster allocation table. Alternatively, the third cluster and the preset resource occupying task may also be determined from multiple clusters according to task type, cluster evaluation index, etc. Among them, the resources of the third cluster have been allocated to the resource occupying task of the second type, and the task type of the preset resource occupying task is the second type.

[0080] Further, the preset resource occupying task in the third cluster is closed to release the resources occupied by the task. Then, the target resource occupying task is assigned to the third cluster to use the just released resources.

[0081] This dynamic adjustment mechanism can effectively respond to sudden changes in resource demand and ensure that important or urgent tasks can obtain resources in a timely manner. It is suitable for systems with high availability requirements, such as financial transactions, emergency rescue command, etc.

[0082] Optionally, determining a third cluster and a preset resource-occupying task from multiple clusters includes: determining a third candidate cluster from multiple clusters, resources of the third candidate cluster have been allocated to the second type of resource-occupying tasks; determining a resource evaluation indicator of the allocated resources of the third candidate cluster, wherein the allocated resources are used to characterize the resources allocated to the second type of resource-occupying tasks; and determining the third cluster and the preset resource-occupying task based on the resource evaluation indicator of the allocated resources.

[0083] In an optional embodiment, a third candidate cluster may be determined from multiple clusters based on a preset cluster allocation table, a cluster evaluation index or a type identifier, and resources of the third candidate cluster are allocated to the resource occupying tasks of the second type.

[0084] Furthermore, the resource evaluation index of the allocated resources of the third candidate cluster can be determined by the server usage data, the memory usage data or the usage data of the central server, wherein the allocated resources can be used to characterize the resources allocated to the second type of resource occupying tasks. Then, the third cluster and the preset resource occupying tasks can be determined based on resource evaluation indicators such as resource utilization indicators, resource pressure indicators, and resource consumption indicators. For example, the resource utilization indicator can be the number of processors, the number of central processing units, or the amount of memory, etc. The resource utilization indicator is not limited here and can be determined as needed.

[0085] By evaluating the usage of allocated resources, resource recovery and reallocation can be performed more accurately.

[0086] Optionally, based on the resource evaluation indicators of the allocated resources, a third cluster and a preset resource occupation task are determined, including: when the resource evaluation indicators of the allocated resources are different, determining the third candidate cluster where the allocated resources corresponding to the minimum resource evaluation indicator are located as the third cluster, and determining the allocated resources corresponding to the minimum resource evaluation indicator as the preset resource occupation task; when the resource evaluation indicators of the allocated resources are the same, determining the third cluster from multiple third candidate clusters based on a balanced allocation strategy.

[0087] In an optional embodiment, when the resource evaluation indicators of the allocated resources are different, they can be determined manually, or a sorting algorithm can be used to determine that the third candidate cluster where the allocated resources corresponding to the minimum resource evaluation indicator are located is the third cluster, and the allocated resources corresponding to the minimum resource evaluation indicator are determined to be the preset resource occupying tasks.

[0088] For example, based on the processor allocation ratio of each cluster in the third candidate cluster, the third candidate cluster where the allocated resources corresponding to the smallest processor allocation ratio are located can be selected as the third cluster, and the allocated resources corresponding to the smallest processor allocation ratio can be determined as the preset resource occupying task. Alternatively, based on the memory allocation ratio of each cluster in the third candidate cluster, the third candidate cluster where the allocated resources corresponding to the smallest memory allocation ratio are located can be selected as the third cluster, and the allocated resources corresponding to the smallest memory allocation ratio can be determined as the preset resource occupying task. Alternatively, based on the central processing unit allocation ratio of each cluster in the third candidate cluster, the third candidate cluster where the allocated resources corresponding to the smallest central processing unit allocation ratio are located can be selected as the third cluster, and the allocated resources corresponding to the smallest central processing unit allocation ratio can be determined as the preset resource occupying task.

[0089] When the resource evaluation indicators of the allocated resources are all the same, the third cluster can be determined from multiple third candidate clusters based on a balanced allocation strategy. The balanced allocation strategy can be determined based on minimum difference selection, weighted random selection, resource utilization ratio, etc. The minimum difference selection method compares the difference between the clusters in the third candidate cluster and the cluster resource allocation target or the average resource utilization rate, and selects the cluster with the smallest difference as the third cluster. Weighted random selection assigns a weight to each cluster in the third candidate cluster, and the weight can be determined based on indicators such as the current resource utilization rate, resource price or historical performance of the cluster. Then, a cluster is selected as the third cluster through a weighted random algorithm. The resource utilization ratio is to calculate the resource utilization ratio of each cluster in the third candidate cluster, and select the cluster whose ratio is closest to the preset balanced ratio as the third cluster.

[0090] This can ensure efficient use of resources and avoid idleness and waste of resources. It is particularly suitable for scenarios where resource demands change frequently, and can effectively improve resource utilization efficiency and system processing capabilities.

[0091] Optionally, when the task type of the target resource-occupying task is the first type, the above method also includes: storing the target resource-occupying task in a task queue corresponding to the first type; reading the current resource-occupying task from the task queue corresponding to the first type; determining the current cluster that successfully matches the current resource-occupying task from multiple clusters, and allocating resources of the current cluster to the current resource-occupying task.

[0092] In an optional embodiment, the task type can be identified by the task tag. When the task tag is read as the first type, the target resource occupying task is stored in the task queue corresponding to the first type in sequence according to the timestamp. Alternatively, according to the priority of the target resource occupying task, the target resource occupying task is stored in the task queue corresponding to the first type in accordance with the priority. The priority can be determined based on the urgency of the task, resource requirements or business value, or it can be determined manually, or it can be set according to a preset storage rule. Thus, the tasks can be dequeued in sequence according to the order of the tasks in the queue.

[0093] Then, the current resource occupying task can be read from the task queue corresponding to the first type according to the timestamp or priority. Further, the current cluster that successfully matches the current resource occupying task can be determined from multiple clusters according to a preset cluster allocation list or cluster evaluation index, and the resources of the current cluster can be allocated to the current resource occupying task.

[0094] Through the management of task queues, priority processing of different types of tasks can be achieved to ensure the timely execution of important tasks. It is suitable for scenarios that require task priority management.

[0095] Optionally, the above method also includes: when detecting that a new cluster has joined multiple clusters, determining the balance variance of the updated multiple clusters, wherein the updated multiple clusters include multiple clusters and the new cluster; based on the balance variance, determining the resource occupying tasks to be migrated from the multiple clusters, wherein the new balance variance obtained after the resource occupying tasks to be migrated are migrated to the new cluster is less than the balance variance; and migrating the resource occupying tasks to be migrated to the new cluster.

[0096] In an optional embodiment, when it is detected that a new cluster joins multiple clusters, the balance variance of the updated multiple clusters can be determined according to the cluster evaluation index. The updated multiple clusters include multiple clusters and the new cluster. Then, for the tasks that can be migrated, the new balance variance after migration is calculated respectively, and the impact of the tasks on the updated multiple clusters after migration to the new cluster is calculated. The migration tasks whose new balance variance is less than the balance variance are screened out and determined as the resource occupying tasks to be migrated. Thus, the resource occupying tasks to be migrated are stopped from the current cluster. Resources are allocated to the resource occupying tasks to be migrated in the new cluster, and the tasks are started.

[0097] For example, the balance variance can be determined by the following formula:

[0098]

[0099] Among them, Z is the balance variance, P i is the comprehensive allocation ratio of the ith cluster, P i-1 is the comprehensive allocation ratio of the i-1th cluster, and m is the total number of clusters.

[0100] In another optional embodiment, the balance variance of multiple clusters after determination and update can also be obtained through a machine learning model. The machine learning model can be trained with historical data to predict the impact of task migration on the balance variance. For tasks that can be migrated, the machine learning model can be used to predict the new balance variance after migration to the new cluster one by one. The task with the smallest predicted value is selected as the resource occupancy task to be migrated. Then, the task migration is performed, and the machine learning model is updated according to the actual impact to improve the accuracy of the prediction.

[0101] This dynamic balancing mechanism can quickly adapt to changes in system scale and ensure the rational distribution of resources. It is suitable for scenarios that require continuous optimization of resource allocation and can effectively improve the overall performance and resource utilization of the system.

[0102] Figure 3 is a schematic diagram of an optional resource allocation method according to an embodiment of the present invention, such as Figure 3 As shown, the method includes:

[0103] Get resource-occupying tasks, and then store the tasks in the bidding instance task queue and the regular task queue according to the task type. Determine whether the regular task queue is empty. If the regular task queue is not empty, allocate resources according to the first scheduling strategy, and then determine whether the allocation cluster is found. If so, dequeue the tasks in the task queue, that is, dequeue the tasks in the regular task queue, and then update the task record table. If the allocation cluster is not found, allocate resources according to the third scheduling strategy, and further determine whether the allocation can be met by stopping the bidding instance tasks. If the allocation can be met by stopping the bidding instance tasks, dequeue the tasks in the task queue, that is, dequeue the tasks in the bidding instance task queue, and then update the task record table and the cluster resource allocation ratio table. If the allocation cannot be met by stopping the bidding instance tasks, determine whether the regular task queue is empty again, that is, wait for the next cycle.

[0104] However, when the regular task queue is empty, determine whether the spot instance task queue is empty. If the spot instance task queue is not empty, allocate resources according to the second scheduling strategy, and then determine whether the allocation cluster is found. If so, dequeue the tasks in the task queue, that is, dequeue the tasks in the spot instance task queue, and then update the task record table. In this way, the regular instance tasks can be executed first. When the regular instance queue is empty, the spot instance queue tasks are executed.

[0105] Figure 4 is a schematic diagram of an optional resource allocation method for a newly added cluster according to an embodiment of the present invention, such as Figure 4 As shown, the method includes:

[0106] A new cluster is detected and the newly added cluster is obtained. Then, the cluster in the cluster list is updated.

[0107] Calculate the variance of the current comprehensive allocation rate of the cluster. Determine whether it is the last spot instance task in the task list. If it is not the last spot instance task in the task list, migrate the spot instance task to the newly added cluster and calculate the variance of the cluster comprehensive allocation rate. Then, determine whether the current comprehensive allocation rate variance is greater than the cluster comprehensive allocation rate variance. If the current comprehensive allocation rate variance is greater than the cluster comprehensive allocation rate variance, migrate the spot instance task to the newly added cluster to ensure that the current comprehensive allocation rate variance is equal to the cluster comprehensive allocation rate variance. Determine the next spot instance task in the task list, continue to determine whether it is the last spot instance task in the task list, and repeat until all the spot instance tasks in the task list are traversed.

[0108] According to an embodiment of the present invention, an embodiment of a resource allocation device is provided. It should be noted that the device can be used to execute the above-mentioned resource allocation method. The specific implementation scheme and application scenario of this embodiment are the same as those of the above-mentioned embodiment and will not be repeated here.

[0109] Figure 5 is a schematic diagram of a resource allocation device according to an embodiment of the present application, such as Figure 5 As shown, the device includes the following:

[0110] An acquisition module 50 is used to acquire a target resource occupation task, wherein the target resource occupation task is used to request occupation of resources in multiple clusters;

[0111] A first allocation module 52 is used to determine a first cluster that successfully matches the target resource occupying task from multiple clusters when the task type of the target resource occupying task is a first type, and allocate resources of the first cluster to the target resource occupying task, wherein the first type is used to indicate that the resource occupation time of the target resource occupying task is preset;

[0112] The second allocation module 54 is used to store the target resource occupying task in a task queue corresponding to the second type when the task type of the target resource occupying task is the second type, and to determine a second cluster that successfully matches the target resource occupying task from multiple clusters when a preset condition is met, and to allocate resources of the second cluster to the target resource occupying task.

[0113] Optionally, determining a first cluster that successfully matches the target resource occupying task from multiple clusters includes: determining a first candidate cluster that matches the target resource occupying task from multiple clusters; when the number of first candidate clusters is one, determining the first candidate cluster as the first cluster; when the number of first candidate clusters is multiple, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters, wherein the cluster evaluation indicators include at least one of the following: processor allocation ratio, memory allocation ratio, central processing unit allocation ratio and comprehensive allocation ratio, and the comprehensive allocation ratio is obtained by summarizing the processor allocation ratio, memory allocation ratio and central processing unit allocation ratio.

[0114] Optionally, determining the first cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on cluster evaluation indicators of multiple first candidate clusters; when the number of second candidate clusters is one, determining the second candidate cluster as the first cluster; when the number of second candidate clusters is multiple, determining the first cluster from multiple second candidate clusters based on a balanced allocation strategy.

[0115] Optionally, when there is no first cluster among multiple clusters that successfully matches the target resource-occupying task, the above method also includes: determining a third cluster and a preset resource-occupying task from multiple clusters, wherein the resources of the third cluster have been allocated to the second type of resource-occupying tasks, and the task type of the preset resource-occupying task is the second type; releasing the resources in the third cluster allocated to the preset resource-occupying task; and allocating the resources of the third cluster to the target resource-occupying task.

[0116] Optionally, determining a third cluster and a preset resource-occupying task from multiple clusters includes: determining a third candidate cluster from multiple clusters, resources of the third candidate cluster have been allocated to the second type of resource-occupying tasks; determining a resource evaluation indicator of the allocated resources of the third candidate cluster, wherein the allocated resources are used to characterize the resources allocated to the second type of resource-occupying tasks; and determining the third cluster and the preset resource-occupying task based on the resource evaluation indicator of the allocated resources.

[0117] Optionally, based on the resource evaluation indicators of the allocated resources, a third cluster and a preset resource occupation task are determined, including: when the resource evaluation indicators of the allocated resources are different, determining the third candidate cluster where the allocated resources corresponding to the minimum resource evaluation indicator are located as the third cluster, and determining the allocated resources corresponding to the minimum resource evaluation indicator as the preset resource occupation task; when the resource evaluation indicators of the allocated resources are the same, determining the third cluster from multiple third candidate clusters based on a balanced allocation strategy.

[0118] Optionally, when the task type of the target resource-occupying task is the first type, the above method also includes: storing the target resource-occupying task in a task queue corresponding to the first type; reading the current resource-occupying task from the task queue corresponding to the first type; determining the current cluster that successfully matches the current resource-occupying task from multiple clusters, and allocating resources of the current cluster to the current resource-occupying task.

[0119] Optionally, the above method also includes: when detecting that a new cluster has joined multiple clusters, determining the balance variance of the updated multiple clusters, wherein the updated multiple clusters include multiple clusters and the new cluster; based on the balance variance, determining the resource occupying tasks to be migrated from the multiple clusters, wherein the new balance variance obtained after the resource occupying tasks to be migrated are migrated to the new cluster is less than the balance variance; and migrating the resource occupying tasks to be migrated to the new cluster.

[0120] An embodiment of the present application further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of the present invention when running.

[0121] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.

[0122] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in various embodiments of the present invention when executed by a processor.

[0123] An embodiment of the present application further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.

[0124] The embodiments of the present application further provide a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.

[0125] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0126] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, 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 units or modules, which can be electrical or other forms.

[0127] The units described 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 units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0128] In addition, each functional unit in each embodiment of the present invention 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.

[0129] 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 invention, in essence, 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 a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0130] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A resource allocation method, characterized in that: include: Obtaining a target resource occupation task, wherein the target resource occupation task is used to request occupation of resources in multiple clusters; In the case where the task type of the target resource occupying task is a first type, determining a first cluster that successfully matches the target resource occupying task from the multiple clusters, and allocating resources of the first cluster to the target resource occupying task, wherein the first type is used to characterize that the resource occupation time of the target resource occupying task is preset; When the task type of the target resource occupying task is the second type, the target resource occupying task is stored in a task queue corresponding to the second type, and when a preset condition is met, a second cluster that successfully matches the target resource occupying task is determined from the multiple clusters, and resources of the second cluster are allocated to the target resource occupying task.

2. The method according to claim 1, characterized in that The determining, from the multiple clusters, a first cluster that successfully matches the target resource occupying task comprises: Determine a first candidate cluster matching the target resource occupying task from the multiple clusters; When the number of the first candidate clusters is one, determining the first candidate cluster to be the first cluster; In the case that there are multiple first candidate clusters, the first cluster is determined from the multiple first candidate clusters based on cluster evaluation indicators of the multiple first candidate clusters, wherein the cluster evaluation indicators include at least one of the following: processor allocation ratio, memory allocation ratio, central processing unit allocation ratio and comprehensive allocation ratio, and the comprehensive allocation ratio is obtained by summarizing the processor allocation ratio, the memory allocation ratio and the central processing unit allocation ratio.

3. The method according to claim 2, characterized in that The step of determining the first cluster from the plurality of first candidate clusters based on the cluster evaluation indicators of the plurality of first candidate clusters includes: determining a second candidate cluster from the plurality of first candidate clusters based on cluster evaluation indicators of the plurality of first candidate clusters; When the number of the second candidate clusters is one, determining the second candidate cluster to be the first cluster; In the case that there are multiple second candidate clusters, the first cluster is determined from the multiple second candidate clusters based on a balanced allocation strategy.

4. The method according to any one of claims 1 to 3, characterized in that In the case that there is no first cluster among the multiple clusters that successfully matches the target resource occupying task, the method further includes: Determine a third cluster and a preset resource occupying task from the multiple clusters, wherein resources of the third cluster have been allocated to the resource occupying task of the second type, and the task type of the preset resource occupying task is the second type; Releasing the resources allocated to the preset resource occupying task in the third cluster; Allocate resources of the third cluster to the target resource-occupying task.

5. The method according to claim 4, characterized in that The determining a third cluster and a preset resource occupying task from the multiple clusters includes: determining a third candidate cluster from the multiple clusters, wherein resources of the third candidate cluster have been allocated to the resource-occupying tasks of the second type; Determining a resource evaluation indicator of the allocated resources of the third candidate cluster, wherein the allocated resources are used to characterize the resources allocated to the resource-occupying tasks of the second type; The third cluster and the preset resource occupying task are determined based on the resource evaluation index of the allocated resources.

6. The method according to claim 5, characterized in that The determining the third cluster and the preset resource occupying task based on the resource evaluation indicator of the allocated resources includes: In the case where the resource evaluation indicators of the allocated resources are different, determining that the third candidate cluster where the allocated resources corresponding to the minimum resource evaluation indicator are located is the third cluster, and determining that the allocated resources corresponding to the minimum resource evaluation indicator are the preset resource occupying tasks; In a case where the resource evaluation indicators of the allocated resources are all the same, the third cluster is determined from a plurality of third candidate clusters based on a balanced allocation strategy.

7. The method according to any one of claims 1 to 3, characterized in that In a case where the task type of the target resource occupying task is the first type, the method further includes: Storing the target resource occupying task in a task queue corresponding to the first type; Read the current resource-occupying task from the task queue corresponding to the first type; A current cluster that successfully matches the current resource occupying task is determined from the multiple clusters, and resources of the current cluster are allocated to the current resource occupying task.

8. The method according to claim 1, characterized in that The method further comprises: In the case of detecting that a new cluster joins the plurality of clusters, determining a balance variance of the updated plurality of clusters, wherein the updated plurality of clusters include the plurality of clusters and the new cluster; Based on the balance variance, determining the resource occupying tasks to be migrated from the multiple clusters, wherein a new balance variance obtained after the resource occupying tasks to be migrated are migrated to the new cluster is smaller than the balance variance; Migrate the resource-occupying tasks to be migrated to the new cluster.

9. A resource allocation device, characterized in that: include: An acquisition module, used for acquiring a target resource occupation task, wherein the target resource occupation task is used for requesting to occupy resources in multiple clusters; A first allocation module is used to determine, from the multiple clusters, a first cluster that successfully matches the target resource occupying task when the task type of the target resource occupying task is a first type, and allocate resources of the first cluster to the target resource occupying task, wherein the first type is used to indicate that the resource occupation time of the target resource occupying task is preset; A second allocation module is used to store the target resource occupying task in a task queue corresponding to the second type when the task type of the target resource occupying task is the second type, and to determine a second cluster that successfully matches the target resource occupying task from the multiple clusters when a preset condition is met, and to allocate resources of the second cluster to the target resource occupying task.

10. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the device where the non-volatile storage medium is located executes the resource allocation method according to any one of claims 1 to 8 by running the computer program.

Citation Information

Patent Citations

  • Resource allocation method and device, resource manager and storage medium

    CN110134521A

  • Resource scheduling method and device, electronic equipment and storage medium

    CN112148468A

  • Task scheduling method, device and system

    CN116610422A

  • Multitask scheduling method and device based on heterogeneous distributed cluster

    CN118227291A

  • Resource cluster supply method, apparatus and device, and readable medium

    CN118885292A

Cited By

  • Resource allocation control method and device for parallel tasks, computer equipment and medium

    CN121785807A