Resource allocation method and apparatus, electronic device, and storage medium

By distinguishing task types and adopting a dynamic resource allocation strategy, the problem of unbalanced resource allocation in multi-cluster management is solved and resource utilization is improved.

CN119883631BActive Publication Date: 2025-10-21CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In multi-cluster management scenarios, unbalanced resource allocation leads to low resource utilization.

Method used

By distinguishing target resource-occupying tasks of different task types, cluster resources can be quickly located and allocated for tasks occupying preset time periods. Tasks that need to wait for resources are gradually allocated through the task queue to avoid excessive resource occupation and achieve dynamic resource allocation.

Benefits of technology

It achieves balanced resource allocation, improves resource utilization, and solves the problem of low resource utilization caused by unbalanced cluster resource allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883631B_ABST
    Figure CN119883631B_ABST
Patent Text Reader

Abstract

A resource allocation method and device, electronic equipment and storage medium are disclosed. The method comprises: obtaining a target resource occupation task, wherein the target resource occupation task is used to request occupation of resources in multiple clusters; in a case where a task type of the target resource occupation task is a first type, determining a first cluster that matches the target resource occupation task successfully from the multiple clusters, and allocating resources of the first cluster to the target resource occupation task; in a case where 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 in a case where a preset condition is met, determining a second cluster that matches the target resource occupation task successfully from the multiple clusters, and allocating resources of the second cluster to the target resource occupation task. The present application solves the technical problem of low resource utilization caused by uneven allocation of cluster resources in the related art.
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, communications services are often deployed in cloud environments to achieve more efficient and flexible computing resource management and utilization. In this context, cloud-based deployment of communications services has become a trend, not only improving operational efficiency but also enhancing service elasticity and scalability through resource sharing. However, resource allocation issues in cloud environments have also become prominent, especially in multi-cluster management scenarios, where the necessity and challenges of resource allocation become even more pronounced.

[0003] In related technologies, resources can be allocated through bidding instances. However, since bidding instances are usually concentrated in one cluster, it is difficult to allocate resources to different clusters. This may cause some tasks to occupy too many resources and uneven resource allocation, thereby reducing resource utilization.

[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0005] 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 related technologies.

[0006] According to one aspect of an embodiment of the present invention, a resource allocation method is provided, including: 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 the 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, based on the cluster evaluation indicators of multiple first candidate clusters, determining the first cluster from multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on the 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 task, 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; 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, wherein resources of the third candidate cluster have been allocated to the second type of resource-occupying task; 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 task; 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, the third cluster and the 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 the 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 the resources of the current cluster to the current resource-occupying task.

[0013] Optionally, the above method also includes: when detecting that a new cluster joins 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 for acquiring 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 for, 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; a second allocation module for, 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 determining a second cluster that successfully matches the target resource-occupying task from multiple clusters when a preset condition is met, and allocating resources of the second cluster to the target resource-occupying task.

[0015] According to another aspect of an embodiment of the present invention, an electronic device is provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods of various embodiments of the present invention when 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 provided. When the computer program is executed by a processor, the methods in various 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 of 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 of 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 resources to multiple clusters, 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 solutions of the present invention, the technical solutions 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 embodiments described 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 making creative efforts should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the description 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 numbers 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 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 embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG1 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 (illustrated as 102a, 102b, ..., 102n in the figure) processors (the processor may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices), 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 will 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 than shown, or with Figure 1 Different configurations 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 circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10. As described in the embodiments of the present application, the data processing circuitry serves 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 the software programs and modules stored in the memory 104 to perform various functional applications and data processing, that is, to implement the above-mentioned IP address allocation method for the application. 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 located 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 combinations 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 includes the following steps:

[0035] Step S202: Obtain target resource occupying tasks.

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

[0037] The target resource occupation task described above can be used to request resource occupation across multiple clusters. This helps address cross-cluster resource allocation and optimizes resource utilization efficiency. The target resource occupation task can be a data processing task, backup task, or distributed computing task. The content of the target resource occupation task is not limited and can be determined as needed.

[0038] Target resource-consuming tasks can be applications or workloads that need to be executed in a computing environment. These tasks consume computing resources, such as memory and accelerator resources. In cloud computing or container orchestration scenarios, target resource-consuming tasks can be user-submitted applications, services, or data processing tasks. Effective scheduling of target resource-consuming tasks is crucial for optimizing resource utilization and improving system performance.

