Resource scheduling method and device, equipment, storage medium and computer program product
By obtaining the maximum value of the resource requirements of bare metal instances and building reference examples, determining the resource situation of bare metal nodes, and using genetic algorithms for scheduling, the problem of possible failure of resource scheduling of bare metal instances in the prior art is solved, and a higher scheduling success rate is achieved.
Patent Information
- Application Number
- CN202411820423.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-18
AI Technical Summary
The resource scheduling scheme for bare metal instances in the prior art has the problem of possible scheduling failure, especially in the case of resource shortage.
By obtaining the maximum value of the resource requirements of the instance to be scheduled, a reference example is constructed, the resource situation of the bare metal node resource is determined, and the resource situation is scheduled according to the resource situation. When resources are sufficient, unallocated bare metal nodes are traversed to allocate instances; when resources are insufficient, genetic algorithms are used to schedule according to instance priorities.
It effectively avoids the possibility of scheduling failure, improves the resource scheduling success rate of bare metal instances, and solves the problem of scheduling failure when resources are scarce in the prior art.
Smart Images

Figure CN119645575A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of resource scheduling, and in particular to a resource scheduling method, apparatus, device, storage medium and computer program product. Background Art
[0002] OpenStack is a widely used open source cloud computing management platform project, which mainly provides virtualization services and management functions for computing, networking, and storage. Bare metal instances provide direct access and control to physical servers, allowing tenants to run operating systems directly on physical hardware without going through any virtualization layer. The Ironic project in OpenStack allows users to manage physical machines through a unified OpenStack API (application programming interface) like managing virtual machines, including bare metal server registration, discovery, configuration, deployment of operating systems, power management, and lifecycle management. OpenStack also provides scheduling algorithms and rich filters for more intelligent creation of bare metal instances. The difference between bare metal scheduling and virtual machine (i.e. virtual machine) scheduling is that a computing node can create multiple virtual machines, while a bare metal node can only create one bare metal instance.
[0003] Among them, the existing bare metal instance scheduling is mainly for the scheduling of a single instance. For batch scheduling, it can only be a cyclic single scheduling operation. Its scheduling algorithm is relatively simple, and in the case of resource shortage, batch scheduling of bare metal instances will lead to scheduling failure.
[0004] As described above, the resource scheduling solution for bare metal instances in the prior art may fail in scheduling. Summary of the invention
[0005] The purpose of the present application is to provide a resource scheduling method, apparatus, device, storage medium and computer program product to solve the problem of possible scheduling failure in the resource scheduling scheme for bare metal instances in the prior art.
[0006] In order to solve the above technical problems, an embodiment of the present application provides a resource scheduling method, including:
[0007] Get the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0008] constructing a reference instance according to the maximum value;
[0009] Determine, according to the reference instance, a resource status of a bare metal node resource; the bare metal node resource includes resources of the target type;
[0010] According to the resource situation, resource scheduling of the bare metal node resources is performed for the instance to be scheduled.
[0011] Optionally, determining the resource status of the bare metal node resources according to the reference instance includes:
[0012] Determine the number of bare metal node resources that can meet the resource requirements of the reference instance;
[0013] The resource status of the bare metal node resources is determined according to the number of nodes and the total number of nodes corresponding to the bare metal node resources.
[0014] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0015] When the resource situation indicates that the resources are sufficient, traverse the unallocated bare metal nodes in the bare metal node resources for one of the instances to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled;
[0016] Obtaining a weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled;
[0017] According to the weight, a target bare metal node allocated to the instance to be scheduled is determined from the candidate bare metal nodes.
[0018] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0019] When the resource situation indicates that the resources are insufficient, a genetic algorithm is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
[0020] Optionally, the using a genetic algorithm to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes:
[0021] Generate an initial allocation plan for bare metal node resources;
[0022] Using a genetic algorithm, according to the initial allocation scheme, the priority of the instance to be scheduled, the fitness determination method and the mutation method, resource scheduling of the bare metal node resources for the instance to be scheduled;
[0023] The fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness;
[0024] The variation method includes: allocating a candidate bare metal node with the smallest weight value for the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node among the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
[0025] Optionally, also include:
[0026] Receive requests for batch scheduling instances;
[0027] According to the request, allocatable bare metal nodes are obtained from a database to obtain the bare metal node resources.
[0028] Optionally, also include:
[0029] Get the resource information of the bare metal node;
[0030] The resource information is stored in a database and updated regularly.
[0031] The embodiment of the present application also provides a resource scheduling device, including:
[0032] A first acquisition module is used to acquire the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0033] A first construction module, configured to construct a reference instance according to the maximum value;
[0034] A first determination module is used to determine the resource status of bare metal node resources according to the reference instance; the bare metal node resources include resources of the target type;
[0035] The first scheduling module is used to schedule the bare metal node resources for the instance to be scheduled according to the resource situation.
[0036] Optionally, determining the resource status of the bare metal node resources according to the reference instance includes:
[0037] Determine the number of bare metal node resources that can meet the resource requirements of the reference instance;
[0038] The resource status of the bare metal node resources is determined according to the number of nodes and the total number of nodes corresponding to the bare metal node resources.
[0039] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0040] When the resource situation indicates that the resources are sufficient, traverse the unallocated bare metal nodes in the bare metal node resources for one of the instances to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled;
[0041] Obtaining a weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled;
[0042] According to the weight, a target bare metal node allocated to the instance to be scheduled is determined from the candidate bare metal nodes.
[0043] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0044] When the resource situation indicates that the resources are insufficient, a genetic algorithm is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
[0045] Optionally, the using a genetic algorithm to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes:
[0046] Generate an initial allocation plan for bare metal node resources;
[0047] Using a genetic algorithm, according to the initial allocation scheme, the priority of the instance to be scheduled, the fitness determination method and the mutation method, resource scheduling of the bare metal node resources for the instance to be scheduled;
[0048] The fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness;
[0049] The variation method includes: allocating a candidate bare metal node with the smallest weight value for the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node among the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
[0050] Optionally, also include:
[0051] A first receiving module, used to receive a request for batch scheduling instances;
[0052] The second acquisition module is used to acquire the allocatable bare metal nodes from the database according to the request to obtain the bare metal node resources.
[0053] Optionally, also include:
[0054] The third acquisition module is used to obtain resource information of the bare metal node;
[0055] The storage and updating module is used to store the resource information in a database and update it regularly.
[0056] The embodiment of the present application also provides a resource scheduling device, including: a processor;
[0057] The processor is used to obtain the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0058] constructing a reference instance according to the maximum value;
[0059] Determine, according to the reference instance, a resource status of a bare metal node resource; the bare metal node resource includes resources of the target type;
[0060] According to the resource situation, resource scheduling of the bare metal node resources is performed for the instance to be scheduled.
[0061] Optionally, determining the resource status of the bare metal node resources according to the reference instance includes:
[0062] Determine the number of bare metal node resources that can meet the resource requirements of the reference instance;
[0063] The resource status of the bare metal node resources is determined according to the number of nodes and the total number of nodes corresponding to the bare metal node resources.
[0064] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0065] When the resource situation indicates that the resources are sufficient, traverse the unallocated bare metal nodes in the bare metal node resources for one of the instances to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled;
[0066] Obtaining a weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled;
[0067] According to the weight, a target bare metal node allocated to the instance to be scheduled is determined from the candidate bare metal nodes.
[0068] Optionally, the performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes:
[0069] When the resource situation indicates that the resources are insufficient, a genetic algorithm is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
[0070] Optionally, the using a genetic algorithm to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes:
[0071] Generate an initial allocation plan for bare metal node resources;
[0072] Using a genetic algorithm, according to the initial allocation scheme, the priority of the instance to be scheduled, the fitness determination method and the mutation method, resource scheduling of the bare metal node resources for the instance to be scheduled;
[0073] The fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness;
[0074] The variation method includes: allocating a candidate bare metal node with the smallest weight value for the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node among the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
[0075] Optionally, the processor is further configured to:
[0076] receiving, via a transceiver, a request for batch scheduling instances;
[0077] According to the request, allocatable bare metal nodes are obtained from a database to obtain the bare metal node resources.
[0078] Optionally, the processor is further configured to:
[0079] Get the resource information of the bare metal node;
[0080] The resource information is stored in a database and updated regularly.
[0081] An embodiment of the present application also provides a resource scheduling device, including a memory, a processor, and a program stored in the memory and executable on the processor; when the processor executes the program, the above-mentioned resource scheduling method is implemented.
[0082] The embodiment of the present application also provides a readable storage medium on which a program is stored, and when the program is executed by a processor, the steps in the above-mentioned resource scheduling method are implemented.
[0083] The embodiment of the present application also provides a computer program product, including computer instructions, which implement the steps of the above-mentioned resource scheduling method when executed by a processor.
[0084] The beneficial effects of the above technical solution of the present application are as follows:
[0085] In the above scheme, the resource scheduling method obtains the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructs a reference instance based on the maximum value; determines the resource situation of the bare metal node resources based on the reference instance; the bare metal node resources include the resources of the target type; based on the resource situation, performs resource scheduling of the bare metal node resources for the instance to be scheduled; can support resource scheduling according to the resource situation, thereby avoiding the possibility of scheduling failure, and solving the problem of possible scheduling failure in the resource scheduling scheme for bare metal instances in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0086] Figure 1 A schematic diagram of a resource scheduling method flow in an embodiment of the present application;
[0087] Figure 2 A schematic diagram of a bare metal batch scheduling architecture according to an embodiment of the present application;
[0088] Figure 3 The resource scheduling method of the embodiment of the present application is specifically implemented as follows: Figure 1 ;
[0089] Figure 4 The resource scheduling method of the embodiment of the present application is specifically implemented as follows: Figure 2 ;
[0090] Figure 5 This is a schematic diagram of the bare metal instance batch scheduling process of an embodiment of the present application;
[0091] Figure 6 This is a schematic diagram of the structure of a resource scheduling device according to an embodiment of the present application;
[0092] Figure 7 This is a schematic diagram of the resource scheduling device structure of an embodiment of the present application. DETAILED DESCRIPTION
[0093] In order to make the technical problems, technical solutions and advantages to be solved by the present application clearer, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0094] The following first introduces the relevant contents of this plan.
[0095] The current bare metal instance scheduling is mainly for single instance scheduling: the scheduler uses a series of filters and weight calculation methods to decide which bare metal node to assign the bare metal instance to. There is no suitable scheduling strategy for batch scheduling, and instances can only be scheduled by calling the instance creation interface in a loop; and it is impossible to know whether the bare metal resources in the environment are sufficient to schedule the bare metal instance before creating the bare metal instance. When the bare metal node resources are tight, scheduling will fail. For example, there are two bare metal nodes. Node 1 is configured as (2, 30, 200) and Node 2 is configured as (2, 20, 300). The parameters in the configuration are cpu_cores (number of CPU cores), mem_size (memory size), and disk_size (disk size). Suppose there are two bare metal instances waiting to be scheduled. The specifications of Instance 1 are (2, 20, 200) and those of Instance 2 are (2, 30, 100). The parameters in the specifications correspond to the parameters in the node configuration. According to the current scheduling logic, Instance 1 may be scheduled to Node 1, but Instance 2 cannot be scheduled. However, the actual situation is that Instance 1 can be scheduled to Node 2, and Instance 2 can be scheduled to Node 1.
[0096] Based on the above, the present application provides a resource scheduling method to solve the problem that the resource scheduling scheme for bare metal instances in the existing technology may fail to schedule. Figure 1 As shown, including:
[0097] Step 11: Obtain the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0098] Among them, the "maximum value of the resource demand of the target type" is, for example: the maximum number of CPU cores, maximum memory and / or maximum disk (the corresponding demand types are: computing intensive, IO (transceiver interface) intensive, memory intensive), but is not limited to this.
[0099] Step 12: constructing a reference instance according to the maximum value;
[0100] For example, a maximum bare metal instance can be constructed based on the maximum number of CPU cores, maximum memory, and maximum disk, but this is not a limitation.
[0101] Step 13: Determine the resource status of bare metal node resources according to the reference instance; the bare metal node resources include resources of the target type;
[0102] The resource status may indicate whether the resources are sufficient, but is not limited thereto.
[0103] Step 14: According to the resource situation, perform resource scheduling of the bare metal node resources for the instance to be scheduled.
[0104] Among them, step 14 may include: according to the resource situation, allocating bare metal nodes for the instances to be scheduled, and then cyclically calling the OpenStack interface (specifying the allocated bare metal nodes) to directionally create bare metal instances, but is not limited to this.
[0105] The resource scheduling method provided in the embodiment of the present application obtains the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructs a reference instance based on the maximum value; determines the resource situation of the bare metal node resources based on the reference instance; the bare metal node resources include the resources of the target type; and performs resource scheduling of the bare metal node resources for the instance to be scheduled based on the resource situation; and can support resource scheduling based on the resource situation, thereby avoiding the possibility of scheduling failure, and solving the problem of possible scheduling failure in the resource scheduling scheme for bare metal instances in the prior art.
[0106] Wherein, determining the resource situation of the bare metal node resources according to the reference instance includes: determining the number of nodes in the bare metal node resources that can meet the resource requirements of the reference instance; determining the resource situation of the bare metal node resources according to the number of nodes and the total number of nodes corresponding to the bare metal node resources. In this way, the resource situation of the bare metal node resources can be accurately determined. Wherein, "determining the resource situation of the bare metal node resources according to the number of nodes and the total number of nodes corresponding to the bare metal node resources" may include: when the ratio between the number of nodes and the total number of nodes corresponding to the bare metal node resources is greater than a first threshold, determining that the resource situation of the bare metal node resources is sufficient resources; otherwise, determining that the resource situation of the bare metal node resources is insufficient resources; but it is not limited to this (for example, when the ratio is equal to the first threshold, it is also determined that the resources are sufficient, etc.).
[0107] In an embodiment of the present application, the resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: when the resource situation indicates that the resources are sufficient, traversing the unallocated bare metal nodes in the bare metal node resources for one instance to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled; obtaining the weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled; and determining the target bare metal node allocated to the instance to be scheduled from the candidate bare metal nodes according to the weight. This can support the allocation of bare metal instances using the least resources as much as possible. Among them, "traversing the unallocated bare metal nodes in the bare metal node resources for one instance to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled" may include: obtaining the unallocated bare metal node whose node configuration is greater than (or equal to) the bare metal instance specification as the candidate bare metal node; the node configuration may include: at least one of the number of CPU cores, memory size, and disk size; the bare metal instance specification may include: at least one of the number of CPU cores, memory size, and disk size; but it is not limited to this. Among them, "according to the demand type corresponding to the instance to be scheduled, obtaining the weight of the candidate bare metal node" may include: obtaining the weight according to formula 1, and the formula 1 is: weight Z = k×cpu_cores (number of CPU cores) + m×mem_size (memory size) + n×disk_size (disk size), where k, m, and n can be set according to the demand type of the instance, and the demand types of the instance are respectively computing intensive, IO (transceiver interface) intensive, and memory intensive (corresponding to k, m, and n respectively); but it is not limited to this. Among them, "according to the weight, determining the target bare metal node assigned to the instance to be scheduled from the candidate bare metal nodes" may include: selecting a candidate bare metal node with the smallest weight value as the target bare metal node, and assigning it to the corresponding instance to be scheduled; in addition, the target bare metal node can also be set to allocated, but it is not limited to this.
[0108] The resource scheduling of the bare metal node resources for the to-be-scheduled instance according to the resource situation includes: when the resource situation indicates that the resources are insufficient, using a genetic algorithm to schedule the bare metal node resources for the to-be-scheduled instance according to the priority of the to-be-scheduled instance. This can support the search for the optimal allocation solution and prioritize the allocation of bare metal instances with high priorities.
[0109] In an embodiment of the present application, the use of a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes: generating an initial allocation scheme for bare metal node resources; using a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the initial allocation scheme, the priority of the instance to be scheduled, a fitness determination method and a variation method (for example, including: performing cross iteration to obtain a final or optimal allocation scheme, and performing the resource scheduling accordingly); wherein the fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness (in this scheme, the schemes with the top 10% of fitness in each allocation scheme can be retained as the parent, but not limited to this); the variation method includes: allocating a candidate bare metal node with the smallest weight value for the instance to be scheduled with the highest priority that has not been successfully allocated in the allocation scheme; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node in the bare metal node resources that can meet the resource demand of the instance to be scheduled. In this way, resource scheduling using a genetic algorithm can be specifically implemented. Among them, fitness can be understood as a parameter involved in the genetic algorithm, and the genetic algorithm can obtain the final allocation plan, but it is not limited to this.
[0110] Furthermore, the resource scheduling method further includes: receiving a request for batch scheduling instances; and obtaining the allocatable bare metal nodes from a database according to the request to obtain the bare metal node resources. This can support resource scheduling according to batch scheduling requirements.
[0111] In the embodiment of the present application, the resource scheduling method further includes: obtaining resource information of the bare metal node (such as the number of CPU cores, memory size, disk size, etc.); storing the resource information in a database and updating it regularly. This facilitates the subsequent use of the resource information and ensures the accuracy of the resource information.
[0112] The resource scheduling method provided in the embodiment of the present application is illustrated below.
[0113] In view of the above technical problems, the embodiment of the present application provides a resource scheduling method, which can be specifically implemented as a bare metal instance batch scheduling method based on OpenStack, mainly involving: the scheduling service (which can be included in the resource scheduling device) queries the configuration information of all bare metal nodes in the OpenStack cluster (such as CPU, memory, disk, etc.) and stores it in the database; the scheduling service receives the user's request for batch scheduling of bare metal instances, reads the bare metal node resource information from the database, and can calculate the weight to sort the bare metal nodes, and then allocates the bare metal instances to the bare metal nodes according to different allocation algorithms. Finally, the OpenStack API is called cyclically to create bare metal instances.
[0114] For details, please refer to Figure 2 ,This solution receives batch scheduling requests from users through a scheduling service, and reads the configuration information of (allocatable) bare metal nodes from the database, and uses an allocation algorithm to allocate (under the OpenStack cluster) a suitable bare metal node to each bare metal instance (e.g., ,evaluate whether the bare metal resources in the current environment (or under the current OpenStack cluster) are sufficient. If sufficient, use the resource minimization allocation algorithm to allocate a suitable bare metal node to each bare metal instance, otherwise use the priority allocation algorithm). ,After all bare metal instances have nodes allocated, the OpenStack interface for creating bare metal instances is ,called cyclically, and the allocated bare metal nodes are specified to create the bare metal instances.
[0115] The following are examples to illustrate each part of this plan.
[0116] 1. Obtain and update bare metal node resource information;
[0117] During the scheduling process, the scheduling service can obtain all bare metal node resource information managed by the OpenStack cluster, and this information is updated less frequently, so the scheduling service can read all bare metal node information from the OpenStack interface when the service starts and store it in a local database (which may correspond to the above-mentioned acquisition of bare metal node resource information; storing the resource information in the database). When the scheduling service receives a scheduling request, it reads the configuration information of the bare metal node from the database for scheduling (which may correspond to the above-mentioned reception of a request for batch scheduling instances; according to the request, the allocatable bare metal nodes are obtained from the database to obtain the bare metal node resources). Since bare metal nodes may be added or deleted, the scheduling service can periodically update the bare metal resource information (which may correspond to periodically updating the resource information of bare metal nodes).
[0118] 2. Allocation algorithm;
[0119] This solution provides two methods for allocating bare metal instances: resource minimization allocation and priority allocation. Among them, resource minimization allocation can allocate bare metal instances using the least resources as much as possible.
[0120] The following are examples of the two allocation methods.
[0121] (1) The resource minimization allocation process can be as follows Figure 3 The following contents are involved:
[0122] First, the weight of the bare metal node is explained, where the weight calculation formula of the bare metal node can be: k×cpu_cores+m×mem_size+n×disk_size, where k, m, and n can be set according to the demand type of the instance. For example, the demand types of the instances corresponding to k, m, and n respectively are: computing intensive, IO (transceiver interface) intensive, and memory intensive; and each demand type has three levels: high, medium, and low, and the corresponding coefficient values can be 10, 5, and 1. In this solution, each bare metal instance can have multiple demand types.
[0123] Regarding the allocation process, it may include: traversing the bare metal instance list, and for each bare metal instance, traversing the unallocated bare metal node list; for the traversed bare metal node, it may be performed: judging whether the current bare metal instance can be allocated to this bare metal node (it may also be understood as judging whether the currently traversed bare metal node can be allocated with a bare metal instance), if the number of CPU cores, memory size, and disk size in the bare metal instance specification are all smaller than the configuration of the bare metal node (the corresponding configuration size in: number of CPU cores, memory size, and disk size), it may be allocated (which may correspond to the above-mentioned traversal of the unallocated bare metal nodes in the bare metal node resources for one of the instances to be scheduled, and obtaining a candidate bare metal node that can meet the resource requirements of the instance to be scheduled). If it may be allocated, the k, m, and n coefficients of the current bare metal instance may be used to calculate the weight value of the bare metal node (which may correspond to the above-mentioned acquisition of the weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled). If it cannot be allocated, it can be determined whether the currently traversed bare metal node is the last bare metal node; if not, continue to traverse the next bare metal node; if so, that is, the currently traversed bare metal node is the last one (it can also be understood as after the traversal of each bare metal node is completed), a bare metal node with the smallest weight value can be selected (which can correspond to the above-mentioned target bare metal node), and the current bare metal instance is allocated to the selected bare metal node (which can correspond to the above-mentioned determination of the target bare metal node allocated to the instance to be scheduled from the candidate bare metal nodes according to the weight), and the selected current bare metal node is set (or marked) as allocated. In addition, if all the traversed bare metal nodes cannot be allocated to the current bare metal instance, the allocation failure is returned, and the bare metal node allocation operation can continue for the next bare metal instance.
[0124] In addition, if the current bare metal instance is the last one, it indicates that all bare metal instances have been successfully allocated (that is, after the allocation of the last bare metal instance is completed), and the allocation result can be returned. If the current bare metal instance is not the last bare metal instance, the next bare metal instance can be allocated; for details, please refer to the allocation content of the current bare metal instance, which will not be repeated here.
[0125] (2) Priority allocation can find the best allocation solution when resources are scarce, and prioritize bare metal instances with high priority. The priority allocation process can be as follows: Figure 4As shown, a genetic algorithm is used to find the optimal allocation scheme (which may correspond to the above-mentioned use of a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled); for example: first randomly generate an initial set of allocation schemes (which may include multiple initial schemes), and the number of initial schemes may be equal to (number of instances) × (number of nodes that can be allocated) × 50. Afterwards, the fitness of each allocation scheme may be calculated, and the fitness calculation method may be the sum of the priorities of the bare metal instances that can be allocated in the scheme (which may correspond to the above-mentioned sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness). The larger the fitness, the higher the priority of the bare metal instances. For a set of allocation schemes, some individuals need to be selected to enter the next generation, for example: first retain the schemes with the top 10% of fitness in each scheme (as the parent generation); then use the round-robin selection method to select the parent generation, and use the crossover method to generate two new allocation schemes (for example, swap the last 5 instances in the two schemes to form a new scheme). The newly generated allocation scheme can be mutated, such as selecting the highest priority instance that has not been successfully allocated in the scheme (for example, the instance in the scheme does not match the node), and assigning it to an allocable bare metal node with the smallest weight value (which may correspond to the above-mentioned mutation method including: for the highest priority to-be-scheduled instance that has not been successfully allocated in the allocation scheme, assign a candidate bare metal node with the smallest weight value; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node in the bare metal node resources that can meet the resource requirements of the instance to be scheduled), and the probability of mutation can be 0.01 (which can be understood as updating the allocation node of the instance in the scheme). The above process can be repeated until the number of iterations (upper limit) is reached or the fitness improvement is not obvious, and the allocation scheme with the best fitness is output (that is, the allocation scheme with the largest fitness is selected as the result). Among them, the method for judging whether the fitness improvement is obvious can be that in the past 5 iterations, the fitness improvement of the optimal allocation scheme is less than 0.5% of the fitness, which means that the fitness improvement is not obvious, but it is not limited to this. The above priority allocation process may correspond to the above-mentioned initial allocation plan for generating bare metal node resources; utilizing a genetic algorithm, according to the initial allocation plan, the priority of the instance to be scheduled, the fitness determination method, and the mutation method, the bare metal node resources are scheduled for the instance to be scheduled.
[0126] 3. Bare metal resource assessment;
[0127] The scheduling service can determine whether bare metal resources are tight based on a preset threshold; for example: first find the maximum number of CPU cores, maximum memory, and maximum disk from the bare metal instance list, and construct a maximum bare metal instance (which may correspond to the maximum value of the resource demand of the target type corresponding to the instance to be scheduled obtained above; based on the maximum value, build a reference instance); then, obtain the resource ratio, and the resource ratio calculation formula may be: num_schedulable (the number of bare metal nodes that can be allocated to the maximum bare metal instance) / num_bare_metal_instance (the number of bare metal instances); if the resource ratio is greater than the threshold (which may be determined based on empirical values), it may indicate that resources are sufficient and all bare metal instances can be allocated successfully; otherwise, it may be determined that resources are insufficient (which may correspond to the number of nodes in the bare metal node resources that can meet the resource requirements of the reference instance determined above; the resource situation of the bare metal node resources is determined based on the number of nodes and the total number of nodes corresponding to the bare metal node resources). For example, if the threshold is set to 1, and 5 bare metal instances need to be scheduled, a maximum bare metal instance A is constructed first; assuming that there are 20 bare metal nodes to be scheduled, of which 8 nodes can schedule instance A, then the resource ratio is 8 / 5=1.6, which is greater than the threshold and indicates that the resources are sufficient. In this scheme, if the resources are sufficient, resource minimization allocation can be used (corresponding to the above-mentioned case where the resource situation indicates that the resources are sufficient, for one of the instances to be scheduled, the unallocated bare metal nodes in the bare metal node resources are traversed to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled; according to the demand type corresponding to the instance to be scheduled, the weight of the candidate bare metal node is obtained; according to the weight, the target bare metal node assigned to the instance to be scheduled is determined from the candidate bare metal nodes); otherwise (i.e., resources are scarce or insufficient), some instances may not be allocated. In this case, priority allocation can be used to find the optimal allocation scheme, and instances with high priority are allocated first (corresponding to the above-mentioned case where the resource situation indicates that the resources are insufficient, the genetic algorithm is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled).
[0128] 4. Bare metal batch scheduling process;
[0129] The bare metal (instance) batch scheduling process of this solution can be as follows Figure 5As shown, it includes: first, the scheduling service receives the user's request for batch scheduling of bare metal instances, and then reads the allocatable bare metal node information from the database (that is, reads the bare metal node resource information in the database). Evaluate whether the bare metal resources in the current environment are sufficient. If the resources are sufficient, you can directly use the resource minimization allocation (method), otherwise use the priority allocation (method). After allocating bare metal nodes to all bare metal instances, you can call the OpenStack create bare metal instance interface cyclically and specify the allocated bare metal nodes to create bare metal instances.
[0130] Based on the above, the solution provided by the embodiment of the present application involves the following contents:
[0131] 1) Provide a scheduling service to receive user requests to create bare metal instances in batches, allocate bare metal nodes to bare metal instances (allocate bare metal nodes to each bare metal instance based on an allocation algorithm), and cyclically call the OpenStack interface to create bare metal instances in a targeted manner (cyclically call the OpenStack interface to create bare metal instances using specified allocated bare metal nodes).
[0132] 2) Obtain resource information of all bare metal nodes in the environment (such as the number of CPU cores, memory size, and disk size), store it in the database, and provide a scheduled task to refresh the bare metal node information. For example, when the scheduling service starts, it queries the configuration information of all bare metal nodes in the OpenStack cluster and stores it in the local database. It is then updated regularly so that the configuration information of bare metal nodes can be queried from the local database when a batch creation request is received.
[0133] 3) Provide two allocation algorithms: use resource minimization allocation when resources are sufficient, and use priority allocation when resources are scarce. In this way, when resources are sufficient, this solution can allocate bare metal nodes (or schedule resources) with the goal of minimizing the total amount of allocated resources; when resources are insufficient, use a genetic algorithm to prioritize bare metal instances with high priority (i.e., use a genetic algorithm for node allocation or resource scheduling). 4) Provide a method for calculating whether bare metal node resources are sufficient, and flexibly control which allocation algorithm to use through a threshold.
[0134] Based on the above, this solution can improve the overall utilization of cluster resources. Specifically, this solution:
[0135] 1) Compared with the existing technology which is mainly applied to batch scheduling of virtual machines and is not suitable for batch scheduling of bare metal instances, a batch scheduling solution is provided for bare metal instances.
[0136] 2) It provides a method for batch scheduling of bare metal instances, which can solve the problem of scheduling failure in existing scheduling strategies. That is, it can solve the problem of possible allocation failure in existing technologies and find the optimal solution for the allocation plan.
[0137] 3) Two allocation algorithms are provided. When resources are sufficient, resource minimization allocation can be used, which has a fast allocation speed and consumes less node resources. When resources are scarce, priority allocation can be used to give priority to instances with extremely high priority.
[0138] 4) A threshold is provided to control which allocation algorithm is used, which can be flexibly adjusted according to the actual usage scenario.
[0139] It should be noted that this solution has a broad market application prospect in the field of cloud computing, and provides a very effective solution to the current problems to be solved in the industry; this solution can implement a bare metal instance batch scheduling method based on OpenStack, making up for the shortcomings of existing technical solutions, and is a low-cost, feasible and easy-to-promote bare metal batch scheduling technology with extremely high practical value, extremely broad market prospects and wide market applications; it can be applied to many application systems such as cloud platforms, computing network simulation platforms and other cloud platform application systems, without any restrictions here.
[0140] The present application also provides a resource scheduling device, such as Figure 6 As shown, including:
[0141] A first acquisition module 61 is used to acquire the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0142] A first construction module 62, configured to construct a reference instance according to the maximum value;
[0143] A first determination module 63 is used to determine the resource status of bare metal node resources according to the reference instance; the bare metal node resources include resources of the target type;
[0144] The first scheduling module 64 is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation.
[0145] The resource scheduling device provided in the embodiment of the present application obtains the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructs a reference instance based on the maximum value; determines the resource situation of the bare metal node resources based on the reference instance; the bare metal node resources include the resources of the target type; and performs resource scheduling of the bare metal node resources for the instance to be scheduled based on the resource situation; and can support resource scheduling based on the resource situation, thereby avoiding the possibility of scheduling failure, and solving the problem of possible scheduling failure in the resource scheduling scheme for bare metal instances in the prior art.
[0146] Among them, determining the resource situation of bare metal node resources based on the reference instance includes: determining the number of nodes in the bare metal node resources that can meet the resource requirements of the reference instance; determining the resource situation of the bare metal node resources based on the number of nodes and the total number of nodes corresponding to the bare metal node resources.
[0147] In an embodiment of the present application, the resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: when the resource situation indicates that the resources are sufficient, traversing the unallocated bare metal nodes in the bare metal node resources for one of the instance to be scheduled to obtain candidate bare metal nodes that can meet the resource requirements of the instance to be scheduled; obtaining the weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled; and determining the target bare metal node assigned to the instance to be scheduled from the candidate bare metal nodes according to the weight.
[0148] Among them, the resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: when the resource situation indicates insufficient resources, using a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
[0149] In an embodiment of the present application, the use of a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes: generating an initial allocation plan for bare metal node resources; using a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the initial allocation plan, the priority of the instance to be scheduled, a fitness determination method and a mutation method; wherein the fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation plan as the fitness; the mutation method includes: allocating a candidate bare metal node with the smallest weight value to the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node in the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
[0150] Furthermore, the resource scheduling device also includes: a first receiving module, used to receive a request for batch scheduling instances; and a second acquisition module, used to obtain allocatable bare metal nodes from a database according to the request to obtain the bare metal node resources.
[0151] In the embodiment of the present application, the resource scheduling device further includes: a third acquisition module, used to obtain resource information of the bare metal node; a storage update module, used to store the resource information in a database and update it regularly.
[0152] Among them, the implementation embodiments of the above-mentioned resource scheduling method are all applicable to the embodiments of the resource scheduling device and can achieve the same technical effects.
[0153] The present application also provides a resource scheduling device, such as Figure 7 As shown, it includes: a processor 71;
[0154] The processor 71 is used to obtain the maximum value of the resource demand of the target type corresponding to the instance to be scheduled;
[0155] constructing a reference instance according to the maximum value;
[0156] Determine, according to the reference instance, a resource status of a bare metal node resource; the bare metal node resource includes resources of the target type;
[0157] According to the resource situation, resource scheduling of the bare metal node resources is performed for the instance to be scheduled.
[0158] The resource scheduling device provided in the embodiment of the present application obtains the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructs a reference instance based on the maximum value; determines the resource situation of the bare metal node resources based on the reference instance; the bare metal node resources include the resources of the target type; and performs resource scheduling of the bare metal node resources for the instance to be scheduled based on the resource situation; and can support resource scheduling based on the resource situation, thereby avoiding the possibility of scheduling failure, and solving the problem of possible scheduling failure in the resource scheduling scheme for bare metal instances in the prior art.
[0159] Among them, determining the resource situation of bare metal node resources based on the reference instance includes: determining the number of nodes in the bare metal node resources that can meet the resource requirements of the reference instance; determining the resource situation of the bare metal node resources based on the number of nodes and the total number of nodes corresponding to the bare metal node resources.
[0160] In an embodiment of the present application, the resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: when the resource situation indicates that the resources are sufficient, traversing the unallocated bare metal nodes in the bare metal node resources for one of the instance to be scheduled to obtain candidate bare metal nodes that can meet the resource requirements of the instance to be scheduled; obtaining the weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled; and determining the target bare metal node assigned to the instance to be scheduled from the candidate bare metal nodes according to the weight.
[0161] Among them, the resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: when the resource situation indicates insufficient resources, using a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
[0162] In an embodiment of the present application, the use of a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes: generating an initial allocation plan for bare metal node resources; using a genetic algorithm to schedule the bare metal node resources for the instance to be scheduled according to the initial allocation plan, the priority of the instance to be scheduled, a fitness determination method and a mutation method; wherein the fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation plan as the fitness; the mutation method includes: allocating a candidate bare metal node with the smallest weight value to the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node in the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
[0163] Furthermore, the processor is also used to: receive a request for batch scheduling instances through a transceiver; and obtain allocatable bare metal nodes from a database according to the request to obtain the bare metal node resources.
[0164] In an embodiment of the present application, the processor is also used to: obtain resource information of the bare metal node; store the resource information in a database, and update it regularly.
[0165] Among them, the implementation embodiments of the above-mentioned resource scheduling method are all applicable to the embodiments of the resource scheduling device and can achieve the same technical effects.
[0166] An embodiment of the present application also provides a resource scheduling device, including a memory, a processor, and a program stored in the memory and executable on the processor; when the processor executes the program, the above-mentioned resource scheduling method is implemented.
[0167] Among them, the implementation embodiments of the above-mentioned resource scheduling method are all applicable to the embodiments of the resource scheduling device and can achieve the same technical effects.
[0168] The embodiment of the present application also provides a readable storage medium on which a program is stored, and when the program is executed by a processor, the steps in the above-mentioned resource scheduling method are implemented.
[0169] Among them, the implementation embodiments of the above-mentioned resource scheduling method are all applicable to the embodiments of the readable storage medium and can also achieve the same technical effect.
[0170] The embodiment of the present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the various processes of the method embodiment of the above-mentioned resource scheduling method and can achieve the same technical effect. To avoid repetition, they are not repeated here.
[0171] It should be noted that many functional components described in this specification are referred to as modules in order to more particularly emphasize the independence of their implementation methods.
[0172] In the embodiment of the present application, module can be implemented with software so that it can be executed by various types of processors. For example, an executable code module of an identification can include one or more physical or logical blocks of computer instructions, for example, it can be constructed as an object, process or function. Nevertheless, the executable code of the identified module does not need to be physically located together, but can include different instructions stored in different positions, and when these instructions are logically combined together, it constitutes a module and realizes the specified purpose of the module.
[0173] In fact, executable code module can be a single instruction or many instructions, and can even be distributed on a plurality of different code segments, distributed among different programs, and distributed across a plurality of memory devices. Similarly, operating data can be identified in the module, and can be implemented and organized in the data structure of any appropriate type according to any appropriate form. The operating data can be collected as a single data set, or can be distributed in different locations (including on different storage devices), and can only be present on a system or network as an electronic signal at least in part.
[0174] When a module can be implemented by software, considering the level of existing hardware technology, a person skilled in the art can build a corresponding hardware circuit to implement the corresponding function of the module that can be implemented by software without considering the cost. The hardware circuit includes a conventional very large scale integration (VLSI) circuit or gate array and existing semiconductors such as logic chips, transistors, or other discrete components. The module can also be implemented by a programmable hardware device, such as a field programmable gate array, a programmable array logic, a programmable logic device, etc.
[0175] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary personnel in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A resource scheduling method, characterized in that: include: Get the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructing a reference instance according to the maximum value; Determine, according to the reference instance, a resource status of a bare metal node resource; the bare metal node resource includes resources of the target type; According to the resource situation, resource scheduling of the bare metal node resources is performed for the instance to be scheduled.
2. The resource scheduling method according to claim 1, characterized in that: Determining the resource status of the bare metal node resources according to the reference instance includes: Determine the number of bare metal node resources that can meet the resource requirements of the reference instance; The resource status of the bare metal node resources is determined according to the number of nodes and the total number of nodes corresponding to the bare metal node resources.
3. The resource scheduling method according to claim 1, characterized in that: The performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: When the resource situation indicates that the resources are sufficient, traverse the unallocated bare metal nodes in the bare metal node resources for one of the instances to be scheduled to obtain a candidate bare metal node that can meet the resource requirements of the instance to be scheduled; Obtaining a weight of the candidate bare metal node according to the demand type corresponding to the instance to be scheduled; According to the weight, a target bare metal node allocated to the instance to be scheduled is determined from the candidate bare metal nodes.
4. The resource scheduling method according to claim 1, characterized in that: The performing resource scheduling of the bare metal node resources for the instance to be scheduled according to the resource situation includes: When the resource situation indicates that the resources are insufficient, a genetic algorithm is used to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled.
5. The resource scheduling method according to claim 4, characterized in that: The utilizing a genetic algorithm to perform resource scheduling of the bare metal node resources for the instance to be scheduled according to the priority of the instance to be scheduled includes: Generate an initial allocation plan for bare metal node resources; Using a genetic algorithm, according to the initial allocation scheme, the priority of the instance to be scheduled, the fitness determination method and the mutation method, resource scheduling of the bare metal node resources for the instance to be scheduled; The fitness determination method includes: taking the sum of the priorities of the instances to be scheduled in the allocation scheme as the fitness; The variation method includes: allocating a candidate bare metal node with the smallest weight value for the highest priority instance to be scheduled that has not been successfully allocated in the allocation plan; the weight value is determined according to the demand type corresponding to the instance to be scheduled, and the candidate bare metal node is a bare metal node among the bare metal node resources that can meet the resource requirements of the instance to be scheduled.
6. The resource scheduling method according to claim 1, characterized in that: Also includes: Receive requests for batch scheduling instances; According to the request, allocatable bare metal nodes are obtained from a database to obtain the bare metal node resources.
7. The resource scheduling method according to claim 1 or 6, characterized in that: Also includes: Get the resource information of the bare metal node; The resource information is stored in a database and updated regularly.
8. A resource scheduling device, characterized in that: include: A first acquisition module is used to acquire the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; A first construction module, configured to construct a reference instance according to the maximum value; A first determination module is used to determine the resource status of bare metal node resources according to the reference instance; the bare metal node resources include resources of the target type; The first scheduling module is used to schedule the bare metal node resources for the instance to be scheduled according to the resource situation.
9. A resource scheduling device, characterized in that: include: processor; The processor is used to obtain the maximum value of the resource demand of the target type corresponding to the instance to be scheduled; constructing a reference instance according to the maximum value; Determine, according to the reference instance, a resource status of a bare metal node resource; the bare metal node resource includes resources of the target type; According to the resource situation, resource scheduling of the bare metal node resources is performed for the instance to be scheduled.
10. A resource scheduling device, comprising a memory, a processor, and a program stored in the memory and executable on the processor; characterized in that: When the processor executes the program, the resource scheduling method according to any one of claims 1 to 7 is implemented.
11. A readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps in the resource scheduling method according to any one of claims 1 to 7 are implemented.
12. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the resource scheduling method according to any one of claims 1 to 7.