CN114327897A - Resource allocation method and device and electronic equipment - Google Patents

Resource allocation method and device and electronic equipment Download PDF

Info

Publication number
CN114327897A
CN114327897A CN202111643857.1A CN202111643857A CN114327897A CN 114327897 A CN114327897 A CN 114327897A CN 202111643857 A CN202111643857 A CN 202111643857A CN 114327897 A CN114327897 A CN 114327897A
Authority
CN
China
Prior art keywords
candidate
job
score
jobs
pod
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111643857.1A
Other languages
Chinese (zh)
Inventor
李盼盼
张恒华
胡在斌
骆宝童
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202111643857.1A priority Critical patent/CN114327897A/en
Publication of CN114327897A publication Critical patent/CN114327897A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present disclosure provides a resource allocation method and an electronic device, and belongs to the technical field of big data and resource allocation, the specific scheme is as follows: acquiring a first candidate job list based on the priority of the target job, wherein the priority of the candidate job in the first candidate job list is lower than that of the target job; calculating the scores of at least part of candidate jobs in the first candidate job list, wherein at least part of candidate jobs comprise at least one candidate job group, and the priorities of jobs in the same candidate job group are the same; determining a first job from the first candidate job list according to the score of at least part of the candidate jobs and the priority of the first candidate job list; resources of the first job are allocated to the target job. And combining the scores of at least part of the candidate jobs and the priority of the first candidate job list, selecting the first job from the first candidate job list, and allocating the resources of the first job with the priority lower than that of the target job to the target job, thereby improving the reasonability of resource allocation.

Description