[0039] Allocating target resource-consuming tasks is crucial in cloud computing and cluster management scenarios. By properly allocating these tasks, resources can be effectively utilized, avoiding waste or overallocation. Intelligent resource allocation enables efficient resource utilization and improves overall system performance. In a multi-cluster or multi-node environment, balanced task distribution prevents overloading of certain clusters or nodes while leaving others idle. Load balancing helps maintain system stability and responsiveness, ensuring that all clusters or nodes are effectively utilized. In cloud environments, resource utilization is often directly correlated with cost. Strategically allocating target resource-consuming tasks, such as prioritizing lower-cost spot instances, can effectively control operating costs while ensuring service quality and response time. It also ensures that critical or high-priority target resource-consuming tasks receive sufficient resources, maintaining high service levels. This not only impacts task completion speed but also the end-user experience. Automatically adjusting resource allocation as the workload of target resource-consuming tasks changes, for example by increasing resources during peak demand periods and reducing them during low demand periods, allows for elastic system scalability. Furthermore, cross-cluster task allocation allows tasks to be quickly switched to healthy clusters or nodes when a cluster or node fails, improving the system's fault tolerance and disaster recovery speed. Furthermore, based on different business policies, such as priority and performance requirements, target resource-intensive tasks are assigned to matching clusters or nodes to improve computing efficiency.

[0040] In an optional embodiment, tasks to be processed are 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 be obtained through a scheduler. Alternatively, a task request submitted by a user or the system can be received, and the 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, 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.

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

[0043] Target resource-consuming tasks can be categorized into different task types based on resource requirements and operational needs. For example, in container orchestration systems like Kubernetes, target resource-consuming tasks can be categorized into regular instance tasks, spot instance tasks, batch tasks, fixed-time tasks, and elastic scaling tasks. There are no restrictions on the task types for target resource-consuming tasks and these can be determined as needed. Different allocation strategies can be employed depending on the task type. For example, for regular instance tasks, a stable supply of resources must be ensured to avoid service interruptions. For batch and fixed-time tasks, resources can be utilized during off-peak hours to avoid idle resources and improve overall resource utilization efficiency. Elastic scaling tasks automatically adjust resources based on real-time load, ensuring stable service even under large load fluctuations. By differentiating task types, the risk tolerance of different tasks can also be considered. For example, critical tasks can be provided with more stable resources while non-critical tasks can be interrupted when resources are limited.

[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, and 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 aforementioned cluster can be a collection of multiple nodes connected via a network, working together to complete a target resource occupation task or provide a service. Leveraging the computing power and storage resources of the cluster's multiple nodes, services with higher performance, higher availability, greater storage capacity, and improved scalability are provided. Clusters can be high-performance computing clusters, distributed clusters, load balancing clusters, high-availability clusters, container clusters, and more. The clusters are not limited here and can be determined as needed. The first cluster among the multiple clusters that successfully matches the target resource occupation task can be used 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 a target resource occupation task of the first type is received, the resource utilization of the clusters is compared based on the task's requirements. The cluster with a current resource utilization below a preset threshold is selected as the first cluster. This effectively avoids excessive resource concentration and improves overall resource utilization. The target resource occupation task is then started on this first cluster.

[0048] In another optional embodiment, a quality of service (QoS) priority strategy can be used to select a first cluster from multiple clusters. The specific requirements of the task and the QoS can be considered. Among multiple clusters, the network latency, storage speed, hardware configuration, and historical performance data of the clusters 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 high network latency requirements, the cluster with the lowest network latency will be prioritized. This approach ensures that the response time and performance of critical tasks are guaranteed. The target resource occupation task is then launched on the first cluster.

[0049] In another optional embodiment, a cluster list can be maintained, which records the clusters to which new tasks are assigned. The cluster list can 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 the task queue corresponding to the second type, and when the preset conditions are 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 second type of target resource occupation tasks mentioned above 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 may be determined as needed. Among them, the spot instance tasks may be tasks that run on spot instance resources. Spot instances are resources provided by a cloud service provider. The price of spot instance resources is low, but the stability and availability of resources are low. They are suitable for batch processing tasks or background jobs that can tolerate interruptions or resource instability. 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 level, appropriate cluster resources can be allocated to the target resource occupying task of the second type. 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, or it can be determined artificially, or it can be set according to a preset storage rule. Thus, the tasks can be queued out in sequence according to the order of the tasks in the queue.

[0053] Furthermore, the task queue status and the cluster's resource status and cost can be checked to allocate appropriate cluster resources to the second type of target resource-consuming tasks. Optionally, for the second type of target resource-consuming tasks in the task queue, the system evaluates whether the cluster's resources meet the task's requirements and compares their costs. The cluster with the lowest cost and sufficient resources is selected as the second cluster. After the second cluster is determined, the task is removed from the task queue and launched on the second cluster, allocating the required resources.

[0054] Alternatively, a second cluster that successfully matches the target resource-occupying task can be identified from multiple clusters based on preset matching rules, and the target resource-occupying task can then be started on this 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 the prediction results, and the task is started on the second cluster, allocating 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 of 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 of 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 resources to multiple clusters, 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 the 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 that matches the target resource-occupying task can be determined from multiple clusters based on 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. Therefore, when the number of first candidate clusters is one, the first candidate cluster can be determined as 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 based on the weighted score of each cluster in the first candidate cluster. Alternatively, the first cluster can be predicted from the multiple first candidate clusters based on 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 the first type of target resource occupation task to meet the resource requirements of the target resource occupation task.

[0059] 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. The cluster evaluation indicators are 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 represent 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] Where 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 leads to resource waste and uneven system load. It is particularly suitable for processing resource-intensive tasks such as deep learning model training and large-scale data processing.

