A method, apparatus, device, and storage medium for deducting resources from a physical machine.
By generating specification priority queues and resource adaptation scores, the resource fragmentation problem in multi-specification virtual machine inventory calculation in existing technologies is solved, and global optimal planning and efficient utilization of physical machine resources are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CAPITALONLINE DATA SERVICE CO LTD
- Filing Date
- 2026-04-29
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies cannot simultaneously process inventory calculations for virtual machines of various specifications, resulting in insufficient utilization of physical machine resources, waste of resources, and difficulty in obtaining globally optimal inventory calculation results.
By generating specification priority queues, matching relationship tables, and resource adaptation scores, the system achieves global planning of resource requirements for virtual machines of various specifications, optimizes the resource allocation process, and ensures an effective mapping relationship between virtual machines and physical machines.
It improves the utilization rate of physical machine resources, obtains the global optimal calculation result of cloud computing resource inventory, reduces resource waste, and achieves efficient matching of virtual machines of various specifications and maximizes resource utilization.
Smart Images

Figure CN122309034A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method, apparatus, device, and storage medium for deducting resources from a physical machine. Background Technology
[0002] The current cloud computing resource inventory calculation uses a one-to-many matching algorithm of "single virtual machine (VM) specification to multiple physical machines". The core of this algorithm is to simulate resource deduction to complete inventory accounting. The specific execution process is as follows: After the inventory calculation task is queued, the scheduling system first extracts key information such as machine type, required number of Central Processing Unit (CPU) cores, and memory size from the inventory calculation request. Based on this, it sets hard and soft constraints for scheduling. Then, it obtains the real-time resource remaining status of all devices in the physical machine cluster. Subsequently, based on the hard constraints, physical machines that do not meet the basic resource requirements are filtered out, retaining only compliant devices. Then, based on the soft constraints, the remaining physical machines are scored and ranked. Resources are deducted from the physical machines for the VM specification according to the ranking results, ultimately completing the inventory calculation for that specification. Here, hard constraints are the essential basic conditions for physical machines to meet the creation of virtual machines; these are non-negotiable, veto-limit indicators, and machines that are not met are directly filtered out. Soft constraints are optimization reference conditions for resource matching; they are not mandatory and are only used to score and rank physical machines that meet the hard constraints.
[0003] However, this algorithm can only process the inventory calculation of a single virtual machine specification at a time. It needs to iterate through all the virtual machine specifications to be created and complete the deduction calculation one by one. It cannot coordinate the resource requirements of multiple virtual machines at the same time for global planning. Therefore, it is difficult to obtain the globally optimal inventory calculation result, which can easily lead to insufficient utilization of physical machine resources, resulting in resource fragmentation and waste. Ultimately, the inventory distribution and resource allocation will not reach the optimal state.
[0004] Therefore, how to simultaneously process inventory calculations for virtual machines of various specifications to improve resource utilization efficiency is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] To address the aforementioned issues, this application provides a method, apparatus, device, and storage medium for deducting resources from physical machines. This method enables global planning of resource requirements for virtual machines of various specifications, improves the utilization rate of physical machine resources, and yields the globally optimal calculation result for cloud computing resource inventory.
[0006] The embodiments of this application disclose the following technical solutions: A method for deducting resources from a physical machine, the method comprising: Physical machines that meet the hard constraints are selected from the physical machine cluster as available physical machines; the hard constraints are used to define the minimum required resources and environment requirements that the physical machines can support the specifications of the virtual machines to be created. Based on the business level of each virtual machine specification to be created, a specification priority queue is generated in order of priority level, and a matching relationship table is created with an initial empty state; the matching relationship table is used to record the mapping relationship between the virtual machine specifications to be created and the physical machines. Calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created. Based on the resource compatibility score between the available physical machine and each virtual machine specification to be created, generate a specification matching queue for each available physical machine and a physical machine matching queue for each virtual machine specification to be created in order of score. The resource compatibility score is used to quantify the degree of compatibility between the available physical machine and the virtual machine specification to be created based on the resource compatibility between the virtual machine specification to be created and the available physical machine, as well as the fragmentation risk of the remaining resources of the physical machine after the specification is deployed. Based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, the matching and matching conflict handling between the virtual machine specification to be created and the available physical machines are performed to update the matching relationship table and obtain the effective mapping relationship between the specification and the physical machine. Repeat the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, and constructing the effective mapping relationship until the specification priority queue is empty, then stop and deduct resources from each physical machine based on the final matching relationship table; Repeat the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, constructing the effective mapping relationship, and deducting physical machine resources until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, then stop.
[0007] A resource deduction device for a physical machine, the device comprising: The physical machine acquisition unit is used to acquire physical machines that meet the hard constraints from the physical machine cluster as available physical machines; the hard constraints are used to define the minimum necessary resources and environment requirements that the physical machine can support the specifications of the virtual machine to be created. The first queue generation unit is used to generate a specification priority queue based on the business level of each virtual machine specification to be created, in order of priority of the levels. The relation table creation unit is used to create a matching relation table with an initial empty state; the matching relation table is used to record the mapping relationship between the virtual machine specifications to be created and the physical machines; The computing unit is used to calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created. The resource compatibility score is used to quantify the compatibility between available physical machines and virtual machine specifications to be created based on the resource compatibility between the virtual machine specification to be created and available physical machines, as well as the risk of fragmentation of the remaining resources of physical machines after the specification is deployed. The second queue generation unit is used to generate a specification matching queue for each available physical machine and a physical machine matching queue for each virtual machine specification to be created, based on the resource adaptation score between any available physical machine and each virtual machine specification to be created, according to the score size and in order. The first matching conflict handling unit is used to perform matching and matching conflict handling between the virtual machine specification to be created and the available physical machines based on the specification priority queue, each specification matching queue, each physical machine matching queue and each resource adaptation score, so as to update the matching relationship table to obtain the effective mapping relationship between the specification and the physical machine. The first-round resource deduction unit is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, and constructing the effective mapping relationship until the specification priority queue is empty, and then stop, and deduct resources from each physical machine based on the final matching relationship table; The cyclic matching and deduction unit is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, constructing the effective mapping relationship, and deducting physical machine resources, until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, at which point it stops.
[0008] A physical machine resource deduction device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the physical machine resource deduction method as described above.
[0009] A computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the physical machine resource deduction method as described above.
[0010] Compared with the prior art, this application has the following beneficial effects: This application provides a method, apparatus, device, and storage medium for deducting resources from physical machines. Specifically, when executing the resource deduction method for physical machines provided in this application embodiment, firstly, physical machines that meet hard constraints are selected from the physical machine cluster. These constraints define the minimum resource and environmental requirements required for the physical machines to support the virtual machine specification to be created. Next, according to the service level of the virtual machine specification to be created, a specification priority queue is generated in priority order, and an initially empty matching relationship table is created to record the mapping relationship between the virtual machine specification to be created and the physical machines. Subsequently, a resource adaptation score between each available physical machine and each virtual machine specification to be created is calculated, and a specification matching queue is generated for each available physical machine according to the score, while a physical machine matching queue is generated for each virtual machine specification to be created. The resource adaptation score quantifies the degree of adaptation between available physical machines and virtual machine specifications to be created, while also considering the fragmentation risk of remaining physical machine resources after specification deployment. Next, based on the specification priority queue, each specification matching queue, the physical machine matching queue, and the resource adaptation score, the specifications of the virtual machine to be created are matched with available physical machines, and any matching conflicts are handled. The matching relationship table is then updated to form a valid specification-physical machine mapping relationship. This process is repeated until the specification priority queue is empty. Finally, resources are deducted from each physical machine according to the final matching relationship table. Furthermore, this entire step is repeated until no available physical machine has remaining resources that can match any virtual machine specification to be created.
[0011] This application employs a multi-level matching system, utilizing specification matching queues, physical machine matching queues, and resource adaptation scores. It handles conflicts during the matching process, ensuring the rationality and efficiency of the effective mapping relationship between specifications and physical machines, thereby improving the overall optimization effect of resource allocation. Simultaneously, this application can process virtual machine inventory calculations for multiple specifications. By generating specification priority queues and processing them sequentially based on business levels, it ensures comprehensive planning for all virtual machine specifications to be created, rather than processing them one by one, thus avoiding resource fragmentation. Furthermore, a resource adaptation score mechanism is introduced. This mechanism quantifies the degree of adaptation between each virtual machine specification to be created and available physical machines, as well as the risk of fragmentation of remaining physical machine resources after specification deployment. This mechanism helps to more accurately match physical machines and virtual machine specifications, reducing resource waste. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings used in the description of the embodiment or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating a method for deducting resources from a physical machine, as provided in this application embodiment; Figure 2 A matching relationship table provided for embodiments of this application; Figure 3 A resource adaptation score illustration table provided for embodiments of this application; Figure 4 A flowchart illustrating a method for matching virtual machine specifications with physical machines and handling conflicts, provided in an embodiment of this application; Figure 5 A flowchart illustrating another method for matching virtual machine specifications with physical machines and handling conflicts, provided in this application embodiment; Figure 6 This is a schematic diagram of a physical machine resource deduction device provided in an embodiment of this application. Detailed Implementation
[0014] To facilitate understanding of the technical solutions provided in the embodiments of this application, the background technology involved in the embodiments of this application will be described below.
[0015] The current cloud computing resource inventory calculation adopts a one-to-many matching algorithm for a single virtual machine specification to multiple physical machines. It uses simulated resource deduction as the core to complete the inventory calculation. The overall process is as follows: After the inventory calculation task enters the queue, the scheduling system first extracts key parameters such as machine type, required number of CPU cores, and memory size from the corresponding request. Based on this, it sets both hard and soft constraints for scheduling. Then, it obtains the real-time remaining resource status of all devices in the physical machine cluster. After that, the first round of screening is completed through hard constraints, directly eliminating physical machines whose remaining CPU cores, memory, disk, and other basic resources do not meet the minimum requirements for virtual machine creation, and only retaining compliant devices. Then, based on soft constraints such as physical machine resource utilization, network latency, and the degree of fragmentation of remaining resources, the compliant physical machines are scored and ranked. Finally, according to the ranking result, the physical machine resources are deducted sequentially for virtual machines of that specification to complete the inventory calculation for that specification. Hard constraints are the essential conditions that physical machines must meet to create virtual machines. These are non-negotiable, veto-limit indicators, and machines that do not meet them will be directly eliminated. Examples include: the number of remaining CPU cores on the physical machine must be greater than or equal to the number of cores required by the virtual machine; the remaining memory capacity must be greater than or equal to the memory required by the virtual machine; and the remaining disk space must be greater than or equal to the disk space required by the virtual machine. Soft constraints are optimization reference conditions for resource matching. They are not mandatory and are only used to score and rank physical machines that meet the hard constraints. Examples include: physical machine resource utilization (to avoid excessive resource concentration); network latency between the physical machine's data center and the business (prioritizing low-latency data centers); and the degree of fragmentation of the physical machine's remaining resources (prioritizing physical machines with low fragmentation).
[0016] For example, the specifications of virtual machines to be created: for example, there are two specifications to be created: large-scale VM1 (8-core CPU + 64GB memory, large cores) and small-scale VM2 (2-core CPU + 8GB memory, small cores); host / physical machine: the physical server of cloud computing, for example, there are 2 physical machines, physical machine H1 (remaining 10-core CPU + 80GB memory) and physical machine H2 (remaining 6-core CPU + 40GB memory); one-to-many matching: only one virtual machine specification is counted at a time, and matching and deducting resources for all physical machines that meet the conditions; resource deduction: after determining that a certain physical machine can create a virtual machine of a certain specification, the resources of that virtual machine are subtracted from the remaining resources of the physical machine to obtain the remaining resources after deduction (i.e., inventory).
[0017] The limitations of this algorithm can be intuitively demonstrated through a specific scenario: Suppose we want to create two types of virtual machines: a large-scale VM1 (8-core CPU + 64GB RAM) and a small-scale VM2 (2-core CPU + 8GB RAM). We have existing physical machines H1 (remaining 10-core CPU + 80GB RAM) and H2 (remaining 6-core CPU + 40GB RAM). This algorithm can only calculate the inventory for one type at a time, requiring cyclic deduction, and the calculation order directly determines the inventory result and resource utilization. If VM2 is calculated first and then VM1, after deduction, H1 has 8 cores + 72GB and H2 has 4 cores + 32GB remaining, allowing only 2 VM2 + 1 VM1 machines to be created. H2 will generate unusable resource fragmentation. If VM1 is calculated first and then VM2, after deduction, H1 has 2 cores + 16GB and H2 has 6 cores + 40GB remaining, allowing 1 VM1 + 4 VM2 machines to be created, achieving full utilization of physical machine resources.
[0018] It is evident that this one-to-many matching algorithm cannot simultaneously coordinate the resource requirements of multiple virtual machines of different specifications for global planning. It can only iterate through all specifications to be created and perform deduction calculations one by one. Not only is it difficult to obtain the globally optimal inventory calculation result, but it is also very easy to cause insufficient utilization of physical machine resources due to the randomness of the calculation order, resulting in a large amount of resource fragmentation and waste. Ultimately, the overall inventory distribution and resource allocation cannot reach the optimal state.
[0019] To address this issue, this application provides a method, apparatus, device, and storage medium for deducting resources from physical machines. First, physical machines meeting hard constraints are selected from the physical machine cluster as available physical machines. Next, based on the service level of each virtual machine specification to be created, a specification priority queue is generated in order of priority, and an initially empty matching table is created to record the mapping relationship between the virtual machine specifications and physical machines. Then, the resource compatibility score between any available physical machine and each virtual machine specification to be created is calculated. Based on each resource compatibility score, a specification matching queue is generated for each available physical machine in order of score, and a physical machine matching queue is generated for each virtual machine specification to be created. Then, based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource compatibility score, matching and matching conflict handling are performed between the virtual machine specifications to be created and available physical machines to update the matching table and obtain the effective mapping relationship between specifications and physical machines. All the above steps are repeated until the specification priority queue is empty, at which point resource deduction is performed on each physical machine based on the final matching table. The entire process is repeated until no available physical machine resources can match any virtual machine specification to be created. This application enables global planning of resource requirements for virtual machines of various specifications, improves physical machine resource utilization, and yields globally optimal calculation results for cloud computing resource inventory.
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0021] See Figure 1 The figure is a flowchart of a method for deducting resources from a physical machine according to an embodiment of this application. Figure 1 As shown, the resource deduction method for this physical machine may include steps S101-S106: S101: Obtain physical machines that meet the hard constraints from the physical machine cluster as available physical machines.
[0022] To quickly select physical machines from the physical machine cluster that have the basic capacity to support the specifications of the virtual machines to be created, and to eliminate devices that cannot meet the minimum resource and environment requirements for virtual machine creation, thereby reducing the amount of unnecessary work in subsequent matching calculations, we can first select physical machines from the physical machine cluster that meet the hard constraints and identify them as usable physical machines.
[0023] Hard constraints define the minimum necessary resources and environment requirements for a physical machine to support the specifications of the virtual machine to be created. These are non-negotiable, veto-limit screening criteria; if a physical machine fails to meet any hard constraint, it will be directly excluded from the subsequent matching process. To improve screening efficiency in large-scale physical machine clusters, bitwise operations can be used for rapid filtering, eliminating the need for complex numerical calculations on a machine-by-machine basis. Physical machines that do not meet the hard constraints can be directly marked as "unavailable," significantly reducing screening time and adapting to the scheduling needs of massive physical machines in cloud computing scenarios.
[0024] For example, suppose the virtual machine to be created has hard constraints including ≥16GB of memory and ≥4 CPU cores. The physical machine cluster has three physical machines: H1, H2, and H3. H1 has 20GB of remaining memory and 6 CPU cores, H2 has 12GB of remaining memory and 8 CPU cores, and H3 has 18GB of remaining memory and 3 CPU cores. When filtering according to the hard constraints, bitwise operations are used to quickly compare the resource data of each physical machine: H2's remaining memory does not meet the minimum requirement of 16GB, and H3's remaining CPU cores do not meet the basic standard of 4 cores; both are directly marked as "unavailable." Only H1 meets both the memory and CPU hard constraints and is determined to be a usable physical machine, entering the subsequent resource matching process.
[0025] S102: Based on the business level of each virtual machine specification to be created, generate a specification priority queue in order of priority of the level, and create a matching relationship table with an initial empty state.
[0026] To ensure that virtual machine resource matching is conducted in an orderly manner according to business importance, guarantee the resource deployment priority of core businesses, and establish a clear basis for subsequent matching of specifications with physical machines, conflict resolution, and resource deduction, all virtual machine specifications to be created can be sorted from high to low according to their business level, strictly following the principle of core businesses first and then testing businesses, to generate a specification priority queue. The subsequent resource matching process will process each specification in the order of this queue, ensuring that core business specifications receive physical machine resources first.
[0027] Simultaneously, a matching table is created with an initial empty state (the structure of the matching table can be similar to...). Figure 2 This table, in the form of a dedicated data carrier, is used to record the one-to-one mapping relationship between the specifications of the virtual machine to be created and the successfully matched physical machine throughout the entire process, making the associated information of the entire resource matching process traceable and verifiable.
[0028] For example, suppose there are three types of virtual machine specifications to be created. The core business type includes VM1 (8-core CPU + 64GB memory) for the transaction system and VM2 (4-core CPU + 32GB memory) for the user center. The test business type is VM3 (2-core CPU + 8GB memory) for new feature testing. According to the business level rule of "core first, then test", the generated specification priority queue is VM1→VM2→VM3. Subsequently, physical machine resources will be matched for VM1 and VM2 first.
[0029] It should be noted that the service level of a virtual machine specification is a priority category assigned to different virtual machine specifications based on attributes such as the importance, service level, stability requirements, and real-time needs of the services hosted by the virtual machine. This category is used to determine the processing order during resource scheduling, matching, and deduction, ensuring that high-value, high-priority services receive physical machine resources first. The more important and core the service, the higher the level; the less important and non-critical the service, the lower the level. For example, the service level of core services is higher than that of testing services.
[0030] S103: Calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created, and based on the resource compatibility score between the available physical machine and each virtual machine specification to be created, generate a specification matching queue for each available physical machine in order of score size, and generate a physical machine matching queue for each virtual machine specification to be created.
[0031] To accurately quantify the compatibility between each available physical machine and each virtual machine specification to be created, and to provide a scientific ranking basis for subsequent bidirectional matching of specifications and physical machines, a resource compatibility score can be calculated for each combination of any available physical machine and each virtual machine specification to be created. This score is not a single-dimensional evaluation, but rather comprehensively considers two core factors: the resource compatibility between the virtual machine specification to be created and the available physical machine, and the risk of fragmentation of the remaining resources of the physical machine after the specification is deployed. This achieves a quantitative determination of the compatibility between physical machines and virtual machine specifications. After completing the full score calculation, a specification matching queue will be generated separately for each available physical machine according to the score from high to low, clarifying the priority of each virtual machine specification adapted to that physical machine. At the same time, a physical machine matching queue will be generated for each virtual machine specification to be created, determining the priority of each physical machine adapted to that specification. This provides a clear quantitative ranking reference for subsequent matching operations, avoiding blind matching.
[0032] See Figure 3 , Figure 3 This application provides a resource adaptation score illustration table. For example, given available physical machines P1, P2, and P3, and virtual machine specifications VM1, VM2, and VM3 to be created, the resource adaptation scores between each physical machine and virtual machine specification are as follows: Figure 3As shown: The resource compatibility scores of physical machine P1 with VM1, VM2, and VM3 are 60, 90, and 70, respectively. The resource compatibility scores of physical machine P2 with VM1, VM2, and VM3 are 55, 41, and 99, respectively. The resource compatibility scores of physical machine P3 with VM1, VM2, and VM3 are 64, 85, and 48, respectively.
[0033] Based on this, a specification matching queue and a physical machine matching queue are generated: The specification matching queue for physical machine P1 is: VM2 (90 points) → VM3 (70 points) → VM1 (60 points). The specification matching queue for physical machine P2 is: VM3 (99 points) → VM1 (55 points) → VM2 (41 points). The specification matching queue for physical machine P3 is: VM2 (85 points) → VM1 (64 points) → VM3 (48 points). The physical machine matching queue for virtual machine specification VM1 is: P3 (64 points) → P1 (60 points) → P2 (55 points). The physical machine matching queue for VM2 virtual machine specification is: P1 (90 points) → P3 (85 points) → P2 (41 points). The physical machine matching queue for VM3 virtual machine specification is: P2 (99 points) → P1 (70 points) → P3 (48 points).
[0034] S104: Based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, perform matching and matching conflict processing between the virtual machine specification to be created and the available physical machines, so as to update the matching relationship table to obtain the effective mapping relationship between specifications and physical machines.
[0035] To ensure that the matching results between the specifications of virtual machines to be created and available physical machines both meet business priority requirements and ensure the scientific nature of resource adaptation, while efficiently resolving resource conflicts that arise during the matching process, and ultimately forming a specification-physical machine correspondence that can be directly used for subsequent resource deduction, a comprehensive set of criteria is used. This includes a specification priority queue, the specification matching queues of each available physical machine, the physical machine matching queues of each virtual machine specification to be created, and the full resource adaptation score. For conflicts where the same physical machine is selected by multiple virtual machine specifications simultaneously, a multi-dimensional comprehensive analysis and conflict handling process is conducted based on the above four criteria. This ensures that the matching results after conflict resolution both adhere to the scheduling logic prioritizing core business needs and maximize compliance with quantitative standards for resource adaptation. Throughout the matching and conflict handling process, each determined specification-physical machine correspondence is updated in real-time to the matching relationship table, continuously refining the mapping information within the table. This ultimately yields an accurate and conflict-free effective mapping relationship between specifications and physical machines, providing unique and reliable core data support for subsequent physical machine resource deduction.
[0036] S105: Repeat steps S102-S104 until the specification priority queue is empty, then stop and deduct resources from each physical machine based on the final matching table.
[0037] To ensure that all virtual machine specifications to be created can be accurately matched with physical machines based on business priority and resource adaptability, and to achieve standardized deduction of physical machine resources based on the matching results, the following steps can be executed repeatedly: S102 generates a specification priority queue and matching relationship table; S103 calculates resource adaptability scores and generates various matching queues; and S104 performs matching and conflict handling. This process continues until all virtual machine specifications in the specification priority queue have completed the matching operation and the queue is empty, at which point the loop stops. After this loop ends, based on the effective mapping relationship between specifications and physical machines recorded in the finally updated matching relationship table, the corresponding resource deduction operation can be performed on each physical machine. That is, the resource amount required by the matched virtual machine specification can be deducted from the remaining resources of the physical machine. This completes the resource calculation corresponding to this round of matching, laying an accurate resource data foundation for the next round of resource matching and deduction.
[0038] For example, suppose a certain round of specification priority queues is: core business VM1 → core business VM2 → test business VM3. After the steps are executed cyclically to complete the matching of all specifications, the final mapping relationship recorded in the specification priority queue matching relationship table is VM1-H1, VM2-H2, VM3-H1. VM1 requires 8 CPU cores + 64GB memory, VM2 requires 4 CPU cores + 32GB memory, and VM3 requires 2 CPU cores + 8GB memory. Physical machines H1 initially have 10 CPU cores + 80GB memory remaining, and H2 initially has 6 CPU cores + 40GB memory remaining. At this point, resource deduction is performed based on this matching relationship table: H1 deducts the resources of VM1 + VM3, leaving 0 CPU cores + 8GB memory; H2 deducts the resources of VM2, leaving 2 CPU cores + 8GB memory, completing this round of resource deduction operation, and synchronously updating the real-time remaining resource data of H1 and H2.
[0039] S106: Repeat steps S102-S105 until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, then stop.
[0040] To fully exploit the resource utilization potential of the physical machine cluster and maximize the matching and utilization of the remaining resources of each physical machine until there are no suitable virtual machine specifications to be created, the process can continuously loop through the following steps: S102 generating a specification priority queue and matching relationship table, S103 calculating resource adaptation scores and generating various matching queues, S104 performing matching and conflict handling, and S105 completing resource deduction. Each loop will re-perform the matching and deduction operations based on the real-time remaining resources of the physical machines after the previous round of deduction, until it is detected that the remaining resources of any available physical machine in the cluster cannot meet the hard constraints of any virtual machine specification to be created and cannot complete any specification matching. At this point, the entire physical machine resource deduction process will be terminated, thereby achieving refined and maximized utilization of physical machine resources and fundamentally reducing resource fragmentation waste.
[0041] For example, the initial physical machine cluster has H1 (10 cores + 80GB remaining) and H2 (6 cores + 40GB remaining), and the virtual machines to be created are core business VM1 (8 cores + 64GB) and test business VM2 (2 cores + 8GB).
[0042] First round of loop: S101-S105 are executed to complete the matching. The mapping relationship is VM1-H1, VM2-H2. After deduction, H1 has 2 cores + 16G and H2 has 4 cores + 32G. There are still resources that can be matched. Second round of loop: S102-S105 are re-executed based on the remaining resources. At this time, there is no VM1 to match, only VM2 can be matched. The mapping relationship is VM2-H1, VM2-H2. After deduction, H1 has 0 cores + 8G remaining and H2 has 2 cores + 24G remaining. There are still a small amount of remaining resources, but they have not reached the matching threshold. The third loop: S102-S105 are executed again. It is detected that the remaining 0 CPU cores of H1 cannot meet the 2-core hard constraint of VM2. Although the remaining 2 CPU cores of H2 meet the constraint, combined with hard constraints such as memory and resource adaptability, there are no virtual machine specifications to be created that can be matched. It is determined that the remaining resources of any available physical machine cannot match any specification, and the entire resource deduction process is terminated, thus maximizing the utilization of physical machine resources.
[0043] Based on the content of S101-S106, we know that firstly, physical machines in the physical machine cluster that meet the hard constraints are selected as available physical machines. Then, according to the service level of each virtual machine specification to be created, a specification priority queue is generated in order of priority. Simultaneously, an initially empty matching table is created to record the mapping relationship between the virtual machine specifications to be created and the physical machines. Next, the resource adaptation score between any available physical machine and each virtual machine specification to be created is calculated. Based on this score, a specification matching queue is generated for each available physical machine, and a physical machine matching queue is generated for each virtual machine specification to be created, ranked by score. Then, combining the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, matching of the virtual machine specifications to be created and available physical machines is performed, and matching conflicts are handled. The matching table is updated to obtain an effective mapping relationship between specifications and physical machines. Afterwards, the steps of generating the specification priority queue, creating the matching table, calculating the resource adaptation score, and constructing the effective mapping relationship are executed cyclically until the specification priority queue is empty. Finally, resources are deducted from each physical machine based on the final matching table. Finally, the above steps are repeated until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, at which point the entire resource deduction process terminates. This application can achieve global planning of resource requirements for multi-specification virtual machines, improve physical machine resource utilization, and obtain globally optimal calculation results for cloud computing resource inventory.
[0044] See Figure 4 , Figure 4 This application provides a flowchart of a method for matching virtual machine specifications with physical machines and handling conflicts. Accordingly, step S104 performs matching and conflict handling between the virtual machine specification to be created and available physical machines based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, so as to update the matching relationship table to obtain an effective mapping relationship between specifications and physical machines. Specifically, this can be implemented through steps S401-S405. S401: Traverse the specification priority queue, select the highest priority virtual machine specification to be created as the target specification, and proceed to step S402 after the target specification is selected.
[0045] Traversing the specification priority queue and selecting the highest-priority virtual machine specification to be created as the target specification is a crucial prerequisite for ensuring that core businesses receive priority resource allocation and is also the foundation for the orderly conduct of subsequent matching processes. It is necessary to strictly follow the pre-defined business priority order (e.g., core businesses first, then ordinary businesses, and finally testing businesses), traversing all virtual machine specifications to be created in the specification priority queue one by one, and prioritizing the specification at the top of the queue with the highest business priority as the target specification. This ensures that the resource needs of high-priority businesses are processed first, preventing low-priority specifications from preempting resource allocation opportunities for core businesses, thus aligning with a business value-driven resource scheduling logic.
[0046] For example, the specification priority queue is as follows: Core business VM1 (8-core CPU + 64GB memory) → Core business VM2 (4-core CPU + 32GB memory) → General business VM3 (2-core CPU + 16GB memory) → Test business VM4 (1-core CPU + 8GB memory)
[0047] During step S401, all virtual machine specifications to be created are traversed sequentially according to the queue order, and the specification at the head of the queue is identified first as the target specification for this round of matching: First traversal: The first element of the specification priority queue is read as VM1 (the transaction system, the highest priority of core business). Therefore, VM1 is determined as the target specification for the first stage, and physical machine matching operations are carried out for it first to ensure that the resource needs of core businesses such as the transaction system are processed first. After VM1 completes the matching and is removed from the specification priority queue, step S401 is executed again: the system traverses the updated queue (VM2→VM3→VM4) and determines VM2 (user center, core business secondary priority) at the top of the queue as the new target specification. This process continues until all specifications are selected as target specifications and matched in sequence. Throughout the process, the priority rule of "core business before ordinary business, and ordinary business before test business" is followed to ensure that the resource allocation for high-value business is not squeezed out by low-priority business.
[0048] This method of traversing and selecting target specifications fundamentally ensures that virtual machine specifications with higher business value have the first opportunity to be matched with physical machine resources, avoiding resource shortages or deployment delays in core businesses due to disordered scheduling.
[0049] S402: Select the physical machine with the highest score in the physical machine matching queue of the target specification as the candidate physical machine of the target specification. After the selection of the candidate physical machine is completed, proceed to step S403.
[0050] The core of step S402 is to select the physical machine candidate with the best adaptability for the target specification. The decision is based on the pre-generated resource adaptation score. This score comprehensively considers the resource adaptability between the virtual machine specification to be created and the available physical machines, as well as the fragmentation risk of the remaining physical machine resources after the specification is deployed. This realizes the transformation of physical machine selection from "experience judgment" to "data-driven", ensuring that the matching result not only meets the resource utilization efficiency requirements, but also minimizes the generation of subsequent resource fragmentation.
[0051] Specifically, the system will first locate the physical machine matching queue corresponding to the target specification (this queue has been sorted from high to low according to the resource adaptation score), and directly select the first physical machine in the queue with the highest score as the candidate physical machine. This physical machine is the one with the highest adaptation to the target specification and the lowest fragmentation risk among all available physical machines. It can meet the resource requirements of the target specification to the greatest extent, while ensuring the rational use of physical machine resources.
[0052] For example, suppose the core business VM1 (8-core CPU + 64GB memory, transaction system) has been identified as the target specification, and the pre-generated VM1 physical machine matching queue (sorted from highest to lowest resource adaptation score) is as follows: Physical machine H1 (score 95) → Physical machine H3 (score 82) → Physical machine H5 (score 70) → Physical machine H2 (score 45). At this time, the physical machine with the highest score in the location queue is H1 (95 points), and H1 is directly identified as the candidate physical machine for the target specification VM1, as the primary choice for this round of matching.
[0053] S403: Query whether there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table. If yes, proceed to step S405; otherwise, proceed to step S404.
[0054] Step S403 is a crucial step in identifying matching conflicts. Its core task is to query the matching relationship table to determine whether the currently selected candidate physical machine has already been occupied by another virtual machine specification to be created, providing a clear basis for subsequent conflict-free matching or conflict handling. The system will search all recorded mapping relationships in the matching relationship table to check if there is a record with the candidate physical machine as the associated object: if a relevant mapping record exists, it means that the candidate physical machine has already been occupied by another virtual machine specification to be created, which will result in a resource matching conflict, and the process needs to proceed to step S405 for conflict handling; if no relevant mapping record exists, it means that the candidate physical machine is currently in an idle and available state, and can be directly used for matching the target specification without conflict handling, and the process proceeds to step S404 to complete conflict-free matching.
[0055] S404: Establish a mapping relationship between the target specification and the candidate physical machine, record the mapping relationship in the matching relationship table, and delete the target specification from the specification priority queue. After completing this conflict-free matching, return to step S401 to continue processing the remaining specifications until the specification priority queue is empty.
[0056] Step S404 corresponds to the matching operation in a conflict-free scenario. When there is no mapping record of candidate physical machines in the matching relationship table, the system can directly establish an effective mapping relationship between the target specification and the candidate physical machines to ensure that the target specification can quickly obtain the appropriate physical machine resources, and at the same time complete the synchronous update of the matching relationship table and the specification priority queue.
[0057] Specifically, the system accurately writes the correspondence between "target specification - candidate physical machine" into the matching relationship table, forming a traceable and verifiable matching ledger, providing accurate data support for subsequent physical machine resource deduction. Simultaneously, it removes the matched target specifications from the specification priority queue, advancing the queue's processing progress and ensuring that each virtual machine specification to be created is matched one by one, avoiding duplicate processing or omissions. After completing the above operations, the system returns to step S401, re-traverses the updated specification priority queue, selects the new highest priority specification as the target specification, and continues the matching process until all specifications in the specification priority queue are matched, achieving efficient resource scheduling in conflict-free scenarios.
[0058] S405: Determine the mapping relationship in S403 as a pending relationship, and combine the pending relationship to perform matching conflict processing on the target specification, the matched specification and the candidate physical machine. After the conflict processing is completed, return to step S401 to continue processing the remaining specifications until the specification priority queue is empty.
[0059] The core of step S405 is to handle resource matching conflict scenarios. When a candidate physical machine has established a mapping relationship with other specifications (i.e., matched specifications), it is necessary to resolve the conflict through multi-dimensional analysis to ensure that the matching result not only meets the business priority requirements, but also achieves the optimal adaptation of physical machine resources.
[0060] Specifically, the system first marks the existing mapping relationships between candidate physical machines and matched specifications as pending relationships to avoid decision-making errors caused by direct deletion or retention. Subsequently, it combines the specification priority queue (to determine the business priority of the target specification and the matched specification), various matching queues (to determine the adaptation order of the two with the candidate physical machines), and resource adaptation score (to quantify the degree of adaptation between the two and the candidate physical machines) to conduct a comprehensive evaluation. Finally, it retains the better mapping relationship. After obtaining the better mapping relationship (i.e., completing the conflict resolution), it returns to step S401 to continue processing the remaining specifications until the specification priority queue is empty.
[0061] Through steps S401-S405, this step-by-step matching and conflict resolution method based on specification priority and resource adaptation score not only ensures the priority of resource allocation for core businesses, but also achieves efficient adaptation of physical machine resources through quantitative evaluation. At the same time, it efficiently resolves resource conflicts in the matching process, providing an accurate and reliable mapping basis for subsequent physical machine resource deduction, and significantly improving the rationality and efficiency of cloud computing resource scheduling.
[0062] See Figure 5 , Figure 5 This is a flowchart illustrating another method for matching and resolving conflicts between virtual machine specifications and physical machines provided in this application embodiment. Accordingly, in step S405, the target specification, the matched specification, and the candidate physical machine are matched and conflicted based on the pending relationship. This can be specifically implemented through steps S501-S505: S501: In the specification matching queue of the candidate physical machine, query whether the priority of the target specification is lower than the priority of the matched specification. If yes, proceed to step S502; otherwise, proceed to step S503.
[0063] In order to quickly determine the resource allocation tendency of candidate physical machines based on business priority in the case of matching conflict, and to avoid core business resources being squeezed out by low-priority specifications, step S501 will query in the specification matching queue of candidate physical machines whether the priority of the target specification is lower than the priority of the already matched specification.
[0064] Specifically, the candidate physical machine specification matching queue is already sorted from high to low according to resource adaptation scores, and also implicitly constrains business priority; specifications with higher business priority will receive a higher adaptation order in the queue. By comparing the positions of the target specification and the matched specifications in this queue, the business priority of the two can be intuitively determined: If the target specification is located further back in the queue, it means that its priority is lower than that of the matched specification. Therefore, the resource usage of the matched specification should be guaranteed first, and the process proceeds to step S502. If the target specification is positioned higher in the queue, it indicates that its priority is higher than that of the matched specifications. Further refined judgment needs to be made based on the resource adaptation score, and then proceed to step S503.
[0065] For example, assuming the candidate physical machine is H1, its specification matching queue (sorted by resource adaptation score + business priority) is: core business VM2 (85 points) → core business VM1 (90 points) → test business VM3 (70 points).
[0066] Scenario 2: Matched specification: VM2 (core business, 1st in the queue); Target specification: VM3 (test business, 3rd in the queue).
[0067] The query shows that VM3 is in a lower position than VM2 in the queue. Therefore, the priority of the target specification VM3 is lower than that of the already matched specification VM2. It is necessary to re-match VM3 with a suboptimal physical machine to ensure that the core business resources of VM2 are not preempted.
[0068] Scenario 2: Matched specification: VM3 (test service, 3rd in the queue); Target specification: VM1 (core service, 2nd in the queue)
[0069] The query shows that VM1 is in the queue before VM3. Therefore, the target specification VM1 is determined to have a higher priority than the matched specification VM3. The next step is to compare the resource adaptation scores to determine whether to replace the mapping relationship.
[0070] S502: Query the physical machine with a score lower than the candidate physical machine in the physical machine matching queue of the target specification, replace the candidate physical machine as the new candidate physical machine, and use the new candidate physical machine to replace the candidate physical machine to re-execute step S403 and subsequent steps.
[0071] In order to strictly adhere to the resource scheduling principle of "core business first", in the case of matching conflict, priority should be given to ensuring the resource occupation of the already matched high-priority specifications, while avoiding the target specifications from being unable to be matched due to conflict. This ensures that all virtual machine specifications to be created can obtain reasonable resource adaptation opportunities. When it is determined that the priority of the target specification is lower than the priority of the matched specifications, the processing method of "avoiding high priority and reselecting the second-best physical machine" should be adopted.
[0072] Specifically, in the physical machine matching queue for the target specification, the physical machine with the lowest score after the current candidate physical machine is queried, and the original candidate physical machine is replaced with the new candidate physical machine. Then, using this new candidate physical machine, the operation of "querying whether there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created" is re-executed, as well as all related steps after this query operation, until a conflict-free physical machine is matched for the target specification, or all queries and matching attempts for suboptimal physical machines are completed.
[0073] This processing logic adheres to the core constraint of business priority, preventing low-priority target specifications from preempting resources already matched by high-priority specifications, while also providing subsequent adaptation opportunities for low-priority target specifications. This avoids target specification matching failure due to a single conflict, thus balancing the integrity of business priority and resource scheduling. At the same time, it continues the "data-driven" adaptation principle, ensuring that the newly selected candidate physical machine is still the optimal choice that can be matched with the target specification at present, maximizing resource adaptation efficiency.
[0074] For example, assume the following basic information: Candidate physical machine H1 (original candidate physical machine), in its specification matching queue, the matched specification VM2 (core business, high priority) is in a higher position than the target specification VM3 (test business, low priority), and VM3 is determined to have a lower priority than VM2; the physical machine matching queue of the target specification VM3 (sorted from high to low according to resource adaptation score) is: H1 (70 points) → H3 (65 points) → H5 (60 points); in the matching relationship table, H1 has established a mapping relationship with VM2 (that is, the original candidate physical machine H1 has a conflict).
[0075] The specific process for performing this step is as follows: Since VM3 has a lower priority than the already matched VM2, it cannot preempt resources from H1. Therefore, in the VM3 physical machine matching queue, the physical machine with a score lower than the original candidate physical machine H1 (70 points) is queried, that is, H3 (65 points), which is immediately following H1 in the queue. H3 is then selected as the new candidate physical machine. Then, using the new candidate physical machine H3, the step of "querying whether there is a mapping relationship between H3 and other virtual machine specifications to be created" is executed again: if the query finds that H3 has not established a mapping relationship with any specification (no conflict), the subsequent steps are taken to establish a mapping relationship between VM3 and H3, completing the matching of VM3; if the query finds that H3 has established a mapping relationship with other specifications (there is still a conflict), then in the VM3 physical machine matching queue, H5 (60 points), which has a score lower than H3, is selected as the new candidate physical machine, and the above query and subsequent steps are repeated until a conflict-free physical machine is matched, or all candidate physical machines of VM3 are traversed.
[0076] For example, if the priority of the target specification VM4 (test service) is lower than that of the matched specification VM1 (core service), and the original candidate physical machine H2 has been occupied by VM1, the physical machine matching queue of VM4 is H2 (80 points) → H4 (75 points) → H6 (70 points). Then H4 is selected as the new candidate physical machine, and H4 is re-queried to see if there is a conflict. This process is repeated to ensure that VM4 can complete resource matching as much as possible without interfering with the core service.
[0077] S503: Query whether the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine. If yes, proceed to step S504; otherwise, proceed to step S505.
[0078] To achieve both the "core business priority" scheduling principle and the resource allocation rights of high-priority target specifications in matching conflict scenarios, while also considering the adaptation efficiency of physical machine resources and avoiding high-priority specifications occupying poorly adaptable physical machines and causing resource waste, when the priority of the target specification is determined to be higher than that of the matched specification, it is necessary to further query whether the resource adaptation score between the target specification and the candidate physical machine is higher than the adaptation score between the matched specification and the candidate physical machine. If the score is higher, it means that the high-priority specification is more compatible with the physical machine, and proceed to step S504; If the score is lower, it means that the matched specifications are more compatible with the physical machine, and proceed to step S505.
[0079] S504: Replace the matched specification in the pending relationship with the target specification, and add the matched specification back to the specification priority queue. After the replacement is completed, return to step S401 to continue processing the remaining specifications until the specification priority queue is empty.
[0080] In order to follow the core principle of "prioritizing high-priority business and optimizing resource utilization", when the target specification (high priority) and the matched specification (low priority) compete for the same physical machine resource, if the resource compatibility score between the target specification and the candidate physical machine is higher than the compatibility score between the matched specification and the physical machine, it means that allocating the physical machine to the high-priority target specification can make full use of the resource value. Therefore, a mapping relationship replacement operation is performed: the pending relationship between the matched specification and the candidate physical machine is removed, a new mapping relationship between the target specification and the candidate physical machine is established, and the replaced matched specification is added back to the specification priority queue to ensure that it can continue to match other physical machines.
[0081] S505: Perform step S502 and subsequent steps.
[0082] In order to ensure that high-priority services are scheduled first, while also taking into account the optimal adaptation and low fragmentation of physical machine resources, and to avoid resource waste caused by simply pursuing priority, when the target specification has a higher priority but a lower adaptation score, it means that the current candidate physical machine is more suitable for the matched specification. Therefore, the original mapping relationship is not replaced, and step S502 is directly executed: a second-best physical machine is selected for the target specification, and then the process returns to the conflict judgment stage to continue matching. This ensures both service priority and global resource optimization.
[0083] Through steps S501-S505, the matching conflict between business priority and resource adaptation score is resolved: it strictly follows the scheduling logic of "core business priority" to ensure the resource allocation rights of high-value business, and through quantitative comparison of resource adaptation scores, it ensures that physical machine resources are always tilted towards the specifications with better adaptability, avoiding resource waste and fragmentation risks.
[0084] In one possible implementation, to quantify the resource compatibility between the specifications of the virtual machine to be created and the available physical machines, while avoiding problems such as resource redundancy and waste, and fragmentation of remaining resources, this embodiment sets a standardized resource compatibility score calculation formula. Through multi-dimensional quantitative evaluation, a scientific decision-making process for physical machine selection is achieved. The specific calculation formula is as follows: Resource matching score = Σ(resource matching degree × weight - resource redundancy penalty score - fragmentation penalty score); Resource matching degree is a core indicator that measures the degree to which the remaining resources of the physical machine match the resource requirements of the virtual machine specification. The calculation method is as follows: Resource matching degree = (remaining physical machine resources / required virtual machine resources) × 100%. The remaining physical machine resources include the remaining number of cores and remaining capacity of the physical machine. The required virtual machine resources include the required number of cores and required capacity. Correspondingly, the required virtual machine resources are the number of CPU cores and memory (or storage) capacity explicitly required by the virtual machine specification to be created.
[0085] It should be noted that resource matching degree needs to be calculated separately for CPU cores and capacity, and then participate in the subsequent scoring calculation separately. The weight can be set according to business needs to distinguish the importance of different resource dimensions.
[0086] Resource redundancy penalty scores are used to penalize situations where the remaining resources of the physical machine far exceed the requirements of the virtual machine specifications, avoiding waste caused by excessive resource redundancy. A tiered scoring rule is adopted, as follows: If the remaining resources of the physical machine in a certain dimension exceed N% (e.g., 20%, where N is a positive integer) of the resource requirements of the virtual machine to be created in that dimension, then a tiered scoring is performed in units of M% (e.g., 5%, where M is a positive integer and N > M). For every M% exceeding the requirement, x points (e.g., 5 points) are recorded. The penalty scores of each level are accumulated separately for the two resource dimensions of CPU cores and capacity to obtain the resource redundancy penalty score corresponding to each resource dimension; if it does not exceed N%, no redundancy penalty score is generated for that dimension.
[0087] The fragmentation penalty score quantifies the degree of fragmentation of remaining resources after deploying virtual machines on a physical machine. Higher fragmentation results in a higher penalty score. The calculation method is as follows: Fragmentation Penalty Score = Remaining Physical Machine Resources modulo Required Resources. That is, the remaining resources of a physical machine in a certain dimension are modulo the required resources in that dimension. The modulo result is the fragmentation penalty score for that resource dimension. The smaller the modulo result, the more regular the remaining resources, the lower the fragmentation risk, and the smaller the penalty. If the remaining physical machine resources are equal to or less than the required resources, the modulo result represents the remaining physical machine resources, and the penalty score is relatively low.
[0088] See Figure 6 , Figure 6 This is a schematic diagram of a resource deduction device for a physical machine provided in an embodiment of this application. Figure 6 As shown, the resource deduction device of this physical machine includes: The physical machine acquisition unit 601 is used to acquire physical machines that meet the hard constraints from the physical machine cluster as available physical machines; the hard constraints are used to define the minimum necessary resources and environment requirements that the physical machine can support the specifications of the virtual machine to be created. The first queue generation unit 602 is used to generate a specification priority queue based on the business level of each virtual machine specification to be created, in order of priority of the levels. The relationship table creation unit 603 is used to create a matching relationship table with an initial empty state; the matching relationship table is used to record the mapping relationship between the virtual machine specifications to be created and the physical machines; The computing unit 604 is used to calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created. The resource compatibility score is used to quantify the compatibility between available physical machines and virtual machine specifications to be created based on the resource compatibility between the virtual machine specification to be created and available physical machines, as well as the fragmentation risk of the remaining resources of physical machines after the specification is deployed. The second queue generation unit 605 is used to generate a specification matching queue for each available physical machine and a physical machine matching queue for each virtual machine specification to be created, based on the resource adaptation score between the arbitrary available physical machine and each virtual machine specification to be created, according to the score size and in order. The first matching conflict processing unit 606 is used to perform matching and matching conflict processing between the virtual machine specification to be created and the available physical machine based on the specification priority queue, each specification matching queue, each physical machine matching queue and each resource adaptation score, so as to update the matching relationship table to obtain the effective mapping relationship between the specification and the physical machine. The first-round resource deduction unit 607 is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score and constructing the effective mapping relationship until the specification priority queue is empty, and then stop, and deduct resources from each physical machine based on the final matching relationship table; The cyclic matching and deduction unit 608 is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, constructing the effective mapping relationship, and deducting physical machine resources, until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, at which point it stops.
[0089] In one possible implementation, the first matching conflict processing unit 606 specifically includes: The target specification determination unit is used to traverse the specification priority queue and take the highest priority virtual machine specification to be created as the target specification. The setting unit is used to select the physics machine with the highest score in the physics machine matching queue of the target specification as the candidate physics machine of the target specification. The query unit is used to query whether there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table; The conflict-free matching unit, if there is no mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, is used to establish a mapping relationship between the target specification and the candidate physical machine, record the mapping relationship in the matching relationship table, and delete the target specification from the specification priority queue; The conflict handling execution unit, if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, is used to determine the mapping relationship as a pending relationship, and to perform matching conflict handling on the target specification, the matched specification and the candidate physical machine in combination with the pending relationship; the matched specification is the virtual machine specification to be created that has already established a mapping relationship with the candidate physical machine in the matching relationship table.
[0090] In one possible implementation, the process of handling matching conflicts between the target specification, the matched specification, and the candidate physical machine in conjunction with the pending relationship includes: In the specification matching queue of the candidate physical machine, query whether the priority of the target specification is lower than the priority of the already matched specification; If the priority of the target specification is lower than the priority of the matched specification, then query the physical machine matching queue of the target specification for a physical machine with a score lower than the candidate physical machine to replace the candidate physical machine as a new candidate physical machine. Then, use the new candidate physical machine to replace the candidate physical machine and re-execute the query to see if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, as well as subsequent steps. If the priority of the target specification is higher than the priority of the matched specification, then query whether the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine. If the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine, then the matched specification in the pending relationship is replaced with the target specification, and the matched specification is added back to the specification priority queue.
[0091] In one possible implementation, the apparatus further includes a second matching conflict processing unit, for: If the resource compatibility score between the target specification and the candidate physical machine is lower than the resource compatibility score between the matched specification and the candidate physical machine, then the following steps are performed: querying the physical machine with the second-lowest score in the physical machine matching queue of the target specification to replace the candidate physical machine as a new candidate physical machine, and so on.
[0092] In one possible implementation, the formula for calculating the resource adaptation score is as follows: Resource matching score = Σ(resource matching degree × weight - resource redundancy penalty score - fragmentation penalty score); Wherein, resource matching degree = (remaining physical machine resources / required specifications resources) × 100%, the remaining physical machine resources include the remaining number of physical machine cores and remaining capacity; the required specifications include the required number of cores and required capacity; The calculation rule for resource redundancy penalty score is as follows: if the remaining resources of the physical machine exceed N% of the resource requirements of the corresponding virtual machine to be created, then a tiered scoring is performed in units of M%. For each M% exceeding the limit, x points are recorded. The penalty scores generated by the tiered scoring are accumulated according to the resource dimension to obtain the resource redundancy penalty score corresponding to each resource dimension; N and M are both positive integers, and N is greater than M. Fragmentation penalty score = Physical machine remaining resources mod specification resource requirements.
[0093] In addition, this application embodiment also provides a physical machine resource deduction device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the physical machine resource deduction method as described above.
[0094] In addition, this application embodiment also provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the physical machine resource deduction method as described above.
[0095] This application's embodiments use hard constraints to filter available physical machines, then generate priority queues based on virtual machine specifications and business levels. Simultaneously, a resource adaptation score is designed to comprehensively quantify the resource compatibility between virtual machines and physical machines, as well as the fragmentation risk of remaining physical machine resources after specification deployment. Based on this score, specification matching queues are simultaneously built for physical machines, and physical machine matching queues are built for virtual machine specifications, achieving coordinated many-to-many matching between multiple specifications of virtual machines and physical machines. Subsequently, matching and conflict handling are carried out based on specification priority queues, various matching queues, and resource adaptation scores. An effective mapping relationship is formed by dynamically updating the matching relationship table, and multiple rounds of matching and deduction are completed until no physical machine has available matching resources. This achieves synchronous calculation and global resource planning of multi-specification virtual machine inventory, while also ensuring priority matching of core specifications based on business levels, and reducing resource waste from the source through fragmentation risk assessment. Meanwhile, the multi-round matching and deduction mechanism enables refined utilization of physical machine resources, making the resource deduction results approach the global optimum, significantly improving the overall resource utilization of physical machines, effectively solving the problems of resource fragmentation, insufficient utilization, and non-optimal inventory calculation in traditional algorithms, and making the inventory distribution and configuration of cloud computing resources more reasonable.
[0096] The resource deduction method, apparatus, device, and storage medium for a physical machine provided in this application have been described in detail above. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0097] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for deducting resources from a physical machine, characterized in that, The method includes: Physical machines that meet the hard constraints are selected from the physical machine cluster as available physical machines; the hard constraints are used to define the minimum required resources and environment requirements that the physical machines can support the specifications of the virtual machines to be created. Based on the business level of each virtual machine specification to be created, a specification priority queue is generated in order of priority level, and a matching relationship table is created with an initial empty state; the matching relationship table is used to record the mapping relationship between the virtual machine specifications to be created and the physical machines. Calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created. Based on the resource compatibility score between the available physical machine and each virtual machine specification to be created, generate a specification matching queue for each available physical machine and a physical machine matching queue for each virtual machine specification to be created in order of score. The resource compatibility score is used to quantify the degree of compatibility between the available physical machine and the virtual machine specification to be created based on the resource compatibility between the virtual machine specification to be created and the available physical machine, as well as the fragmentation risk of the remaining resources of the physical machine after the specification is deployed. Based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, the matching and matching conflict handling between the virtual machine specification to be created and the available physical machines are performed to update the matching relationship table and obtain the effective mapping relationship between the specification and the physical machine. Repeat the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, and constructing the effective mapping relationship until the specification priority queue is empty, then stop and deduct resources from each physical machine based on the final matching relationship table; Repeat the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, constructing the effective mapping relationship, and deducting physical machine resources until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, then stop.
2. The method according to claim 1, characterized in that, The process of matching and conflict resolution between the virtual machine specifications to be created and available physical machines based on the specification priority queue, each specification matching queue, each physical machine matching queue, and each resource adaptation score, in order to update the matching relationship table and obtain an effective mapping relationship between specifications and physical machines, includes: Iterate through the specification priority queue and take the highest priority virtual machine specification to be created as the target specification. The physics machine with the highest score in the physics machine matching queue for the target specification is selected as the candidate physics machine for the target specification. Query the matching table to see if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created; If there is no mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, then a mapping relationship between the target specification and the candidate physical machine is established, the mapping relationship is recorded in the matching relationship table, and the target specification is deleted from the specification priority queue. If there is a mapping relationship between a candidate physical machine and other virtual machine specifications to be created in the matching relationship table, the mapping relationship is determined as a pending relationship, and the target specification, the matched specification and the candidate physical machine are matched and conflicted in combination with the pending relationship; the matched specification is the virtual machine specification to be created that has established a mapping relationship with the candidate physical machine in the matching relationship table.
3. The method according to claim 2, characterized in that, The step of handling matching conflicts between the target specification, the matched specification, and the candidate physical machine based on the undetermined relationship includes: In the specification matching queue of the candidate physical machine, query whether the priority of the target specification is lower than the priority of the already matched specification; If the priority of the target specification is lower than the priority of the matched specification, then query the physical machine matching queue of the target specification for a physical machine with a score lower than the candidate physical machine to replace the candidate physical machine as a new candidate physical machine. Then, use the new candidate physical machine to replace the candidate physical machine and re-execute the query to see if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, as well as subsequent steps. If the priority of the target specification is higher than the priority of the matched specification, then query whether the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine. If the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine, then the matched specification in the pending relationship is replaced with the target specification, and the matched specification is added back to the specification priority queue.
4. The method according to claim 3, characterized in that, The method further includes: If the resource compatibility score between the target specification and the candidate physical machine is lower than the resource compatibility score between the matched specification and the candidate physical machine, then the following steps are performed: querying the physical machine with the second-lowest score in the physical machine matching queue of the target specification to replace the candidate physical machine as a new candidate physical machine, and so on.
5. The method according to claim 1, characterized in that, The formula for calculating the resource adaptation score is as follows: Resource matching score = Σ(resource matching degree × weight - resource redundancy penalty score - fragmentation penalty score); Wherein, resource matching degree = (remaining physical machine resources / required specifications resources) × 100%, the remaining physical machine resources include the remaining number of physical machine cores and remaining capacity; the required specifications include the required number of cores and required capacity; The calculation rule for resource redundancy penalty score is as follows: if the remaining resources of the physical machine exceed N% of the resource requirements of the corresponding virtual machine to be created, then a tiered scoring is performed in units of M%. For each M% exceeding the limit, x points are recorded. The penalty scores generated by the tiered scoring are accumulated according to the resource dimension to obtain the resource redundancy penalty score corresponding to each resource dimension; N and M are both positive integers, and N is greater than M. Fragmentation penalty score = Physical machine remaining resources mod specification resource requirements.
6. A resource deduction device for a physical machine, characterized in that, The device includes: The physical machine acquisition unit is used to acquire physical machines that meet the hard constraints from the physical machine cluster as available physical machines; the hard constraints are used to define the minimum necessary resources and environment requirements that the physical machine can support the specifications of the virtual machine to be created. The first queue generation unit is used to generate a specification priority queue based on the business level of each virtual machine specification to be created, in order of priority of the levels. The relation table creation unit is used to create a matching relation table with an initial empty state; the matching relation table is used to record the mapping relationship between the virtual machine specifications to be created and the physical machines; The computing unit is used to calculate the resource compatibility score between any available physical machine and each virtual machine specification to be created. The resource compatibility score is used to quantify the compatibility between available physical machines and virtual machine specifications to be created based on the resource compatibility between the virtual machine specification to be created and available physical machines, as well as the risk of fragmentation of the remaining resources of physical machines after the specification is deployed. The second queue generation unit is used to generate a specification matching queue for each available physical machine and a physical machine matching queue for each virtual machine specification to be created, based on the resource adaptation score between any available physical machine and each virtual machine specification to be created, according to the score size and in order. The first matching conflict handling unit is used to perform matching and matching conflict handling between the virtual machine specification to be created and the available physical machines based on the specification priority queue, each specification matching queue, each physical machine matching queue and each resource adaptation score, so as to update the matching relationship table to obtain the effective mapping relationship between the specification and the physical machine. The first-round resource deduction unit is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, and constructing the effective mapping relationship until the specification priority queue is empty, and then stop, and deduct resources from each physical machine based on the final matching relationship table; The cyclic matching and deduction unit is used to repeatedly execute the steps of generating the specification priority queue, creating the matching relationship table, calculating the resource adaptation score, constructing the effective mapping relationship, and deducting physical machine resources, until the remaining resources of any available physical machine cannot match any virtual machine specification to be created, at which point it stops.
7. The apparatus according to claim 6, characterized in that, The first matching conflict processing unit is specifically used for: Iterate through the specification priority queue and take the highest priority virtual machine specification to be created as the target specification. The physics machine with the highest score in the physics machine matching queue for the target specification is selected as the candidate physics machine for the target specification. Query the matching table to see if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created; If there is no mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, then a mapping relationship between the target specification and the candidate physical machine is established, the mapping relationship is recorded in the matching relationship table, and the target specification is deleted from the specification priority queue. If there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, the mapping relationship is determined as a pending relationship, and the target specification, the matched specification and the candidate physical machine are matched and conflicted in combination with the pending relationship; The matched specification refers to the virtual machine specification to be created that has already established a mapping relationship with the candidate physical machine in the matching relationship table.
8. The apparatus according to claim 7, characterized in that, The step of handling matching conflicts between the target specification, the matched specification, and the candidate physical machine based on the undetermined relationship includes: In the specification matching queue of the candidate physical machine, query whether the priority of the target specification is lower than the priority of the already matched specification; If the priority of the target specification is lower than the priority of the matched specification, then query the physical machine matching queue of the target specification for a physical machine with a score lower than the candidate physical machine to replace the candidate physical machine as a new candidate physical machine. Then, use the new candidate physical machine to replace the candidate physical machine and re-execute the query to see if there is a mapping relationship between the candidate physical machine and other virtual machine specifications to be created in the matching relationship table, as well as subsequent steps. If the priority of the target specification is higher than the priority of the matched specification, then query whether the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine. If the resource adaptation score between the target specification and the candidate physical machine is higher than the resource adaptation score between the matched specification and the candidate physical machine, then the matched specification in the pending relationship is replaced with the target specification, and the matched specification is added back to the specification priority queue.
9. A resource deduction device for a physical machine, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the resource deduction method for a physical machine as described in any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform the resource deduction method for a physical machine as described in any one of claims 1-5.