Resource allocation method and device and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to the field of big data and resource allocation technologies, and more particularly, to a resource allocation method and apparatus, and an electronic device.
Background
In kubernets (a system for running and collaboratively containerizing applications on a group of nodes), a server cluster is deployed, each server may be called a node, and for a certain job (job), a plurality of tasks (tasks) may be included, a pod (which is a minimum management unit in the kubernets and may also be understood as a minimum deployable computing unit that can be created and managed in the kubernets) needs to be deployed in a node of the kubernets, and one pod is successfully deployed to the node to run, which indicates that the pod is successfully scheduled and occupies resources of the node, and then the pod may be a Task that can run the job in the node, and one pod may include one or more containers, and one Task corresponds to one pod, that is, one pod may run one Task.
Under the condition that a job needs to be run, in the resource scheduling process, there may be a condition that the resource quota is insufficient, so that the job cannot apply for the resource and cannot run normally, and thus the resource needs to be preempted from the job that has occupied the resource to ensure the normal running of the job, that is, the occupied resource is reallocated to the job.
At present, in the process of preempting resources, a commonly adopted method is to preempt resources occupied by jobs meeting the demands of the preempting person on the job resources.
Disclosure of Invention
The disclosure provides a resource allocation method and device and electronic equipment.
In a first aspect, an embodiment of the present disclosure provides a resource allocation method, where the method includes:
acquiring a first candidate job list based on the priority of a target job, wherein the priority of a candidate job in the first candidate job list is lower than that of the target job;
calculating the scores of at least part of candidate jobs in the first candidate job list, wherein the at least part of candidate jobs comprise at least one candidate job group, and the priorities of jobs in the same candidate job group are the same;
determining a first job from the first candidate job list according to the score of the at least part of candidate jobs and the priority of the first candidate job list;
allocating resources of the first job to the target job.
In the embodiment of the disclosure, the job selection is performed first, and then the selected resource of the first job is allocated to the target job, so that the target job preempts the resource of the first job. In the process of selecting the job, the job is selected from a first candidate job list with the priority lower than that of the target job, the resource of the selected first job is allocated to the target job, so that the resource of the first job with the priority lower than that of the target job can be ensured to be preempted, namely the resource of the low-priority job, the rationality of resource allocation can be improved, and as the jobs with the same priority possibly exist in the list, the scores of at least part of candidate jobs in the first candidate job list can be calculated, and the first job is selected from the first candidate job list by combining the scores of at least part of candidate jobs and the priority of the first candidate job list, so that the rationality of the selected first job is improved, and the resource of the selected first job is allocated to the target job, thereby improving the rationality of resource allocation.
In a second aspect, an embodiment of the present disclosure provides a resource allocation apparatus, including:
the system comprises a list acquisition module, a list acquisition module and a display module, wherein the list acquisition module is used for acquiring a first candidate job list based on the priority of a target job, and the priority of a candidate job in the first candidate job list is lower than that of the target job;
the calculation module is used for calculating the scores of at least part of candidate jobs in the first candidate job list, wherein the at least part of candidate jobs comprise at least one candidate job group, and the priorities of jobs in the same candidate job group are the same;
a determining module, configured to determine a first job from the first candidate job list according to the score of the at least part of candidate jobs and the priority of the first candidate job list;
an allocation module to allocate resources of the first job to the target job.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the resource allocation method of the present disclosure as provided in the first aspect.
In a fourth aspect, an embodiment of the present disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the resource allocation method provided by the first aspect of the present disclosure.
In a fifth aspect, an embodiment of the present disclosure provides a computer program product comprising a computer program, which when executed by a processor, implements the resource allocation method of the present disclosure as provided in the first aspect.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is one of the flow diagrams of a resource allocation method according to an embodiment provided in the present disclosure;
fig. 2 is a second schematic flowchart of a resource allocation method according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a resource allocation method according to one embodiment provided by the present disclosure;
FIG. 4 is one of the scoring graphs of one embodiment provided by the present disclosure;
FIG. 5 is a second graph of scores for one embodiment provided by the present disclosure;
FIG. 6 is a block diagram of a resource allocation apparatus according to an embodiment provided by the present disclosure;
fig. 7 is a block diagram of an electronic device for implementing a resource allocation method of an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, according to an embodiment of the present disclosure, the present disclosure provides a resource allocation method, which is applicable to a Platform as a Service (PaaS), an Infrastructure as a Service (IaaS), or the like, the method including:
step S101: based on the priority of the target job, a first candidate job list is obtained, and the priority of the candidate job in the first candidate job list is lower than that of the target job.
The target job may be understood as a job requiring resource preemption, that is, a preemptive job, and the candidate job may be understood as a job for which a resource is available for preemption, that is, a preemptive job. For example, an artificial intelligence model training job needs to run, but resources provided by the system at present cannot meet the requirement of normal running of the job, so that resources need to be preempted, each job has a corresponding priority, in order to avoid random preemption of the resources from affecting normal running of the job with a higher priority, the target job can preempt resources of the job with a priority lower than that of the target job, that is, the priority of any candidate job in the acquired first candidate job list needs to be lower than that of the target job, and then resources occupied by jobs in the first candidate job list are preempted, so that the resources of the job with a priority lower than that of the target job are preempted by the target job.
Step S102: and calculating the scores of at least part of the candidate jobs in the first candidate job list, wherein at least part of the candidate jobs comprise at least one candidate job group, and the priority of the jobs in the same candidate job group is the same.
However, in the first candidate job list, there may be jobs with the same priority, and for jobs with the same priority, their corresponding scores may be calculated first. At least one group of candidate job groups with the same priority may exist in the first candidate job list, and the priorities of the jobs in the same candidate job group are the same.
Step S103: a first job is determined from the first candidate job list based on at least a portion of the candidate job scores and a priority of the first candidate job list.
In the resource preemption process, the scores of the candidate jobs with the same priority can be considered, the scores of at least part of the candidate jobs are involved in the job selection process, and the first job is determined from the first candidate job list according to the priority of the first candidate job list and the scores of at least part of the candidate jobs, so that the selection of the job is realized.
Step S104: resources of the first job are allocated to the target job.
After the first job is selected, the resources allocated to the first job can be reallocated to the target job, so that the target job can preempt the resources of the first job.
In the embodiment of the disclosure, the job selection is performed first, and then the selected resource of the first job is allocated to the target job, so that the target job preempts the resource of the first job. In the process of selecting the job, the job is selected from a first candidate job list with the priority lower than that of the target job, the resource of the selected first job is allocated to the target job, so that the resource of the first job with the priority lower than that of the target job can be ensured to be preempted, namely the resource of the low-priority job can be preempted, the rationality of resource allocation can be improved, and because the jobs with the same priority can exist in the list, the score of at least part of candidate jobs in the first candidate job list can be calculated, the first job is selected from the first candidate job list by combining the score of at least part of candidate jobs and the priority of the first candidate job list, the rationality of the selected first job is improved, the resource of the first job is allocated to the target job, and the rationality of resource allocation is improved.
As shown in fig. 2, in one embodiment, the step S103 of determining the first job from the first candidate job list according to the score of at least part of the candidate jobs and the priority of the first candidate job list includes:
step S1031: sorting the first candidate job list according to the priority of the candidate jobs in the first candidate job list to obtain a second candidate job list;
step S1032: using the scores of at least part of the candidate jobs to adjust the sequence of at least part of the candidate jobs in the second candidate job list to obtain a third candidate job list;
the third candidate job list is relative to the second candidate job list, the sequence of other candidate jobs is unchanged, and the other candidate jobs are jobs in the third candidate job list except for at least part of candidate jobs;
step S1033: determining a first job based on the order of the third candidate job list and the amount of resources required for the target job;
and the first operation is the last M operations in the third candidate operation list, the resource amount occupied by the last M operations is larger than or equal to the resource amount required by the target operation, and M is a positive integer.
It should be noted that, the sorting of the first candidate job list is to sort the first candidate job list from high priority to low priority, that is, the candidate jobs in the second candidate job list are sorted from high priority to low priority. In the process of adjusting the sequence of the second candidate job list, only at least part of the candidate jobs need to be adjusted, that is, only the sequence of the jobs with the same priority needs to be adjusted, and the sequence of the rest of the candidate jobs is unchanged.
After the sequence adjustment is completed to obtain the third candidate job list, the jobs are sequentially selected from the third candidate job list from back to front according to the sequence of the third candidate job list until the total resource amount occupied by the selected jobs is greater than or equal to the resource amount required by the target job, the selected job number is M, that is, the last M jobs are selected from the third candidate job list, and the resource amount occupied by the last M jobs is greater than or equal to the resource amount required by the target job. It is to be understood that the resource amount of the last M-1 jobs in the third candidate job list is smaller than the resource amount required for the target job, i.e., M may be the minimum job number satisfying the condition that the resource amount of the job is greater than or equal to the resource amount required for the target job.
In this embodiment, the first candidate job list is sorted according to the priority of the candidate jobs in the first candidate job list to obtain a second candidate job list, then the order of at least some of the candidate jobs in the second candidate job list is adjusted by using the scores of at least some of the candidate jobs to obtain a third candidate job list, and jobs are sequentially selected from the third candidate job list from back to front according to the order of the third candidate job list until the total resource amount occupied by the selected jobs is greater than or equal to the resource amount required by the target jobs, and the selected last M jobs are used as the first jobs.
As an example, in the process of using the scores of at least part of the candidate jobs to adjust the order of at least part of the candidate jobs in the second candidate job list to obtain the third candidate job list, the order of each candidate job group is adjusted separately, that is, the order adjustment of at least part of the candidate jobs is performed on the jobs in the candidate job group by taking the candidate job group as a unit. It is to be understood that, using the scores of at least some of the candidate jobs to adjust the order of at least some of the candidate jobs in the second candidate job list, a third candidate job list is obtained, including: using the score of the ith candidate job group to adjust the sequence of the candidate jobs in the ith candidate job group in the second candidate job list, wherein the initial value of i is 1, i is an integer, i is more than or equal to 1 and less than or equal to K, and K is the total number of the candidate job groups of at least part of the candidate jobs; adding one to the i to update the i; and then, under the condition that i is less than or equal to K, returning to use the score of the ith candidate job group to adjust the sequence of the candidate jobs in the ith candidate job group in the second candidate job list, and circulating until i is greater than K, meeting the condition of stopping adjustment, and stopping the sequence adjustment, namely under the condition that i is less than or equal to K, finishing the sequence adjustment of the second candidate job list to obtain a third candidate job list.
In one embodiment, the first candidate job list includes a plurality of entries, any entry includes information of a candidate job and a corresponding at least one management unit pod, any candidate job includes a plurality of tasks, and one pod is used for running one task;
wherein calculating the score of at least part of the candidate jobs in the first candidate job list comprises:
calculating the score of the target candidate job according to the first pod number, the running time length of the target candidate job and the second pod number, wherein the target candidate job is any job in at least part of candidate jobs;
the first pod number is the number of successfully scheduled pods in the pods of the target candidate job, and the second pod number is the number of non-scheduled pods in the pods of the target job.
It should be noted that, at least one pod corresponding to a candidate job in any entry refers to a pod of the candidate job that has been deployed or has been scheduled to a node in the cluster. The first candidate list may be understood to include two columns, one column is a key (key), the other column is a value (value), the key may be a name of the candidate job, the value may be information of at least one pod corresponding to the candidate job, that is, one row in the list is an entry, and information of at least one pod corresponding to one candidate job may be understood as an information array. As an example, information of a pod may include, but is not limited to, the name of the pod, the resource for which the pod applies, the time the pod operates, and the like. In the process of creating the first candidate list, each pod on each node in the potential nodes in the system is traversed, a candidate job corresponding to a pod with a lower priority than the target job is added into the list, and the priority of the pod is inherited from the job to which the pod belongs, namely, the priority of the pod is the same as that of the job to which the pod belongs. Corresponding to the target operation, in the process of traversing the Nodes, on one hand, the resources on the Nodes are not enough and are not scheduled successfully, on the other hand, some Nodes are not scheduled successfully due to hardware problems such as affinity, disk pressure and the like, for the former situation, the Nodes are classified as Potential Nodes (Potential Nodes), and the affinity means that the pod needs to run on a specific node, and the two Nodes have the same label.
In the embodiment, the score of the target candidate job is calculated according to the first pod number, the running time length of the target candidate job and the second pod number, and the target candidate job is any job in at least part of the candidate jobs.
In the embodiment, in the process of calculating the score, the number of the pod which is successfully scheduled in the pod of the target candidate job and the number of the pod which is not scheduled in the pod of the target job are considered, and the running time of the target candidate job is also considered, so that the accuracy of the calculated score of the target candidate job can be improved.
In one embodiment, calculating a score for the target candidate job based on the first pod number, the run length of the target candidate job, and the second pod number comprises:
under the condition that the first pod number is smaller than the second pod number, calculating a first score by using the first pod number and the second pod number, and calculating a second score by using the second pod number, the operation time length and the preset time length;
weighting and summing the first score and the second score by using the first preset weight and the second preset weight to obtain a score of the target candidate job;
the first score is positively correlated with the second pod number, is inversely correlated with the first pod number, and the second score is positively correlated with the operation duration and the second pod number, and is inversely correlated with the preset duration.
In the process of calculating the score, the first pod number is required to be compared with the second pod number, when the first pod number is smaller than the second pod number, the first score can be calculated by using the first pod number and the second pod number, the second score can be calculated by using the second pod number, the operation time length and the preset time length, and then the first score and the second score are weighted and summed by using the first preset weight and the second preset weight to obtain the score of the target candidate operation. In this way, in the process of calculating the score of the target candidate job, not only the first score and the second score are considered, but also the influence degree of the first score and the second score in the calculation process, namely the weight is considered, so that the accuracy of the obtained score can be improved. It should be noted that both the first preset weight and the second preset weight can be preset according to the actual situation.
As an example, in the case that the first pod number is smaller than the second pod number, the score P1 of the target candidate job may be calculated by using the following calculation formula:
P1=w1*(2N+1-p)+w2*max((2N+1)*t/T,t-T+(2N+1))。
wherein w1 is a first preset weight, w2 is a second preset weight, the first score is (2N +1-p), the second score is max ((2N +1) × T/T, T-T + (2N +1)), that is, the maximum values of (2N +1) × T/T and T-T + (2N +1), the first pod number is p, the second pod number is N, T is the running time of the target candidate job, T is a preset time, and x represents a multiplier. Specific values of w1, w2 and T are not limited in this disclosure, e.g., w1 and w2 may be 1 and T may be 24 hours, i.e., 86400 seconds.
In one embodiment, calculating a score for the target candidate job based on the first pod number, the run length of the target candidate job, and the second pod number comprises:
under the condition that the first pod number is larger than the second pod number, calculating a third score by using the first pod number and the second pod number, and calculating a fourth score by using the second pod number, the operation time length and the preset time length;
carrying out weighted summation on the third score and the fourth score by using the first preset weight and the second preset weight to obtain a score of the target candidate job;
the third score is positively correlated with the second pod number, is inversely correlated with the difference between the second pod number and the first pod number, and the fourth score is positively correlated with the running time length and the second pod number, and is inversely correlated with the preset time length.
And under the condition that the first pod number is larger than the second pod number, performing score calculation in a mode different from the mode of calculating the score under the condition that the first pod number is smaller than the second pod number, namely calculating a third score by using the first pod number and the second pod number, calculating a fourth score by using the second pod number, the running time and the preset time, and performing weighted summation on the third score and the fourth score by using the first preset weight and the second preset weight to obtain the score of the target candidate operation. In this way, in the process of calculating the score of the target candidate job, not only the third score and the fourth score, but also the influence degree of the third score and the fourth score in the calculation process, namely the weight, is considered, so that the accuracy of the obtained score can be improved.
As an example, in the case that the first pod number is greater than the second pod number, the score P1 of the target candidate job may be calculated by using the following calculation formula:
P1=w1*(N/(N-p)+N+1)+w2*max((2N+1)*t/T,t-T+(2N+1))。
wherein w1 is a first preset weight, w2 is a second preset weight, the third score is (N/(N-p) + N +1), and the fourth score is max ((2N +1) × T/T, T-T + (2N + 1)).
In one embodiment, calculating a score for the target candidate job based on the first pod number, the run length of the target candidate job, and the second pod number comprises:
under the condition that the first pod number is equal to the second pod number, calculating a fifth score by using the second pod number, the operation time length and the preset time length;
weighting the fifth score by using a second preset weight to obtain a score of the target candidate operation;
and the fifth score is positively correlated with the running time length and the second pod number and inversely correlated with the preset time length.
And under the condition that the first pod number is equal to the second pod number, performing score calculation in a mode different from the two score calculation modes, namely calculating a fifth score by using the second pod number, the operation time length and the preset time length, and performing weighted summation on the fifth score by using a second preset weight to obtain the score of the target candidate operation. In this way, in the process of calculating the score of the target candidate job, not only the fifth score calculated according to the second pod number but also the influence degree of the fifth score, that is, the weight is considered, so that the accuracy of the obtained score can be improved.
As an example, in the case that the first pod number is equal to the second pod number, the score P1 of the target candidate job can be calculated by using the following calculation formula:
P1=w2*max((2N+1)*t/T,t-T+(2N+1))。
wherein the fifth score is max ((2N +1) × T/T, T-T + (2N + 1)).
As shown in fig. 3, taking the second pod number of 4 as an example, that is, N is 4, w1 is 1, a curve including a first score and a third score, where the first score is (2N +1-p) in the case where p is less than N, the third score is (N/(N-p) + N +1) in the case where p is greater than N, and the score of the job is zero by the pod number of the job in the case where p is equal to N. As shown in fig. 4, w2 is 1, and the curves including the second score, the fourth score and the fifth score are max ((2N +1) × T/T, T-T + (2N + 1)).
The process of the above method is described in detail below with an embodiment.
Based on the priority of the target job X, a first candidate job list L1 is acquired.
The first candidate job list L1 is sorted, for example, in order of priority of the candidate jobs therein, resulting in a second candidate job list L2.
Assume that target job X has N pod not yet deployed, requiring J GPUs (graphics processors). At least some of the candidate jobs in the second candidate job list L2 include at least one candidate job group, the priority of the jobs in each candidate job group is the same, and a candidate job group with the same priority is divided into two parts according to whether the number of GPUs occupied by the jobs is less than J. That is, the candidate job components are a part a occupying less GPUs than J and a part B occupying more than or equal to J. For each of the two parts, a score for the candidate job is calculated using a weighted sum formula. For example, the running time t of each candidate job in each part, the number of scheduled pots, and the like are calculated, and the order of the candidate job groups in the second candidate list L2 is adjusted according to the scores of the candidate jobs in the candidate job groups. After the order adjustment, for example, each candidate job in part a is ranked before each candidate job in part B. Similar procedures as described above are performed for each of the candidate job groups, and the adjustment of the order of the candidate jobs in each of the candidate job groups in the second candidate job list is completed to obtain a third candidate list L3, and subsequently, job selection may be performed in L3.
The probability that the resource is preempted increases the further back the resource is ranked in the third candidate list L3, and in the process of selecting the resource of the job from L3 for preemption, the resource is preempted from the last of the third candidate list L3. That is, the resource preemption of the job is tried in order from the last to the front of the third candidate list L3, it is confirmed whether or not the resource requirement of the target job can be satisfied, and the preemption is stopped when the resource requirement is satisfied.
Taking the second pod number of the target job X as 2, i.e., N is 2, 4 GPUs (i.e., J is 4) are required as an example for description.
As shown in fig. 5, the first candidate job list L1 is ranked in descending order of priority to obtain a second candidate job list L2 with high priority first and low priority second. For example, 8 candidate jobs are included in the second candidate job list L2, the priorities of candidate job Y1 and candidate job Y2 are all high priority levels, and the priorities of candidate job Y3, candidate job Y4, candidate job Y5, candidate job Y6, candidate job Y7, and candidate job Y8 are all low priority levels, ranked after candidate job Y1 and candidate job Y2.
For a group of candidate jobs of the same priority in the second candidate job list L2, for example, a group of candidate jobs with a low priority level includes candidate job Y3, candidate job Y4, candidate job Y5, candidate job Y6, candidate job Y7, and candidate job Y8, which are divided into two parts according to the magnitude relation between the number of GPUs of the candidate jobs and 4 (the number of GPU demands of target job X), the number of GPUs being less than 4 before and greater than or equal to 4 after. And preempting the tasks occupying the number of GPUs larger than or equal to the GPU required number of the target operation X preferentially, and ensuring that the requirements of the target operation X can be met after the resources of a small number of operations are preempted as much as possible, so that the occupied operations are less as much as possible.
For each part divided in the previous step, for example, for a part with the number of GPUs greater than or equal to 4, a score is calculated according to the number of dots already scheduled of the job, and by comparing the first number of dots of the candidate job with 2 (the second number of dots of the target job X, i.e., N), the jobs in the candidate job group can be divided into a part with the number of dots less than 2 and a part greater than or equal to 2, i.e., C part and D part, respectively. In the part C, the pod numbers are arranged in a descending order, the higher the pod numbers are, the higher the ordering is, the higher the sorting is, the part D is arranged in an ascending order based on the pod numbers, and the higher the pod numbers are, the lower the ordering is. For both part C and part D, the score (score) of the job is calculated based on the number of pots of the job, with lower scores ranked further back and part C still ranked ahead of part D overall. Because the pod number is directly hooked with the occupied node number, the node requirement with the occupied node number larger than that of the target operation X and the most similar operation are preempted preferentially through sequencing, so that the operation as less as possible is preempted.
The other score is calculated based on the running time length, and for each of the jobs of the sections C and D, the other score calculated based on the running time length is calculated by the running time length, and jobs having a running time length exceeding T can be preferentially retained. And carrying out weighted summation with the scores calculated based on the pod numbers to obtain final scores, wherein the lower the score is, the lower the rank is, the later the score is.
The final score is calculated according to the jobs in the candidate job groups with the same priority, the order of the candidate job group in the second candidate job list L2 can be adjusted, and after the order of each candidate job group is adjusted, a third candidate list L3 is obtained. Resources of a job are selected from L3 for preemption, for example, resources of the job are sequentially attempted to be preempted from the last forward order of the third candidate list L3, it is confirmed whether the resource requirement of the target job can be satisfied, and preemption is stopped, for example, M jobs after the resource requirement is satisfied.
As shown in fig. 6, according to an embodiment of the present disclosure, the present disclosure also provides a resource allocation apparatus 600, including:
a list obtaining module 601, configured to obtain a first candidate job list based on a priority of a target job, where a priority of a candidate job in the first candidate job list is lower than a priority of the target job;
a calculating module 602, configured to calculate scores of at least some candidate jobs in the first candidate job list, where at least some candidate jobs include at least one candidate job group, and priorities of jobs in the same candidate job group are the same;
a determining module 603, configured to determine a first job from the first candidate job list according to a score of at least a part of the candidate jobs and a priority of the first candidate job list;
an allocation module 604 for allocating resources of the first job to the target job.
In one embodiment, the determining module 603 includes:
the sorting module is used for sorting the first candidate job list according to the priority of the candidate jobs in the first candidate job list to obtain a second candidate job list;
the adjusting module is used for adjusting the sequence of at least part of candidate jobs in the second candidate job list by using the scores of at least part of candidate jobs to obtain a third candidate job list, wherein the sequence of the rest of candidate jobs in the third candidate job list is unchanged relative to the second candidate job list, and the rest of candidate jobs are jobs in the third candidate job list except for at least part of candidate jobs;
and the job determining module is used for determining the first job based on the sequence of the third candidate job list and the resource amount required by the target job, wherein the first job is the last M jobs in the third candidate job list, the resource amount occupied by the last M jobs is greater than or equal to the resource amount required by the target job, and M is a positive integer.
In one embodiment, the first candidate job list includes a plurality of entries, any entry includes information of a candidate job and a corresponding at least one management unit pod, any candidate job includes a plurality of tasks, and one pod is used for running one task;
wherein calculating the score of at least part of the candidate jobs in the first candidate job list comprises:
calculating the score of the target candidate job according to the first pod number, the running time length of the target candidate job and the second pod number, wherein the target candidate job is any job in at least part of candidate jobs;
the first pod number is the number of successfully scheduled pods in the pods of the target candidate job, and the second pod number is the number of non-scheduled pods in the pods of the target job.
In one embodiment, the calculation module 602 includes:
the first calculation submodule is used for calculating a first score by using the first pod number and the second pod number and calculating a second score by using the second pod number, the operation time length and the preset time length under the condition that the first pod number is smaller than the second pod number;
the second calculation submodule is used for weighting and summing the first score and the second score by utilizing the first preset weight and the second preset weight to obtain the score of the target candidate operation;
the first score is positively correlated with the second pod number, is inversely correlated with the first pod number, and the second score is positively correlated with the operation duration and the second pod number, and is inversely correlated with the preset duration.
In one embodiment, the calculation module 602 includes:
the third calculation submodule is used for calculating a third score by using the first pod number and the second pod number and calculating a fourth score by using the second pod number, the operation time length and the preset time length under the condition that the first pod number is larger than the second pod number;
the fourth calculation submodule is used for weighting and summing the third score and the fourth score by utilizing the first preset weight and the second preset weight to obtain the score of the target candidate operation;
the third score is positively correlated with the second pod number, is inversely correlated with the difference between the second pod number and the first pod number, and the fourth score is positively correlated with the running time length and the second pod number, and is inversely correlated with the preset time length.
In one embodiment, the calculation module 602 includes:
the fifth calculating submodule is used for calculating a fifth score by utilizing the second pod number, the operation time length and the preset time length under the condition that the first pod number is equal to the second pod number;
the weighting module is used for weighting the fifth score by utilizing a second preset weight to obtain the score of the target candidate operation;
and the fifth score is positively correlated with the running time length and the second pod number and inversely correlated with the preset time length.
The resource allocation apparatus in each of the embodiments is an apparatus for implementing the resource allocation method in each of the embodiments, and the technical features and the technical effects correspond to each other, and are not described herein again.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
A non-transitory computer-readable storage medium of an embodiment of the present disclosure stores computer instructions for causing a computer to perform a resource allocation method provided by the present disclosure.
The computer program product of the embodiments of the present disclosure includes a computer program for causing a computer to execute the resource allocation method provided by the embodiments of the present disclosure.
FIG. 7 illustrates a schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM)702 or a computer program loaded from a storage unit 707 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
A number of components in the electronic device 700 are connected to the I/O interface 705, including: an input unit 706 such as a keyboard, a mouse, or the like; an output unit 707 such as various types of displays, speakers, and the like; a storage unit 708 such as a magnetic disk, optical disk, or the like; and a communication unit 709 such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
Computing unit 701 may be a variety of general purpose and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated artificial intelligence (I) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The computing unit 701 performs the respective methods and processes described above, such as the resource allocation method. For example, in some embodiments, the resource allocation method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of a computer program may be loaded onto and/or installed onto device 700 via ROM 702 and/or communications unit 709. When the computer program is loaded into the RAM703 and executed by the computing unit 701, one or more steps of the resource allocation method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the resource allocation method by any other suitable means (e.g., by means of firmware). Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The Server can be a cloud Server, also called a cloud computing Server or a cloud host, and is a host product in a cloud computing service system, so as to solve the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service ("Virtual Private Server", or simply "VPS"). The server may also be a server of a distributed system, or a server incorporating a blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (15)