[0073] Optionally, based on the cluster evaluation indicators of multiple first candidate clusters, determining the first cluster from multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on the 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 of the multiple first candidate clusters based on a cluster evaluation metric. Clusters within the first candidate clusters whose weighted scores are greater than a preset score are then determined to be second candidate clusters. Alternatively, the first cluster can be predicted from the multiple first candidate clusters based on a second matching model. The second matching model predicts the second candidate cluster by learning the relationship between the cluster evaluation metric and historical second candidate clusters. The second matching model can be a decision tree, random forest, cluster analysis model, etc. The second matching model is not limited here and can be determined as needed.

[0075] If there is only one second candidate cluster, the second candidate cluster is determined as the first cluster. If there are multiple second candidate clusters, a balanced allocation strategy can be used to determine the first cluster from the multiple second candidate clusters. This balanced allocation strategy can be determined based on methods such as minimum difference selection, weighted random selection, and resource utilization ratio. The minimum difference selection method compares the differences between the clusters in the second candidate cluster and the cluster resource allocation target or average resource utilization and selects the cluster with the smallest difference as the first cluster. The weighted random selection method assigns a weight to each cluster in the second candidate cluster. The weight can be determined based on indicators such as the cluster's current resource utilization, resource price, or historical performance. A cluster is then selected as the first cluster using a weighted random algorithm. This method helps maintain balance while taking into account cost-effectiveness and cluster performance. The resource utilization ratio method calculates the resource utilization ratio of each cluster in the second candidate cluster and selects the cluster with the ratio closest to the preset balanced ratio as the first cluster.

[0076] This approach further refines the resource allocation process and ensures balanced resource distribution. 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 task, 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; and allocating the resources of the third cluster to the target resource-occupying task.

[0078] In multiple clusters, there are tasks waiting to be assigned in the regular instance task queue, but no cluster has resources that can directly meet their needs. At the same time, there are some clusters whose resources are largely occupied by the spot instance tasks, resulting in high resource utilization. Therefore, the first type of target resource occupation task can be executed with the help of the cluster used to implement the second type of target resource occupation task. For example, for a regular instance task, if there is no cluster that meets the resource requirement conditions, the calculation can shut down the cluster of the spot instance task to use the cluster for the regular instance task. The spot 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 shutdown, the cluster is allocated 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 based on a preset cluster allocation table. Alternatively, the third cluster and the preset resource-occupying task may be determined from multiple clusters based on task type, cluster evaluation indicators, and the like. The resources of the third cluster have been allocated to the second type of resource-occupying task, and the preset resource-occupying task is of the second type.

[0080] Furthermore, 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 newly 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 and emergency rescue command.

[0082] Optionally, determining a third cluster and a preset resource-occupying task from multiple clusters includes: determining a third candidate cluster from multiple clusters, wherein resources of the third candidate cluster have been allocated to the second type of resource-occupying task; 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 task; 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, cluster evaluation indicators, or type identifiers, and resources of the third candidate cluster are allocated to the second type of resource-occupying tasks.

[0084] Furthermore, resource evaluation indicators for the allocated resources of the third candidate cluster can be determined using server usage data, memory usage data, or central server usage data. The allocated resources can be used to represent the resources allocated to the second type of resource-consuming tasks. The third cluster and the pre-set resource-consuming tasks can then 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. 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, the third cluster and the 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 the 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 occupancy task.

[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, a 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 average resource utilization, and selects the cluster with the smallest difference as the third cluster. The weighted random selection assigns a weight to each cluster in the third candidate cluster. The weight can be determined based on indicators such as the cluster's current resource utilization, resource price, or historical performance. Then, a cluster is selected as the third cluster using 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 with the ratio 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 vary 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 the 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 according to 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 set according to a preset storage rule. Thus, the tasks can be dequeued in sequence according to the order in which they are 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. Furthermore, the current cluster that successfully matches the current resource-occupying task can be determined from multiple clusters based on a preset cluster allocation list or cluster evaluation indicators, 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 joins 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 a new cluster is detected to have joined multiple clusters, the updated balance variances of the multiple clusters can be determined based on the cluster evaluation metric. The updated multiple clusters include the multiple clusters and the new cluster. Then, for tasks that can be migrated, the new balance variances after migration are calculated, and their impact on the updated multiple clusters after migration to the new cluster is calculated. Migration tasks whose new balance variances are smaller than the corresponding balance variances are selected and determined as resource-occupying tasks to be migrated. Consequently, the resource-occupying tasks to be migrated are deactivated 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 i-th 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, a machine learning model can be used to determine the balance variance of multiple clusters after the update. The machine learning model can be trained using 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. The task with the smallest predicted value is selected as the resource-consuming task to be migrated. Then, the task migration is executed, and the machine learning model is updated based on 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] Obtain resource-occupying tasks, and then store the tasks in the bid instance task queue and the regular task queue respectively 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 policy, 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 policy, and further determine whether the allocation can be met by stopping the bid instance tasks. If the allocation can be met by stopping the bid instance tasks, dequeue the tasks in the task queue, that is, dequeue the tasks in the bid 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 bid instance tasks, determine again whether the regular task queue is empty, that is, wait for the next cycle.

[0104] However, if the regular task queue is empty, the system checks whether the spot instance task queue is empty. If the spot instance task queue is not empty, it allocates resources according to the second scheduling policy. It then determines whether an allocation cluster has been found. If so, it dequeues the task in the task queue, specifically the spot instance task queue, and then updates the task record table. This prioritizes regular instance tasks. If 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. 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 cluster's current comprehensive allocation rate. Determine whether this is the last spot instance task in the task list. If not, migrate the spot instance task to the newly added cluster and calculate the variance of the cluster's comprehensive allocation rate. Then, determine whether the current comprehensive allocation rate variance is greater than the cluster's comprehensive allocation rate variance. If so, migrate the spot instance task to the newly added cluster to ensure that the current comprehensive allocation rate variance is equal to the cluster's comprehensive allocation rate variance. Determine the next spot instance task in the task list and continue to determine whether this is the last spot instance task in the task list. Repeat this process until all spot instance tasks in the task list have been 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 configured 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 configured to, when the task type of the target resource-occupying task is a first type, determine a first cluster that successfully matches the target resource-occupying task from the multiple clusters, and allocate resources of the first cluster to the target resource-occupying task, wherein the first type is used to indicate that the target resource-occupying task has a preset resource occupation time;

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

[0113] Optionally, determining the 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, based on the cluster evaluation indicators of multiple first candidate clusters, determining the first cluster from multiple first candidate clusters includes: determining the second candidate cluster from multiple first candidate clusters based on the 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 task, 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; 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, wherein resources of the third candidate cluster have been allocated to the second type of resource-occupying task; 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 task; 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, the third cluster and the 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 the 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 the resources of the current cluster to the current resource-occupying task.

[0119] Optionally, the above method also includes: when detecting that a new cluster joins 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 of 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 focus. 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 exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0127] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across 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, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or 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, 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or 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, etc. Various 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 principles of the present invention. These improvements and modifications should also be regarded as within 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; 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 the multiple clusters, and allocating resources of the first cluster to the target resource-occupying task, wherein the first type is used to indicate that the target resource-occupying task has a preset resource occupation time; 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 includes: 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 as 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 determining the first cluster from the plurality of first candidate clusters based on 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 cluster is one, determining the second candidate cluster as 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 a case where the first cluster that successfully matches the target resource occupying task does not exist in the multiple clusters, the method further includes: Determining 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 of a third cluster and a preset resource occupying task from the multiple clusters includes: determining a third candidate cluster from the plurality of 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 allocated resources of the third candidate cluster, wherein the allocated resources are used to represent 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 indicator 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 a case where a new cluster is detected to join the plurality of clusters, determining a balance variance of the updated plurality of clusters, wherein the updated plurality of clusters includes the plurality of clusters and the new cluster; Determining resource-occupying tasks to be migrated from the multiple clusters based on the balance variance, 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, configured to acquire a target resource occupation task, wherein the target resource occupation task is used to request occupation of resources in multiple clusters; a first allocation module, configured to, when the task type of the target resource-occupying task is a first type, determine, from the multiple clusters, a first cluster that successfully matches the target resource-occupying task, 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

  • Task scheduling method, device and system

    CN116610422A

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

    CN118885292A