1. A method of resource allocation, the method comprising:
acquiring a first candidate job list based on the priority of a target job, wherein the priority of a candidate job in the first candidate job list is lower than that of the target job;
calculating the scores of at least part of candidate jobs in the first candidate job list, wherein the at least part of candidate jobs comprise at least one candidate job group, and the priorities of jobs in the same candidate job group are the same;
determining a first job from the first candidate job list according to the score of the at least part of candidate jobs and the priority of the first candidate job list;
allocating resources of the first job to the target job.
2. The method of claim 1, wherein the determining a first job from the first list of candidate jobs based on the score of the at least a portion of the candidate jobs and the priority of the first list of candidate jobs comprises:
sorting the first candidate job list according to the priority of the candidate jobs in the first candidate job list to obtain a second candidate job list;
using the scores of the at least part of candidate jobs to adjust the sequence of the at least part of candidate jobs in the second candidate job list to obtain a third candidate job list, wherein the sequence of the rest of candidate jobs in the third candidate job list is unchanged relative to the second candidate job list, and the rest of candidate jobs are jobs in the third candidate job list except for the at least part of candidate jobs;
and determining the first job based on the sequence of the third candidate job list and the required resource amount of the target job, wherein the first job is the last M jobs in the third candidate job list, the resource amount occupied by the last M jobs is greater than or equal to the required resource amount of the target job, and M is a positive integer.
3. The method of claim 1, wherein the first candidate job list comprises a plurality of entries, any entry comprising information of a candidate job and a corresponding at least one management unit pod, any candidate job comprising a plurality of tasks, one pod for running one task;
wherein the calculating the score of at least part of the candidate jobs in the first candidate job list comprises:
calculating the score of the target candidate job according to the first pod number, the running time length of the target candidate job and the second pod number, wherein the target candidate job is any job in the at least part of candidate jobs;
the first pod number is the number of successfully scheduled pods in the pods of the target candidate job, and the second pod number is the number of non-scheduled pods in the pods of the target job.
4. The method of claim 3, wherein the calculating a score for the target candidate job as a function of the first pod number, the length of time the target candidate job is run, and the second pod number comprises:
under the condition that the first pod number is smaller than the second pod number, calculating a first score by using the first pod number and the second pod number, and calculating a second score by using the second pod number, the operation time length and a preset time length;
weighting and summing the first score and the second score by using a first preset weight and a second preset weight to obtain a score of the target candidate job;
wherein, the first score is in positive correlation with the second pod quantity, and is in inverse correlation with the first pod quantity, the second score is in positive correlation with the operation duration and the second pod quantity, and is in inverse correlation with the preset duration.
5. The method of claim 3, wherein the calculating a score for the target candidate job as a function of the first pod number, the length of time the target candidate job is run, and the second pod number comprises:
under the condition that the first pod number is larger than the second pod number, calculating a third score by using the first pod number and the second pod number, and calculating a fourth score by using the second pod number, the operation time length and a preset time length;
carrying out weighted summation on the third score and the fourth score by utilizing a first preset weight and a second preset weight to obtain a score of the target candidate operation;
wherein the third score is positively correlated with the second pod number, and is inversely correlated with the difference between the second pod number and the first pod number, and the fourth score is positively correlated with the operation duration and the second pod number, and is inversely correlated with the preset duration.
6. The method of claim 3, wherein the calculating a score for the target candidate job as a function of the first pod number, the length of time the target candidate job is run, and the second pod number comprises:
under the condition that the first pod number is equal to the second pod number, calculating a fifth score by using the second pod number, the operation time length and a preset time length;
weighting the fifth score by using a second preset weight to obtain a score of the target candidate job;
wherein the fifth score is positively correlated with the operating duration and the second pod number, and inversely correlated with the preset duration.
7. An apparatus for resource allocation, the apparatus comprising:
the system comprises a list acquisition module, a list acquisition module and a display module, wherein the list acquisition module is used for acquiring a first candidate job list based on the priority of a target job, and the priority of a candidate job in the first candidate job list is lower than that of the target job;
the calculation module is used for calculating the scores of at least part of candidate jobs in the first candidate job list, wherein the at least part of candidate jobs comprise at least one candidate job group, and the priorities of jobs in the same candidate job group are the same;
a determining module, configured to determine a first job from the first candidate job list according to the score of the at least part of candidate jobs and the priority of the first candidate job list;
an allocation module to allocate resources of the first job to the target job.
8. The apparatus of claim 7, wherein the means for determining comprises:
the sorting module is used for sorting the first candidate job list according to the priority of the candidate jobs in the first candidate job list to obtain a second candidate job list;
an adjusting module, configured to adjust an order of the at least part of candidate jobs in the second candidate job list by using the scores of the at least part of candidate jobs to obtain a third candidate job list, where an order of remaining candidate jobs in the third candidate job list is unchanged with respect to the second candidate job list, and the remaining candidate jobs are jobs in the third candidate job list other than the at least part of candidate jobs;
and a job determining module, configured to determine the first job based on an order of the third candidate job list and an amount of resources required by the target job, where the first job is a last M jobs in the third candidate job list, and an amount of resources occupied by the last M jobs is greater than or equal to an amount of resources required by the target job, and M is a positive integer.
9. The apparatus of claim 7, wherein the first candidate job list comprises a plurality of entries, any entry comprising information of a candidate job and a corresponding at least one management unit pod, any candidate job comprising a plurality of tasks, one pod for running one task;
wherein the calculating the score of at least part of the candidate jobs in the first candidate job list comprises:
calculating the score of the target candidate job according to the first pod number, the running time length of the target candidate job and the second pod number, wherein the target candidate job is any job in the at least part of candidate jobs;
the first pod number is the number of successfully scheduled pods in the pods of the target candidate job, and the second pod number is the number of non-scheduled pods in the pods of the target job.
10. The apparatus of claim 9, wherein the computing module comprises:
the first calculation submodule is used for calculating a first score by using the first pod number and the second pod number and calculating a second score by using the second pod number, the operation time length and a preset time length under the condition that the first pod number is smaller than the second pod number;
the second calculation submodule is used for weighting and summing the first score and the second score by utilizing a first preset weight and a second preset weight to obtain the score of the target candidate operation;
wherein, the first score is in positive correlation with the second pod quantity, and is in inverse correlation with the first pod quantity, the second score is in positive correlation with the operation duration and the second pod quantity, and is in inverse correlation with the preset duration.
11. The apparatus of claim 9, wherein the computing module comprises:
the third calculation submodule is used for calculating a third score by using the first pod number and the second pod number and calculating a fourth score by using the second pod number, the operation time length and a preset time length under the condition that the first pod number is larger than the second pod number;
the fourth calculation submodule is used for weighting and summing the third score and the fourth score by utilizing the first preset weight and the second preset weight to obtain the score of the target candidate operation;
wherein the third score is positively correlated with the second pod number, and is inversely correlated with the difference between the second pod number and the first pod number, and the fourth score is positively correlated with the operation duration and the second pod number, and is inversely correlated with the preset duration.
12. The apparatus of claim 9, wherein the computing module comprises:
a fifth calculating submodule, configured to calculate a fifth score using the second pod number, the operation duration, and a preset duration when the first pod number is equal to the second pod number;
the weighting module is used for weighting the fifth score by using a second preset weight to obtain the score of the target candidate operation;
wherein the fifth score is positively correlated with the operating duration and the second pod number, and inversely correlated with the preset duration.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of resource allocation according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the resource allocation method of any one of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements a resource allocation method according to any one of claims 1-6.
CN202111643857.1A 2021-12-29 2021-12-29 Resource allocation method and device and electronic equipment Pending CN114327897A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111643857.1A CN114327897A (en) 2021-12-29 2021-12-29 Resource allocation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111643857.1A CN114327897A (en) 2021-12-29 2021-12-29 Resource allocation method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114327897A true CN114327897A (en) 2022-04-12

Family

ID=81016930

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111643857.1A Pending CN114327897A (en) 2021-12-29 2021-12-29 Resource allocation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114327897A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117097681A (en) * 2023-10-16 2023-11-21 腾讯科技(深圳)有限公司 Scheduling method and device of network resources, storage medium and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117097681A (en) * 2023-10-16 2023-11-21 腾讯科技(深圳)有限公司 Scheduling method and device of network resources, storage medium and electronic equipment
CN117097681B (en) * 2023-10-16 2024-02-09 腾讯科技(深圳)有限公司 Scheduling method and device of network resources, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
JP2020149675A (en) System and method for optimizing scheduling of non-preemptive task in multi-robotic environment
CN114968565A (en) Resource management method, device, electronic equipment, storage medium and server
CN113986497B (en) Queue scheduling method, device and system based on multi-tenant technology
CN113835823A (en) Resource scheduling method and device, electronic equipment and computer readable storage medium
Biswas et al. Multi-level queue for task scheduling in heterogeneous distributed computing system
CN114327894A (en) Resource allocation method, device, electronic equipment and storage medium
KR20140097815A (en) Resource allocation and apparatus
CN114968567A (en) Method, apparatus and medium for allocating computing resources of a compute node
CN115658311A (en) Resource scheduling method, device, equipment and medium
CN115168040A (en) Job preemption scheduling method, device, equipment and storage medium
CN114416357A (en) Method and device for creating container group, electronic equipment and medium
CN114327897A (en) Resource allocation method and device and electronic equipment
Naik A deadline-based elastic approach for balanced task scheduling in computing cloud environment
CN113220452A (en) Resource allocation method, model training method, device and electronic equipment
CN112559179A (en) Job processing method and device
CN114579187B (en) Instruction distribution method and device, electronic equipment and readable storage medium
CN114579305B (en) Resource control method, device, equipment and medium for function calculation
CN115858169A (en) Operation resource allocation method and device, electronic equipment and storage medium
CN114418063B (en) Method and device for distributing network layer in neural network model
CN113254200B (en) Resource arrangement method and intelligent agent
CN115438007A (en) File merging method and device, electronic equipment and medium
CN113032092A (en) Distributed computing method, device and platform
CN113127205B (en) Workflow scheduling method meeting deadline constraint and optimizing cost in cloud
CN117762583A (en) Task scheduling method, device, electronic equipment and storage medium
CN115379000B (en) Service platform capacity expansion method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination