Resource allocation method and related apparatus
By obtaining historical tenant data from cloud services, calculating the number of nodes, and distributing them evenly, the problem of load imbalance caused by tenant instance placement is solved, achieving load balancing and cost optimization.
Patent Information
- Application Number
- PCT/CN2025/084030
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-17
- Filing Date
- 2025-03-21
- Publication Date
- 2025-12-26
AI Technical Summary
In cloud services, the placement of tenant instances can lead to excessive load on physical machines, resulting in load imbalance, especially between availability zones and nodes.
By acquiring historical operational data from tenants, the required number of nodes is calculated, and the distribution of nodes and instances is balanced across availability zones to ensure load balancing for each availability zone and node. Historical data and optimization algorithms are used to adjust instance placement to avoid overload.
It achieves load balancing between availability zones and nodes, reduces the number of physical machines used, lowers operating costs, and improves system availability and disaster recovery capabilities.
Smart Images

Figure CN2025084030_26122025_PF_FP_ABST
Abstract
Description
A resource allocation method and related apparatus
[0001] The present application claims priority to the Chinese patent application No. 202410783003.0, filed on June 17, 2024, and entitled “A resource allocation method and related apparatus”, the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the field of cloud computing technology, and in particular to a resource allocation method and related apparatus. BACKGROUND
[0003] With the continuous development of Internet technology, cloud services have become an indispensable part of modern society. Cloud services are a service mode based on cloud computing technology, which can provide computing, storage and application services and other service resources to users through the Internet. Cloud services are inexpensive and cost-effective, and individual users can obtain more efficient, stable and secure computing resources through cloud services. The emergence of cloud services also provides more flexible and scalable computing resources for enterprises and organizations, which can choose different cloud services according to their needs to achieve more efficient business operations.
[0004] The users of cloud services can also be called tenants, and each tenant can include multiple instances. Cloud service providers usually establish multiple data centers, one or more data centers for a availability zone, and each data center includes numerous physical machines. The cloud service provider places tenant instances on the physical machines. In practical applications, the number of tenant instances can reach tens of thousands, so how to place a large number of instances has become an important problem. Currently, in order to reduce the number of physical machines used and reduce the purchase and operation costs of physical machines, as many instances as possible are often placed on a physical machine, which often leads to high or even overload of a single physical machine, and further leads to unbalanced load between physical machines and between availability zones. SUMMARY
[0005] The present application provides a resource allocation method and related apparatus for balancing the load between availability zones, balancing the load between nodes, and balancing the number of instances of each tenant in different availability zones.
[0006] The first aspect of the application provides a resource allocation method, which can be applied to a resource allocation device. The method comprises: obtaining historical running data of a plurality of tenants, the historical running data comprising resource occupancy of each tenant of the plurality of tenants in a historical running process; calculating a first quantity based on the historical running data, the first quantity being a quantity of nodes required by the plurality of tenants; determining a plurality of availability zones, the plurality of availability zones being used to place instances of the plurality of tenants, each availability zone of the plurality of availability zones comprising a plurality of nodes; allocating the nodes required by the plurality of tenants to each availability zone of the plurality of availability zones based on the first quantity to obtain opened nodes of each availability zone, the difference in the number of opened nodes between different availability zones of the plurality of availability zones being less than or equal to 1; allocating instances of each tenant to each availability zone of the plurality of availability zones, the difference in the number of instances of each tenant allocated to different availability zones of the plurality of availability zones being less than or equal to 1; determining the number of instances of the plurality of tenants allocated to a first availability zone based on the number of instances of each tenant allocated to each availability zone, the first availability zone being any one of the plurality of availability zones; placing the instances of the plurality of tenants allocated to the first availability zone on the opened nodes of the first availability zone based on the number of instances of the plurality of tenants allocated to the first availability zone, the difference in the number of instances placed on different nodes of the opened nodes of the first availability zone being less than or equal to 1.
[0007] The first aspect of the application is a one-time scheduling stage of tenant instances, that is, the instances of the plurality of tenants are placed by the cloud service in an initialization state. First, the historical running data of each tenant of the plurality of tenants is obtained, and the historical running data records the resource occupancy of each tenant in a historical running process. The resource occupancy of a tenant comprises the resource occupancy of a plurality of instances of the tenant on each node where the instances are located. The resource occupancy is the usage of resources, including the occupancy of processor resources and the occupancy of memory resources. In one possible scheme, the tenant has used the cloud service before, and thus the historical running data of the tenant can be directly obtained from a database. In another possible scheme, the tenant is a new user, and thus the tenant is placed on a test node for trial running for a period of time, so as to obtain the historical running data of the tenant. Alternatively, the tenant provides historical running data when applying for the cloud service, and thus the historical running data is obtained from the data provided by the tenant.
[0008] Then, the total number of nodes required by the plurality of tenants is estimated based on the resource usage of each tenant. In calculating the first quantity, parameters such as the number of instances of each tenant, the total number of instances of the plurality of tenants, the processor resource condition and the memory resource condition of each node, the number of instances that can be accommodated by each node, and the number of instances of the same tenant that can be accommodated by each node can also be combined to calculate, so as to obtain a more accurate number of nodes.
[0009] Then, a plurality of available zones for placing the current plurality of tenant instances is determined, and the nodes required by the plurality of tenants are allocated to each available zone based on the first number and the number of available zones, and the number of nodes allocated to each available zone is the number of nodes to be started, and the other nodes in the available zone can not be started first. The allocation rule is that the difference between the number of nodes allocated to different available zones is less than or equal to 1, in other words, the difference between the number of started nodes in different available zones is less than or equal to 1. If the difference is less than 1, it means an average allocation, and the number of started nodes in each available zone is the same. If the difference is equal to 1, it is for the case that cannot be evenly allocated, that is, the first number cannot be divided by the number of available zones.
[0010] After determining the number of nodes started in each available zone, the instances of each tenant are allocated to each available zone based on the number of available zones and the number of nodes started in each available zone, and the allocation rule is that the difference between the number of instances of each tenant allocated to different available zones is less than or equal to 1, so as to achieve the allocation of instances of each tenant to each available zone as evenly as possible. If the difference is less than 1, it means an average allocation, and the number of instances of each tenant allocated to each available zone is the same. If the difference is equal to 1, it is for the case that cannot be evenly allocated.
[0011] The first available zone is any one of the plurality of available zones, and after determining the instances of each tenant allocated to each available zone, the instances of the plurality of tenants allocated to the first available zone are placed on the started nodes of the first available zone, and the placement rule (i.e. the allocation rule) is that the difference between the number of instances placed on different nodes in the first available zone is less than or equal to 1. If the difference is less than 1, it means an average allocation, and the number of instances placed on each started node in the first available zone is the same. If the difference is equal to 1, it is for the case that cannot be evenly allocated.
[0012] In the first aspect of the present application, the number of nodes required by the plurality of tenants (the first number) is estimated according to the historical running data of the tenants, so as to reduce the number of started nodes and save the operation cost. Then, the number of started nodes in each available zone is allocated as evenly as possible according to the first number, so that the number of started nodes in each available zone is approximately equal, and the instances of each tenant are evenly allocated to each available zone, so that the number of instances of each tenant allocated to each available zone is also approximately equal, thereby achieving load balancing between available zones and balancing the number of instances of each tenant in different available zones. Then, the instances of the plurality of tenants allocated to the available zone are allocated to each started node in the available zone as evenly as possible, so that the number of instances allocated to each started node in the available zone is approximately the same, thereby achieving load balancing between nodes.
[0013] In a possible implementation of the first aspect, in the case that the first available zone enabled node comprises the first node, after the step of allocating the multiple tenants to the instance placement in the first available zone on the enabled node in the first available zone, the method further comprises: judging whether the first node is overloaded; in the case that the first node is overloaded, obtaining resource occupancy of the multiple instances placed on the first node; migrating K instances with the highest resource occupancy from the multiple instances to a second node, wherein the first node and the second node both satisfy the load constraint after the migration of the K instances.
[0014] When running for a period of time, the running conditions of the tenant instances change. For example, some tenants add some instances, and some tenants delete some instances. Or the resource occupancy of the instances changes, resulting in unbalanced load among the nodes, some nodes may have a large amount of resource left, and some nodes may have a resource shortage or even be overloaded. Therefore, the placement of the instances is adjusted to ensure that the nodes are not overloaded. Specifically, the overloaded nodes are first screened. For example, for the first node, it is judged whether the first node is overloaded. If the first node is overloaded, the resource occupancy of the instances placed on the first node is obtained. Then, the instances are sorted according to the resource occupancy, and K instances with the highest resource occupancy are selected from the sorted instances, so that the first node is no longer overloaded after the migration of the K instances. Then, a second node is selected, which needs to satisfy the load constraint after the migration of the K instances. After the second node is determined, the K instances are migrated to the second node.
[0015] The instances with the highest resource occupancy are migrated because the migration cost is considered, and the migration times are reduced as much as possible. Compared with the instances with less resource occupancy, the instances with more resource occupancy can be migrated less to achieve no overload.
[0016] Optionally, the first node is just not overloaded after the migration of the K instances, that is, K is the minimum migration times for the first node to satisfy the load constraint.
[0017] In this possible implementation, the placement of the tenant instances is adjusted, and the instances are migrated from the overloaded first node to the second node. After the migration, the first node and the second node both satisfy the load constraint, so as to ensure the load balance among the nodes as much as possible. Moreover, it is ensured that the nodes do not run in an overloaded manner, so as to ensure the operation speed and running safety of the nodes, and reduce the energy consumption of the nodes. In addition, the migrated instances are the instances with the highest resource occupancy. Compared with the instances with less resource occupancy, the first node can be migrated less to achieve no overload, so as to reduce the migration times and reduce the migration cost.
[0018] In a possible implementation manner of the first aspect, the step of migrating K instances with the highest resource occupancy from the plurality of instances to the second node includes: screening the second node from the first availability zone that still satisfies the load constraint after placing the K instances; and placing the K instances on the second node one by one based on the resource occupancy ranking.
[0019] In the possible implementation manner, the second node is also an enabled node in the first availability zone, that is, the instance migration is performed in the availability zone, so that the migration cost can be reduced. The second node can include a plurality of nodes, that is, the K instances are migrated to a plurality of enabled nodes in the first availability zone, and the plurality of enabled nodes all satisfy the load constraint after placing the K instances. During the migration, the instances with large resource occupancy are migrated first, that is, the K instances are placed on the second node one by one based on the resource occupancy ranking. When the second node includes a plurality of nodes, the plurality of nodes can also be ranked based on the remaining resources, and the instances are preferentially migrated to the nodes with more remaining resources.
[0020] In a possible implementation manner of the first aspect, the plurality of availability zones further include a second availability zone, and the second node is an enabled node in the second availability zone.
[0021] In the possible implementation manner, the instance migration is performed across the availability zones, the application scenario of the scheme is expanded, and the success rate of the instance migration is improved. Moreover, the instance migration can be implemented without adding a node, the number of enabled nodes is reduced, and therefore the purchase cost and operation cost of the physical machine can be saved.
[0022] In a possible implementation manner of the first aspect, the plurality of availability zones further include a second availability zone, and before the step of migrating K instances with the highest resource occupancy from the first batch of instances to the second node, the method further includes: starting a second node in the first availability zone or the second availability zone.
[0023] In the possible implementation manner, the instance migration is implemented by adding a node in the availability zone or adding a node across the availability zones, the application scenario of the scheme is expanded, and the success rate of the instance migration is improved.
[0024] In a possible implementation manner of the first aspect, the method further includes: receiving a first instruction generated after an operation personnel sets a priority of an optimization target through a management interface, the optimization target including maintaining load balance among the plurality of availability zones, reducing the number of instances migrated across the availability zones, or reducing the number of added nodes; and migrating K instances with the highest resource occupancy from the plurality of instances to the second node includes: migrating the K instances with the highest resource occupancy from the plurality of instances to the second node in combination with the first instruction.
[0025] The optimization targets include maintaining load balance among the multiple availability zones, reducing the number of instance migrations across availability zones, and reducing the number of newly added nodes. The instance migration schemes are different when the optimization targets are different. When the priority of maintaining load balance among the multiple availability zones is the highest, the load balance among the availability zones is guaranteed first, and instance migration across availability zones or newly added nodes across availability zones can be performed to guarantee the load balance. When the priority of reducing the number of instance migrations across availability zones is the highest, instance migration within an availability zone is performed first, and a node is newly added in the availability zone when no node in the availability zone can be migrated. When the priority of reducing the number of newly added nodes is the highest, instance migration within an availability zone is performed first, and instance migration across availability zones is performed when no node in the availability zone can be migrated. When setting the priorities, a first priority, a second priority, and a third priority can be set. In addition to the optimization targets described above, other optimization targets can be used, such as reducing a total load value, increasing the number of migrations within an availability zone, and reducing the number of newly added nodes across availability zones. The operator sets the priorities of the optimization targets in the management interface to generate a first instruction, and the resource allocation apparatus determines a specific instance migration scheme in combination with the first instruction.
[0026] In this possible implementation manner, a management interface is provided, and the operator can set the priorities of the optimization targets in the management interface in combination with the running conditions and requirements, and determine a specific instance migration scheme through the set priorities, to facilitate the operator to operate and manage the instance migration scheme.
[0027] In a possible implementation manner of the first aspect, the method further includes: when the opened nodes in the multiple availability zones cannot accommodate the instances of the multiple tenants, calculating a second number based on the number of unplaced instances, the second number being a number of nodes that need to be newly opened; and allocating the nodes that need to be newly opened to each of the multiple availability zones based on the second number, a difference between the numbers of the newly opened nodes in different availability zones in the multiple availability zones being less than or equal to 1.
[0028] The number of nodes calculated based on the historical running conditions of the multiple tenants can have some deviations compared with the actual conditions. When the number of opened nodes cannot accommodate the instances of the tenants, some nodes need to be newly added. Specifically, the number of nodes that need to be newly added (that is, the second number) is calculated based on the number of unplaced instances. In the calculation, the processor resource conditions and the memory resource conditions of each node, the number of instances that can be accommodated by each node, and the number of instances of the same tenant that can be accommodated by each node (mutually exclusive constraints) can be combined to calculate, to obtain a more accurate number.
[0029] After the second quantity is calculated, the newly started nodes of each available zone are allocated based on the second quantity, and the allocation rule is that the difference between the number of newly started nodes of different available zones in the plurality of available zones is less than or equal to 1. If the difference is less than 1, it is the case of average allocation, and the number of newly started nodes of each available zone is the same. If the difference is equal to 1, it is for the case that cannot be evenly allocated, that is, the number of newly started nodes (that is, the second quantity) cannot be divided by the number of available zones. Specifically, it can be divided into two cases: the second quantity is less than the number of available zones and the second quantity is greater than the number of available zones. When the second quantity is greater than the number of available zones, the part that can be evenly allocated is allocated first, and then the remainder is allocated one by one based on the remainder. When the second quantity is less than the number of available zones, the second quantity is equivalent to the remainder at this time, and the nodes of the second quantity are allocated to the plurality of available zones one by one.
[0030] In this possible implementation manner, when the estimated number of nodes is insufficient to accommodate the instances of the plurality of tenants, the number of nodes required is calculated based on the number of instances that are not placed, so that the number of started nodes can be reduced as much as possible on the premise of guaranteeing the use demand. Moreover, the newly started nodes are allocated as evenly as possible to each available zone, so as to balance the number of nodes of each available zone, thereby laying a foundation for load balancing between available zones.
[0031] In a possible implementation manner of the first aspect, each started node is used to place only one instance of the same tenant.
[0032] In this possible implementation manner, each node is limited to placing only one instance of the same tenant, so that the asset security of the tenant can be better protected, and the availability and disaster recovery capability of the system can be improved.
[0033] In a possible implementation manner of the first aspect, the method further includes: receiving a second instruction, the second instruction being generated after an operator sets parameters through a management interface, and the parameters including any one or more of the following: an available zone, a number of available zones, a node, an upper limit number of nodes, and a number of instances of the same tenant accommodated by each node; and the step of allocating the nodes required by the plurality of tenants to each available zone in the plurality of available zones based on the first quantity includes: allocating the nodes required by the plurality of tenants to each available zone in the plurality of available zones based on the first quantity and in combination with the second instruction.
[0034] The operation personnel can set parameters in the management interface, such as which available zones are used to place instances of the current tenant, the number of enabled available zones, which nodes in the available zones can be used, the upper limit of the number of enabled nodes, the number of instances that each node can accommodate, and the upper limit of the number of instances of the same tenant that each node can accommodate, and the like. The second instruction is generated after the parameters are set in the management interface and is sent to the resource allocation device. The resource allocation device allocates the enabled nodes to the specified available zones based on the calculated number of nodes required by the multiple tenants in combination with the second instruction, and the enabled nodes are also selected from the nodes indicated by the second instruction. Then, the instances of each tenant are placed on the enabled nodes of each available zone in combination with the second instruction, for example, a specific placement scheme is determined in combination with the upper limit of the number of instances that each node can accommodate and the upper limit of the number of instances of the same tenant that each node can accommodate. When the number of set nodes is not enough, a prompt message is sent and displayed in the management interface, reminding the operation personnel to change the parameter settings.
[0035] In this possible implementation, a management interface is provided, and the operation personnel can set parameters such as available zones that can be used, nodes that can be used, and the upper limit of the number of instances of the same tenant that each node can accommodate through the management interface, facilitating the operation personnel to perform daily management and maintenance.
[0036] The second aspect of the present application provides a resource allocation device, comprising an acquisition unit, a calculation unit, a determination unit, an allocation unit, and a placement unit. The acquisition unit is configured to acquire historical running data of multiple tenants, the historical running data comprising resource occupation amounts of each tenant of the multiple tenants in a historical running process. The calculation unit is configured to calculate a first number based on the historical running data, the first number being a number of nodes required by the multiple tenants. The determination unit is configured to determine multiple available zones, the multiple available zones being used to place instances of the multiple tenants, each available zone of the multiple available zones comprising multiple nodes. The allocation unit is configured to allocate the nodes required by the multiple tenants to each available zone of the multiple available zones based on the first number, to obtain enabled nodes of each available zone, and the number of enabled nodes in different available zones of the multiple available zones having a difference value less than or equal to 1. The allocation unit is further configured to allocate instances of each tenant to each available zone of the multiple available zones, the number of instances of each tenant allocated to different available zones of the multiple available zones having a difference value less than or equal to 1. The allocation unit is further configured to determine the number of instances of the multiple tenants allocated to a first available zone based on the number of instances of each tenant allocated to each available zone, the first available zone being any one of the multiple available zones. The placement unit is configured to place the instances of the multiple tenants allocated to the first available zone on the enabled nodes of the first available zone based on the number of instances of the multiple tenants allocated to the first available zone, and the number of instances placed on different nodes of the enabled nodes of the first available zone having a difference value less than or equal to 1.
[0037] In a possible implementation manner of the second aspect, the started node of the first available zone includes the first node, and the apparatus further includes: a judging unit, configured to judge whether the first node is overloaded; an obtaining unit, configured to obtain resource occupancy of a plurality of instances placed on the first node in a case where the first node is overloaded; and a migrating unit, configured to migrate K instances with the highest resource occupancy from the plurality of instances to the second node, and the first node and the second node both satisfy the load constraint after the migration of the K instances.
[0038] In a possible implementation manner of the second aspect, the migrating unit is specifically configured to: select a second node from the first available zone, which still satisfies the load constraint after placing the K instances; and place the K instances on the second node one by one based on the resource occupancy ranking.
[0039] In a possible implementation manner of the second aspect, the plurality of available zones further include a second available zone, and the second node is a started node in the second available zone.
[0040] In a possible implementation manner of the second aspect, the plurality of available zones further include a second available zone, and the apparatus further includes: a starting unit, configured to newly start a second node in the first available zone or the second available zone.
[0041] In a possible implementation manner of the second aspect, the apparatus further includes: a receiving unit, configured to receive a first instruction, the first instruction being generated after an operator sets a priority of an optimization target through a management interface, and the optimization target including maintaining load balance among the plurality of available zones, reducing the number of instances migrated across available zones, and reducing the number of newly started nodes; and the migrating unit is specifically configured to migrate K instances with the highest resource occupancy from the plurality of instances to the second node in combination with the first instruction.
[0042] In a possible implementation manner of the second aspect, the calculating unit is further configured to: calculate a second number based on the number of instances that are not placed when the instances of the plurality of tenants cannot be placed on the started nodes of the plurality of available zones, the second number being the number of nodes that need to be newly started; and the allocating unit is further configured to: allocate the nodes that need to be newly started to each available zone in the plurality of available zones based on the second number, and the number difference of the newly started nodes between different available zones in the plurality of available zones is less than or equal to 1.
[0043] In a possible implementation manner of the second aspect, each started node is used to place only one instance of the same tenant.
[0044] In a possible implementation manner of the second aspect, the receiving unit is further configured to receive a second instruction, the second instruction being generated after the operation personnel sets the parameters through the management interface, and the parameters include any one or more of the following: an available zone, a number of available zones, a node, an upper limit number of nodes, and a number of instances of each node accommodating the same tenant; and the allocating unit is specifically configured to allocate the nodes required by the plurality of tenants to each of the plurality of available zones based on the first number and in combination with the second instruction.
[0045] The resource allocation apparatus provided in the second aspect of the present application is used to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0046] The resource allocation apparatus provided in the third aspect of the present application includes a processor and a memory. The memory is configured to store instructions, and the processor is configured to acquire the instructions stored in the memory to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0047] The computer readable storage medium provided in the fourth aspect of the present application includes instructions, and when the instructions are run on a computer, the computer is caused to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0048] The computer program product provided in the fifth aspect of the present application includes instructions, and when the computer program product is run on a computer, the computer is caused to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0049] The chip system provided in the sixth aspect of the present application includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is configured to run a computer program or instructions to execute the method in the first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0050] FIG. 1 is a schematic diagram of one application scenario of the resource allocation method provided in the embodiments of the present application;
[0051] FIG. 2a is a schematic diagram of one scheduling stage in the embodiments of the present application;
[0052] FIG. 2b is a schematic diagram of a second scheduling stage in the embodiments of the present application;
[0053] FIG. 3 is a schematic diagram of one embodiment of the resource allocation method provided in the embodiments of the present application;
[0054] FIG. 4 is a schematic diagram of allocating tenant instances to available zones in the embodiments of the present application;
[0055] Figure 5 is a pseudo code diagram of the outer LBFF algorithm in an embodiment of the present application;
[0056] Figure 6 is a diagram of allocating tenant instances to nodes in an embodiment of the present application;
[0057] Figure 7 is a pseudo code diagram of the inner LBFF algorithm in an embodiment of the present application;
[0058] Figure 8 is another embodiment of the resource allocation method provided by the present application;
[0059] Figure 9 is another embodiment of the resource allocation method provided by the present application;
[0060] Figure 10 is another embodiment of the resource allocation method provided by the present application;
[0061] Figure 11 is a diagram of instance migration in an embodiment of the present application;
[0062] Figure 12 is a pseudo code diagram of instance migration in an embodiment of the present application;
[0063] Figure 13 is another embodiment of the resource allocation method provided by the present application;
[0064] Figure 14 is another embodiment of the resource allocation method provided by the present application;
[0065] Figure 15a is a diagram of a management interface provided by an embodiment of the present application;
[0066] Figure 15b is another diagram of a management interface provided by an embodiment of the present application;
[0067] Figure 16a is a diagram of the beneficial effects of an embodiment of the present application;
[0068] Figure 16b is another diagram of the beneficial effects of an embodiment of the present application;
[0069] Figure 16c is another diagram of the beneficial effects of an embodiment of the present application;
[0070] Figure 16d is another diagram of the beneficial effects of an embodiment of the present application;
[0071] Figure 17 is a structural diagram of a resource allocation apparatus provided by an embodiment of the present application;
[0072] Figure 18 is another structural diagram of a resource allocation apparatus provided by an embodiment of the present application. DETAILED DESCRIPTION
[0073] This application provides a resource allocation method that can achieve load balancing between availability zones, load balancing between nodes, and balancing the number of instances per tenant in different availability zones. This application also provides corresponding apparatus, computer-readable storage media, and computer program products, etc., which will be described below.
[0074] The embodiments of this application are described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. As those skilled in the art will understand, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0075] The terms “relocation” and “migration,” “system” and “network,” etc., used in the specification, claims, and accompanying drawings of this application are interchangeable. Unless otherwise specified, ordinal numbers such as “first,” “second,” etc., are used to distinguish multiple objects and are not used to limit the order, sequence, priority, or importance of the multiple objects. It should be understood that such terms are interchangeable where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0076] To facilitate understanding, the relevant terms and concepts mainly involved in the embodiments of this application will be introduced below.
[0077] 1. Availability Zone
[0078] An availability zone (AZ) is a technical concept in cloud computing used to improve the availability and fault tolerance of applications. In the infrastructure of a cloud service provider, multiple physical data centers are typically built. An AZ is a collection of one or more physical data centers, and within an AZ, computing, network, and storage resources are logically divided into multiple clusters. Each availability zone operates independently and has its own power, network, and cooling systems, while they are interconnected via high-speed fiber optic cables.
[0079] 2. Nodes
[0080] Each availability zone consists of multiple racks, each rack includes multiple physical machines, and each physical machine is a node.
[0081] 3. Examples
[0082] An instance is a basic unit in the cloud computing infrastructure. Through virtualization technology, a cloud service provider can divide a physical server into multiple independent virtual machine instances, which can independently run different operating systems and applications. It can be a virtual machine, a container, or even a collection of related applications.
[0083] Please refer to FIG. 1 for a schematic diagram of an application scenario of the resource allocation method provided by the embodiments of the present application.
[0084] As shown in FIG. 1, it is a schematic diagram of placing tenant instances in a cloud computing scenario. In FIG. 1, there are three availability zones, AZ1, AZ2 and AZ3. The multiple availability zones are connected through the Internet. Each availability zone includes three racks, AZ1 includes rack 1.1, rack 1.2 and rack 1.3, AZ2 includes rack 2.1, rack 2.2 and rack 2.3, and AZ3 includes rack 3.1, rack 3.2 and rack 3.3. The racks are used to place physical machines, which can also be referred to as nodes or nodes. Each rack includes three nodes, node1, node2 and node3. The nodes can place tenant instances, each node can place six instances, and each tenant can include multiple instances. The shaded circles in FIG. 1 represent that the tenant instances have been stored, and the blank circles represent that the tenant instances have not been stored.
[0085] Currently, when placing tenant instances, cloud service providers often place as many instances as possible on a physical machine, thereby reducing the number of physical machines used and saving the purchase and operation costs of physical machines. However, this often leads to high load or even overload of a single physical machine, and further leads to unbalanced load between physical machines and between availability zones.
[0086] In view of this, the embodiments of the present application provide a resource allocation method, which can be applied to a resource allocation device. Specifically, by evenly distributing as much as possible the nodes opened in each availability zone, the number of nodes opened in each availability zone is approximately equal, by evenly distributing as much as possible the instances of each tenant to each availability zone, the number of instances of each tenant allocated to each availability zone is also approximately equal, thereby achieving load balancing between availability zones and balancing the number of instances of each tenant in different availability zones. Then, by evenly distributing as much as possible the instances of multiple tenants to the opened nodes in the availability zone, the number of instances allocated to each opened node in the availability zone is approximately equal, thereby achieving load balancing between nodes.
[0087] Thus, the number of instances of each tenant in different availability zones and the number of instances placed on each node can be balanced, and load balancing between availability zones and between nodes can be achieved.
[0088] The two stages of tenant instance placement involved in the resource allocation method provided by the embodiments of the present application will be described first. The tenant instance placement can be divided into a first scheduling stage and a second scheduling stage. The first scheduling stage is a preliminary placement stage of tenant instances, and in this stage, the cloud service is in an initialization state. The second scheduling stage is an optimized configuration stage of tenant instances after a period of operation. After a period of operation, the cloud service can add some instances, delete some instances, or the resource occupancy of each instance changes, thereby causing the load between nodes to be unbalanced, some nodes can have a large amount of resource surplus, and some nodes can have a resource shortage or even be overloaded. Therefore, in the second scheduling stage, some instances of the tenant are re-placed, for example, the instances are migrated from the overloaded node to the node with more free resources, to alleviate the unbalanced load. The first scheduling stage and the second scheduling stage will be described below in conjunction with FIG. 2a and FIG. 2b.
[0089] Fig. 2a is a schematic diagram of a one-time scheduling stage. In Fig. 2a, four tenants are included, which are tenant 1, tenant 2, tenant 3 and tenant 4. Tenant 1 includes four instances, which are 1-1, 1-2, 1-3 and 1-4. Tenant 2 includes three instances, which are 2-1, 2-2 and 2-3. Tenant 3 includes four instances, which are 3-1, 3-2, 3-3 and 3-4. Tenant 4 includes two instances, which are 4-1 and 4-2. Three available zones are available, which are AZ1, AZ2 and AZ3. Each available zone includes three nodes, and each node can place three instances. The nodes of the three available zones are in idle state, and no tenant instance is placed (represented as blank rectangular box in Fig. 2a). The one-time scheduling stage places the instances included in the four tenants on the nodes of the three available zones. In the embodiment of the present application, the instances of each tenant are evenly distributed to the three available zones in the one-time scheduling stage. For the instances distributed to each available zone, the instances are placed in each node one by one, so as to balance the load among the available zones and among the nodes. For example, the four instances of tenant 1 are evenly distributed to the three AZs, and each AZ is first allocated one instance, and the extra instance can be allocated to any of the three AZs. As shown in Fig. 2a, 1-1 is allocated to AZ1, 1-2 is allocated to AZ2, and 1-3 and 1-4 are allocated to AZ3. The placement of the instances of the remaining three tenants is similar to that of tenant 1. It can be understood that, since tenant 1 places two instances in AZ3, the extra instance of tenant 3 is placed in AZ1 or AZ2 as much as possible after the even distribution. If the extra instance of tenant 3 is placed in AZ2, one instance of tenant 4 is preferentially placed in AZ1, and the other instance can be placed in any of AZ2 and AZ3. For example, in Fig. 2a, 3-4 of tenant 3 is placed in AZ2, 4-1 of tenant 4 is placed in AZ1, and 4-2 of tenant 4 is placed in AZ2.
[0090] Fig. 2b is a schematic diagram of a secondary scheduling stage. After the cloud service has been running for a period of time, tenant 2 adds two instances 2-4 and 2-5, tenant 3 reduces instance 3-4, and a new tenant 5 is added, which includes two instances 5-1 and 5-2. The increase or decrease of instances affects the load of nodes, so the storage locations of the instances are adjusted according to the load of the nodes. Specifically, instances in nodes with high load are migrated to nodes with low load, or new nodes are added, and the added instances or instances that need to be migrated are placed on the new nodes. When migrating instances, it can be intra-AZ migration or cross-AZ migration, and adding nodes can also be intra-AZ addition or cross-AZ addition. In Fig. 2b, the two instances added by tenant 2 are placed in AZ3 and AZ1, the two instances of the newly added tenant 5 are placed in AZ2 and AZ1, and since AZ1 reduces instance 3-4, instance 5-2 is placed in the original storage location of instance 3-3. During operation, the resource occupancy of each instance may also change, and the storage location of the instance needs to be adjusted according to the resource occupancy. For example, in Fig. 2b, node 3 of AZ1 is overloaded, and node 1 of AZ3 has a lot of idle resources, so instance 3-2 in node 3 of AZ1 with high resource occupancy is exchanged with instance 1-4 in node 2 of AZ3 with low resource occupancy. After the exchange, instance 1-3 is placed in node 3 of AZ1 and instance 3-2 is placed in node 2 of AZ3, so as to meet the load balancing as much as possible.
[0091] The placement of tenant instances can actually be simplified as achieving the goals of each scheduling stage under certain constraints. For example, the constraints include that each instance is placed on only one node, the memory resource constraint of each node, the processor resource constraint of each node, and the capacity constraint of each node (i.e., the number of instances that can be placed), and can also include the constraint of the number of instances of the same tenant on each node. The goal of the primary scheduling stage can be to balance the load between nodes, balance the number of instances of the same tenant in different availability zones, and reduce the number of nodes opened, etc. The goal of the secondary scheduling stage can be to balance the load between nodes, balance the number of instances of the same tenant in different availability zones, reduce the number of cross-availability-zone migrations, and reduce the number of nodes opened, etc. The goals and constraints are mathematically symbolized to construct an integrated mathematical model including the primary scheduling stage and the secondary scheduling stage:
[0092] where Θ represents a set of tenants, and I represents a set of instances of tenant I. kji = 1 indicates that instance i is placed in node j of AZ k. For the primary scheduling stage and added instances, X kji=0. γ represents the cost coefficient for balancing the number of instances of the same tenant across different Availability Zones (AZs), ε represents the cost coefficient for relocation within an AZ, and ω represents the cost coefficient for relocation across AZs. c ti m represents the processor resource usage of instance i at time t. ti This represents the memory resource usage of instance i at time t. kj Indicates AZ k The maximum number of instances that node j can hold, C kj Indicates AZ k Maximum processor usage percentage of node j, M kj Indicates AZ k The maximum memory usage percentage for node j. T is the total time slice, K is the total number of instances per tenant, and N is the number of nodes in a single availability zone. These parameters are known, while x... kji and α ti As a variable, x kji =1 indicates that instance i is placed in AZ. k In node j, α ti This represents the resource usage of instance i at time t, which is the sum of processor resource usage and processor resource usage.
[0093] Theoretical derivation of the above model yields the following two conclusions. First, for a new instance, placing it on an already used physical machine will increase the objective function value by less than placing it on a new physical machine (the smaller the objective function value, the better). Therefore, it can be concluded that the fewer physical machines used, the better. Second, if an instance is placed on an already used physical machine j, the lower the load on that physical machine at time t, the smaller the increase in the objective function at time t. Therefore, it can be concluded that when all physical machines are loaded (i.e., have instances placed on them), the instance should be placed on a physical machine with a lower load.
[0094] Based on the above conclusions, the resource allocation method provided in this application is described below with reference to Figure 3. As shown in Figure 3, this is a schematic diagram of an embodiment of the resource allocation method provided in this application, which includes steps 301 to 308.
[0095] 301. Obtain historical operation data for multiple tenants, including the resource consumption of each tenant during historical operation.
[0096] The embodiment shown in FIG. 3 is a one-time scheduling stage, i.e., the cloud service is in an initialization state to place instances of multiple tenants. At this time, the historical running data of each tenant in the multiple tenants is first obtained, and the historical running data records the resource occupancy of each tenant in the historical running process. For example, the resource occupancy of each tenant in multiple running periods is obtained, each running period is a period of time arbitrarily selected from the historical running process, and the average value of the resource occupancy of multiple running periods is taken as the resource occupancy of the tenant. The resource occupancy of a tenant includes the resource occupancy of multiple instances of the tenant on each node where the instances are located. The resource occupancy is the usage of resources, including the occupancy of processor resources and the occupancy of memory resources.
[0097] In one possible solution, the tenant has used the cloud service before, and the historical running data of the tenant can be directly obtained from the database. In another possible solution, the tenant is a new user, and the tenant is placed on a test node for trial operation for a period of time, so as to obtain the historical running data of the tenant. Alternatively, the tenant provides historical running data when applying for the cloud service, and the historical running data is obtained from the data provided by the tenant.
[0098] 302, calculate a first number based on the historical running data, the first number being the number of nodes required by the multiple tenants.
[0099] The number of nodes required by the multiple tenants in total is estimated based on the resource usage of each tenant. In calculating the first number, the number of instances of each tenant, the total number of instances of the multiple tenants, the processor resource and memory resource of each node, the number of instances that can be accommodated by each node, and the number of instances of the same tenant that can be accommodated by each node, etc. can also be combined to calculate, so as to obtain a more accurate number of nodes.
[0100] 303, determine multiple availability zones, the multiple availability zones being used to place instances of the multiple tenants, and each availability zone in the multiple availability zones including multiple nodes.
[0101] The availability zones used to place the current multiple tenant instances are determined from the available availability zones, each availability zone including a plurality of nodes, and each node being able to place one or more instances. In one possible solution, the resource allocation device receives an instruction of an operator or a maintenance personnel, and the instruction indicates multiple availability zones, which are the availability zones used to place the current tenant instances. Alternatively, the resource allocation device can also select the multiple availability zones according to the running situation. For example, multiple availability zones with lower load and fewer instances placed are selected from the plurality of availability zones to place the current multiple tenant instances.
[0102] 304. allocate the nodes required by the plurality of tenants to each of the plurality of availability zones based on the first number, to obtain the turned-on nodes of each availability zone, and the difference of the number of turned-on nodes between different availability zones is less than or equal to 1.
[0103] The number of availability zones is determined according to step 303, and the nodes required by the plurality of tenants are allocated to each availability zone determined in step 303 based on the first number and the number of availability zones. The nodes allocated to each availability zone are the nodes that need to be turned on, and the other nodes in the availability zone can not be turned on at first. The allocation rule is that the difference of the number of nodes allocated to different availability zones is less than or equal to 1, in other words, the difference of the number of turned-on nodes between different availability zones is less than or equal to 1.
[0104] The difference less than 1 means that the number of turned-on nodes of each availability zone is the same, that is, the nodes required by the plurality of tenants are evenly allocated to each availability zone. For example, the first number is 9, that is, 9 nodes are required, and the number of availability zones is 3, then the number of turned-on nodes of each availability zone is 9 / 3 = 3. The difference equal to 1 is the case of uneven distribution, that is, the first number cannot be divided by the number of availability zones. In this case, there are two cases: the first number is greater than the number of availability zones, and the first number is less than the number of availability zones. When the first number is greater than the number of availability zones, the part that can be evenly divided is evenly allocated first, and the remaining part (i.e. the remainder) is allocated to each availability zone one by one, so that the number of turned-on nodes of the availability zones without the remainder is the same (the difference is less than 1), the number of turned-on nodes of the availability zones with the remainder is also the same, and the difference of the number of turned-on nodes between the availability zones without the remainder and the availability zones with the remainder is 1. For example, the first number is 11, and the number of availability zones is 3. After allocating 3 nodes to each availability zone, there are 2 nodes left, so any two availability zones are turned on with one node each. That is, the number of turned-on nodes of 2 availability zones is 4, and the number of turned-on nodes of the other availability zone is 3. When the first number is less than the number of availability zones, the first number is equivalent to the remainder, and the nodes of the first number are allocated to the plurality of availability zones one by one. That is, the availability zone of the first number turns on 1 node, and the remaining availability zones do not turn on nodes. For example, the first number is 2, and the number of availability zones is 3, so any two of the 3 availability zones turn on one node, and the other availability zone does not turn on nodes at first.
[0105] According to the estimated first number, the number of turned-on nodes of each availability zone is configured, which can reduce the number of turned-on nodes as much as possible, improve the utilization rate of nodes, and save operation cost. Moreover, the number of turned-on nodes of each availability zone is evenly allocated as much as possible according to the first number, so as to balance the number of nodes of each availability zone, and lay a foundation for realizing load balancing between availability zones.
[0106] 305、allocate the instances of each tenant to each of the plurality of availability zones, a difference between the number of instances of each tenant allocated to different availability zones is less than or equal to 1.
[0107] After determining the number of nodes opened in each availability zone, the instances of each tenant are allocated to each availability zone based on the number of availability zones and the number of nodes opened in each availability zone, and the allocation rule is that the difference between the number of instances of each tenant allocated to different availability zones is less than or equal to 1, so as to achieve the allocation of the instances of each tenant to each availability zone as evenly as possible. When the difference is less than 1, it is the case of average allocation, and the number of instances of each tenant allocated to each availability zone is the same. For example, the first tenant includes 6 instances, and the number of availability zones is 3, so the number of instances of the first tenant allocated to each availability zone is 6 / 3 = 2, and each availability zone allocates two instances of the first tenant.
[0108] When the difference is equal to 1, it is for the case of uneven allocation. Specifically, it can be divided into two cases: the number of instances of the same tenant is greater than the number of availability zones, and the number of instances of the same tenant is less than the number of availability zones. When the number of instances of the same tenant is greater than the number of availability zones, the part that can be evenly divided is allocated first, and the remaining part (i.e. the remainder) is allocated to each availability zone one by one. For example, the first tenant includes 4 instances, and the number of availability zones is 3, so each availability zone allocates one instance first, and the remaining one instance can be allocated to any one of the 3 availability zones, or it can be allocated in combination with the number of nodes opened in each availability zone. If the number of nodes opened in each availability zone is the same, the remaining one instance is allocated to any one of the 3 availability zones. If the number of nodes opened in each availability zone is different, the remaining instance is preferentially allocated to the availability zone with more opened nodes. Alternatively, the allocation can also be combined with the allocation of instances of other tenants, and the remaining instance is preferentially allocated to the node with less total number of instances (i.e. the sum of the instances allocated by each tenant) at present. For example, the total number of instances allocated to AZ1 is 10, and the total number of instances allocated to AZ2 is 9, so the remaining one instance is allocated to AZ2. Finally, two availability zones allocate 1 instance of the first tenant respectively, and the other availability zone allocates two instances of the first tenant.
[0109] When the number of instances of the same tenant is less than the number of availability zones, the instances of the tenant are allocated to the plurality of availability zones one by one. For example, the number of instances of the first tenant is 2, and the number of availability zones is 3, so two availability zones each allocate one instance, and the other availability zone does not allocate instances. When determining to which two availability zones to allocate instances, the number of nodes opened in the availability zones can be considered, and the total number of instances currently allocated to the availability zones can also be considered, which is similar to the case where the number of instances of the same tenant is greater than the number of availability zones, and details are not repeated here.
[0110] In one possible solution, each tenant's instances are allocated to each availability zone by an improved load-balancing first fit (LBFF) algorithm, such that the difference between the number of instances of the same tenant allocated to different availability zones is less than or equal to 1, which can be understood in combination with FIG. 4. FIG. 4 includes three availability zones, and the shaded boxes are instances of tenant 1, which includes four instances. The blank boxes are instances of tenant 2, which includes three instances. The allocation is performed for each tenant one by one, i.e., first for tenant 1 and then for tenant 2. The order of allocation of the instances can also be considered as the order of placement of the instances, i.e., the instances of tenant 1 are placed first and then the instances of tenant 2. The LBFF algorithm allocates (places) the instances of each tenant to the availability zones one by one, and allocates them in the order from the beginning to the end and then from the end to the beginning, as indicated by the arrows. Specifically, the first instance of tenant 1 is allocated to AZ1, the second instance is allocated to AZ2, the third instance is allocated to AZ3, and the fourth instance is also allocated to AZ3. Then, from AZ3 to AZ1, the first instance of tenant 2 is allocated to AZ2, and the second instance is allocated to AZ1. According to the allocation order, the third instance should also be allocated to AZ1, but if it is allocated to AZ1, AZ1 has two instances of tenant 2, and AZ3 has no instance of tenant 2, the difference between the number of instances of tenant 2 allocated to AZ1 and AZ3 is greater than 1, which does not meet the requirement, so the third instance is allocated to AZ3.
[0111] The LBFF algorithm for allocating tenant instances to availability zones can be referred to as an outer LBFF algorithm, and the pseudo code can be referred to FIG. 5. As shown in FIG. 5, some constraints are first set, such as the maximum processor occupancy percentage of each node, the maximum memory occupancy capacity, and the upper limit of the number of instances that can be accommodated. In addition, the processor occupancy and the memory occupancy of each instance, the total time slice, the placement order of the instances, and the nodes started in each availability zone can also be included. The constraints are taken as input, and the corresponding instance placement strategy x is output. The first to fifth lines of the code are the initialization steps, and the sixth to nineteenth lines are the steps of allocating tenant instances to each availability zone. Among them, the sixth to tenth lines are the normal placement order of tenant instances, i.e., from the beginning to the end and then from the end to the beginning. The eleventh and twelfth lines are to change the placement order so that the allocation of tenant instances meets the allocation requirement.
[0112] In addition to the allocation order of the LBFF algorithm described above, the instances of the tenants can also be allocated to each available zone in various allocation orders if the allocation requirements are met. For example, the instances of the tenants are placed in each available zone in turn. For example, the allocation is in the order of AZ1, AZ2, and then AZ3 for three available zones. After the allocation to AZ3, the allocation is restarted in this order from AZ1. In this allocation order, the placement order can not be changed in the middle. In addition to placing the instances one by one, after determining the number of instances allocated to each available zone, the corresponding number of instances can be placed in each available zone. For example, tenant 1 has 4 instances, and it is determined that 2 instances are allocated to AZ1, and 1 instance is allocated to AZ2 and AZ3. Then, 2 instances are placed in AZ1 directly, and then 1 instance is placed in AZ2 and AZ3, respectively. Alternatively, 2 instances are allocated to AZ2, and 1 instance is allocated to AZ1 and AZ3. After placing 1 instance in AZ1, 2 instances are placed in AZ2, and then 1 instance is placed in AZ3.
[0113] 306、determining the number of instances of the plurality of tenants allocated to the first available zone based on the number of instances of each tenant allocated to each available zone, the first available zone being any one of the plurality of available zones.
[0114] After determining the number of instances of each tenant allocated to each available zone, the total number of instances allocated to each available zone can be obtained, and the available zones include the first available zone. For example, there are 3 tenants, tenant 1 allocates 2 instances in the first available zone, tenant 2 allocates 3 instances in the first available zone, and tenant 3 allocates 1 instance in the first available zone, and the total number of instances allocated to the first available zone is 2+3+1=6.
[0115] 307、placing the instances of the plurality of tenants allocated to the first available zone on the started nodes of the first available zone based on the number of instances of the plurality of tenants allocated to the first available zone, the difference between the number of instances placed on different nodes of the started nodes of the first available zone being less than or equal to 1.
[0116] The instances of the plurality of tenants allocated to the first available zone are placed on the started nodes of the first available zone, and the placement rule (i.e., the allocation rule) is that the difference between the number of instances placed on different nodes is less than or equal to 1. The difference is less than 1, which is the case of average allocation, and the number of instances placed on each started node is the same. For example, the plurality of tenants are allocated 6 instances in the first available zone, and the first available zone includes 3 started nodes, so each node is placed with 6 / 3=2 instances.
[0117] The difference equal to 1 is for the case that the total instances cannot be evenly distributed, that is, the total instances allocated to the first availability zone cannot be divided by the number of the nodes started in the first availability zone. At this time, it can be divided into two cases: the total instances are less than the number of the started nodes and the total instances are greater than the number of the started nodes. When the total instances are greater than the number of the started nodes, the instances that can be divided are evenly distributed to each started node, and the remaining nodes (i.e., the remainder) are distributed to the started nodes one by one. For example, a plurality of tenants are allocated 8 instances in the first availability zone, and the first availability zone includes 3 started nodes, then each node is allocated two instances, and the remaining two instances are allocated to two nodes respectively. When the total instances are less than the number of the started nodes, the instances are placed on the started nodes of the first availability zone one by one.
[0118] In one possible solution, the mutual exclusion constraint of each tenant is also considered when the instances are allocated to the started nodes. The mutual exclusion constraint means that in order to ensure the safety of the assets of each tenant, as few instances of the same tenant as possible should be placed on one node, that is, the instances of each tenant should be allocated to multiple nodes when allocating. For example, 3 tenants are allocated 6 instances in the first availability zone, and the first availability zone starts 3 nodes, then each node is allocated 2 instances. Among them, each tenant includes 2 instances, when the mutual exclusion constraint is not considered, the two instances of each tenant can be placed on the same node. When the mutual exclusion constraint is considered, the two instances of each tenant should be placed on two nodes, for example, the two instances of tenant 1 are placed on node 1 and node 2 respectively, the two instances of tenant 2 are placed on node 2 and node 3 respectively, and the two instances of tenant 3 are placed on node 3 and node 1 respectively.
[0119] Optionally, the mutual exclusion constraint requires that the same tenant only places one instance on each node, thereby better protecting the safety of the assets.
[0120] When placing the instances, the instances can be placed on the nodes one by one, for example, instance 1 is placed on node 1, instance 2 is placed on node 2, and instance 3 is placed on node 3. Alternatively, a plurality of instances can be placed on a node, and then another node is placed, for example, five instances are allocated to node 1, then the five instances are placed on node 1, and then the instances are placed on node 2.
[0121] For the placement order of multiple tenants, generally, the instances of one tenant are placed first, and then the instances of another tenant are placed, for example, two instances of tenant 1 are allocated to the first availability zone, and then the instances of tenant 2 are placed after the two instances of tenant 1 are placed. Of course, one instance of tenant 1 can be placed first, and then one instance of tenant 2 is placed, and then another instance of tenant 1 is placed after one instance of each of the multiple tenants is placed. In addition, the specific placement order can be considered in combination with multiple availability zones. For example, tenant 1 includes four instances, three instances are placed in three availability zones, and two instances are allocated to the first availability zone. Then, one instance is placed on node 1 of the first availability zone first, and then one instance is placed on each of the nodes of the other two availability zones, and then the last instance of tenant 1 is placed on node 2 of the first availability zone. After the instances of tenant 1 are placed, the instances of tenant 2 are placed, and the instances of tenant 2 are placed on the multiple availability zones one by one, and in each availability zone, the instances are also placed on the multiple nodes one by one.
[0122] In a possible solution, the instances are placed in combination with the resource occupancy of each instance included in the historical running data. Specifically, the multiple instances of each tenant are arranged in descending order according to the resource occupancy, and the instances with more resource occupancy are preferentially placed.
[0123] The placement of tenant instances can also be achieved by the LBFF algorithm, and the specific process can be understood in combination with FIG. 6. FIG. 6 includes six nodes, and each node can place six instances. The placement order of the LBFF algorithm is shown by arrows in FIG. 6, that is, the instances are placed from node 1 to node 6, and then from node 6 to node 1. For example, the placement order of instance A is the fourth, and since the current placement order is from node 1 to node 6, it is assumed that the first three nodes (node 1 to node 3) have placed instances, and the access starts from node 4 to determine whether the instance can be placed, for example, the instance cannot be placed when a mutual exclusion constraint is generated. If node 4 cannot place the instance, the access continues in the order of arrow line ① to determine whether node 5 and node 6 can place the instance. If neither node 5 nor node 6 can place the instance, the access continues in the order of arrow line ② to determine whether node 3, node 2, and node 1 can place instance A. The placement order of instance B is the ninth, and since the current placement order is from node 6 to node 1, it is assumed that node 6 and node 5 have placed instances, and the access starts from node 4 to determine whether the instance can be placed. If node 4 cannot place the instance, the access continues in the order of arrow line ③ to determine whether node 3, node 2, and node 1 can place the instance. If neither node 3 to node 1 can place the instance, the access continues in the order of arrow line ④ to determine whether node 5 and node 6 can place instance B.
[0124] The LBFF algorithm that assigns tenant instances to nodes can be called the inner LBFF algorithm, and the pseudocode can be found in Figure 7. As shown in Figure 7, some constraints are first set, such as the number of nodes already enabled, the total number of instances allocated to the availability zone, the maximum processor utilization percentage of each node, the maximum memory utilization of each node, the maximum number of instances that each node can accommodate, the actual processor utilization, the actual memory utilization, and the total time slice. These constraints are taken as input, and the output is the specific node where the instance is placed. In the algorithm shown in Figure 6, lines 3 to 8 are used to place instances on nodes, and lines 3 and 4 define the node access order.
[0125] 308. When multiple tenant instances cannot be placed on the open nodes in multiple availability zones, calculate a second quantity based on the number of unplaced instances, and allocate newly opened nodes in each availability zone based on the second quantity.
[0126] The number of nodes calculated in step 302 may deviate from the actual number. When the number of active nodes is insufficient to accommodate the tenant's instances, additional nodes need to be added. Specifically, the number of additional nodes required (i.e., the second number) is calculated based on the number of unplaced instances. The calculation can also incorporate parameters such as the processor and memory resources of each node, the number of instances each node can accommodate, and the number of instances of the same tenant that each node can accommodate (mutual exclusion constraints) to obtain a more accurate number.
[0127] After calculating the second quantity, the newly opened nodes for each availability zone are allocated based on this second quantity. The allocation rule is that the difference in the number of newly opened nodes between different availability zones is less than or equal to 1. A difference less than 1 indicates an even allocation, where each availability zone has the same number of newly opened nodes. For example, if the second quantity is 6 and there are 3 availability zones, then each availability zone will have two new nodes. A difference equal to 1 indicates a non-even allocation, meaning the number of new nodes (the second quantity) cannot be divided evenly by the number of availability zones. Specifically, this can be divided into two cases: the second quantity is less than the number of availability zones, and the second quantity is greater than the number of availability zones. When the second quantity is greater than the number of availability zones, the divisible portion is first evenly allocated, and then allocated one node at a time based on the remainder. For example, if the second quantity is 8 and there are 3 availability zones, each availability zone will first have two new nodes opened, and then any two availability zones will each have one additional node added. When the second quantity is less than the number of availability zones, the second quantity is always considered a remainder, and the nodes of the second quantity are allocated one by one to the multiple availability zones.
[0128] In the embodiment, the number of nodes to be started (the first number) is estimated according to the historical resource occupancy of the tenant instance, so as to reduce the number of started nodes and save operation cost. Then, the number of started nodes in each availability zone is distributed as evenly as possible according to the first number, and the instances of each tenant are distributed to each availability zone as evenly as possible, so that the number of started nodes in each availability zone is approximately equal, and the number of instances of each tenant distributed to each availability zone is also approximately equal, thereby realizing load balancing among the availability zones and balancing the number of instances of each tenant in different availability zones. Finally, the instances of multiple tenants are distributed to each started node in the availability zone as evenly as possible, so that the number of instances distributed to each started node in the availability zone is approximately equal, thereby realizing load balancing among the nodes in the availability zone.
[0129] Optionally, the embodiment formulates the placement order of the instances when distributing the instances of each tenant to each availability zone and distributing the instances of multiple tenants to multiple nodes in the availability zone, so that the instance placement scheme can be obtained more quickly.
[0130] The embodiment shown in FIG. 3 is a one-time scheduling stage, which will be described in general below with reference to the block diagram shown in FIG. 8. As shown in FIG. 8, the embodiment includes steps 801 to 804.
[0131] 801, calculate the number of nodes to be used (i.e. the first number), and distribute the number of started nodes in each availability zone as evenly as possible according to the first number, and the distribution rule is that the number of started nodes in each availability zone is the same or the difference is 1. Optionally, the first number is the minimum number of nodes required by the instances of each tenant, that is, the first number is the lower bound of the number of started nodes.
[0132] 802, arrange the resource occupancy of the tenant instance in descending order. It can be understood that steps 801 and 802 have no execution sequence, that is, step 801 can be executed first or step 802 can be executed first.
[0133] 803, place the tenant instance on the started nodes in each availability zone by using the double-layer LBFF algorithm. The double-layer LBFF algorithm is the outer-layer LBFF algorithm and the inner-layer LBFF algorithm described in the embodiment shown in FIG. 3. The instances of multiple tenants are distributed to each availability zone one by one by using the outer-layer LBFF algorithm, and then the instances distributed to each availability zone are placed on each started node in the availability zone by using the inner-layer LBFF algorithm.
[0134] 804、determining whether the double-layer LBFF algorithm has a solution, if yes, it means that the instances of each tenant have been placed, and the scheduling process is ended. If no, it means that the number of opened nodes is not enough, and step 801 is executed to calculate the number of nodes required by the remaining instances (i.e., the second number), and the number of nodes required by the instances is updated based on the second number. Optionally, the second number is the minimum number of nodes required by the remaining instances, and the lower bound of the number of opened nodes is updated based on the second number. After the number of required nodes is updated in step 801, step 803 is executed again to place the remaining instances on the nodes by the LBFF algorithm.
[0135] Please refer to FIG. 9 for another embodiment of a scheduling stage. As shown in FIG. 9, the resource allocation device includes a cluster controller, which includes a data plane and a control plane. The data plane includes a data storage module, from which historical running data can be obtained. The control plane includes a resource prediction module, an optimizer module and a cluster scheduling module, through which the placement of tenant instances is realized. Specifically, a tenant and the historical running data of the tenant are input into the cluster control module, and the historical running data of the tenant is recorded through the data storage module. The historical running data includes the resource occupation of the tenant in the historical running process, and specifically can be the resource occupation of the tenant in N running periods, each running period being any period of running time. In addition to the relevant data of the tenant, some initial parameters can also be input, for example, which available zones are included, which nodes in the available zones can be used, the upper limit number of instances of the same tenant that each node can accommodate, etc.
[0136] The control plane includes a resource prediction module, an optimizer module and a cluster scheduling module. The resource prediction module predicts the resource occupancy of each tenant instance in a new period according to historical running data recorded in the data plane, and calculates the number of nodes (i.e. the first number) to be started according to the predicted resource occupancy. Then the optimizer module allocates the number of nodes to be started in each availability zone as evenly as possible according to the first number, and the allocation rule is that the number of nodes to be started in each availability zone is the same or the difference is 1. The availability zones that can be used are determined by the initial parameters input, and the nodes to be started in each availability zone are also selected from the nodes set by the initial parameters. Then the tenant instances are allocated to each availability zone as evenly as possible, and the allocation rule is that the difference in the number of instances allocated to each tenant in different availability zones is less than or equal to 1. Furthermore, the instances allocated to each availability zone are allocated to the nodes to be started as evenly as possible, and the allocation rule is that the difference in the number of instances allocated to different nodes is less than or equal to 1, so as to obtain the arrangement scheme of the tenant instances. The optimizer module outputs the arrangement scheme, and the cluster scheduling module schedules the tenants according to the arrangement scheme, that is, places the instances of each tenant on the nodes in each availability zone. The placement of the instances can be displayed on the management interface on the one hand, and is fed back to the cluster controller on the other hand, so as to update the historical running data of the tenants and record them in the data storage module.
[0137] When running for a period of time, the running conditions of the instances of each tenant will change. For example, some tenants will add some instances, or some tenants will delete some instances. Or the resource occupancy of the instances changes, resulting in uneven load among the nodes, some nodes may have a large amount of resource left, and some nodes may have a shortage of resources or even be overloaded. Therefore, the arrangement scheme of the tenant instances needs to be adjusted and optimized, that is, the secondary scheduling stage of the tenant instances.
[0138] The secondary scheduling stage will be described in combination with FIG. 10 with reference to the content of the embodiment shown in FIG. 3. As shown in FIG. 10, another embodiment of the resource allocation method provided by the embodiment of the present application is shown, which includes steps 1001 and 1002.
[0139] 1001, screening the instances to be relocated.
[0140] The overloaded nodes are screened from the nodes to be started in each availability zone, and the instances in the overloaded nodes are migrated. Specifically, the first node is included in the nodes to be started in the first availability zone, and it is judged whether the first node is overloaded. If the first node is overloaded, the instances in the first node are relocated to other nodes.
[0141] In a possible solution, considering the migration cost, the number of migrations is reduced as much as possible, and therefore instances with large resource occupancy are selected first. Compared with instances with small resource occupancy, the first node can achieve no overload after migrating a smaller number of instances, thereby reducing the number of migrations. Specifically, the resource occupancy of a plurality of instances placed on the first node is obtained, the plurality of instances are arranged in descending order according to the resource occupancy, and K instances with the highest resource occupancy are selected from the plurality of instances, so that the first node can satisfy the load constraint after migrating the K instances, that is, the first node will not be overloaded after migrating the K instances. Optionally, the first node is still overloaded after migrating K-1 instances with the highest resource occupancy, and can just satisfy the load constraint after migrating the K instances, and K is the minimum number of migrations that satisfies the condition.
[0142] 1002、Migrating the K instances from the first node to the second node.
[0143] After determining the K instances to be migrated, the K instances are migrated from the first node to the second node, and the second node still satisfies the load constraint after migrating the K instances.
[0144] Optionally, the second node is also a node started in the first availability zone, that is, the K instances are migrated in the first availability zone. The second node can include a plurality of nodes, that is, the K instances are migrated to a plurality of started nodes in the first availability zone, and the plurality of started nodes all satisfy the load constraint after placing the K instances. During migration, instances with large resource occupancy are migrated first, that is, the K instances are placed on the second node one by one based on the resource occupancy sorting. When the second node includes a plurality of nodes, the plurality of nodes can also be sorted based on the remaining resources, and the instances are preferentially migrated to nodes with more remaining resources.
[0145] The migration process of the K instances can be understood in combination with FIG. 11. As shown in FIG. 11, the first availability zone includes the first node and the second node, and the dashed line represents the maximum resource of the node. The resource occupancy of the instance is greater, that is, the resource occupancy of the instance 1 in the first node is the largest. It can be known from FIG. 11 that the first node is overloaded, and the second node has a large resource surplus, so the instance 1 in the first node is migrated to the second node, and both nodes satisfy the load constraint after migration.
[0146] The algorithm for migrating instances within an availability zone can refer to FIG. 12. As shown in FIG. 12, some constraints are input first, such as the specified availability zone, the tenant instance, the maximum processor occupancy percentage and the maximum memory occupancy of each node, the upper limit of the number of instances that each node can accommodate, the processor occupancy and the memory occupancy of the instance, and the total time slice, etc. The constraints are input as input, and the instances to which the nodes should be migrated are output. In the algorithm shown in FIG. 12, the migration of tenant instances is implemented by code lines 1 to 5.
[0147] Optionally, the availability zone further includes a second availability zone, and the second node is a node started in the second availability zone, that is, the K instances are migrated across availability zones. Compared with the intra-availability zone migration, the cross-availability zone migration consumes more cost.
[0148] Optionally, in addition to migrating the K instances to other started nodes, one or more nodes can be started, and the K instances are migrated to the started nodes. Moreover, the nodes can be newly started within the availability zone, or the nodes can be newly started across the availability zones. Specifically, a second node is started in the first availability zone or the second availability zone. After the second node is started, the K instances are migrated to the second node.
[0149] Optionally, the intra-availability zone migration of instances consumes lower cost, and therefore, the migration is preferentially performed within the availability zone. If the remaining nodes within the availability zone do not have sufficient resource margins, then the cross-availability zone migration or the newly added nodes are considered.
[0150] In summary, the secondary scheduling stage is described below in combination with FIG. 13. As shown in FIG. 13, the embodiment includes steps 1301 to 1306.
[0151] 1301, screening the overloaded nodes, and screening the instances that need to be migrated from the nodes.
[0152] 1302, searching whether there is a node that can perform instance migration within the availability zone.
[0153] 1303, judging whether the node that can perform migration is searched within the availability zone, if yes, step 1304 is performed, and if no, step 1305 is performed.
[0154] 1304, migrating the screened instances to the searched node.
[0155] 1305, searching the node that can perform migration across the availability zones, or newly starting a node within the availability zone or a node across the availability zones.
[0156] 1306, judging whether there is an instance that needs to be migrated, if yes, step 1303 is continuously performed, and if no, the secondary scheduling process is ended.
[0157] Please refer to FIG. 14 for another embodiment of the second scheduling stage. Similar to the first scheduling stage, the second scheduling stage also implements the placement of tenant instances through the cluster controller. Specifically, the newly added instances and the historical running data of the newly added instances are input into the cluster controller and recorded by the data storage module. In addition, the current parameter settings are input, and the data storage module updates the initial parameters input in the first scheduling stage according to the current parameter settings. The data storage module also obtains the current running data to determine the deleted instances and the resource occupation of the running instances. The data storage module transmits the newly added instances, the deleted instances and the resource occupation of each instance to the resource prediction module, and the resource prediction module screens out the instances that need to be relocated and determines whether there are nodes in the availability zone that can be migrated, whether new nodes need to be added, etc. The optimizer module outputs a new tenant arrangement scheme, such as where to place the newly added instances, where to relocate the instances in the availability zone, where to relocate across availability zones or to newly added nodes, etc. The cluster scheduling module adjusts the placement of tenant instances according to the tenant arrangement scheme, adds or deletes some instances, and schedules tenants, i.e., relocates tenant instances. The updated instance placement can be displayed on the management interface on the one hand, and on the other hand, the historical running data of the tenants is updated and recorded in the data storage module.
[0158] In one possible solution, the embodiments of the present application provide a management interface, which can be seen in FIG. 15a and FIG. 15b. As shown in FIG. 15a, the operator can set parameters in the management interface, such as which availability zones are used to place the instances of the current tenant, the number of availability zones to be turned on, which nodes in the availability zone can be used, the upper limit of the number of nodes to be turned on, the number of instances that each node can accommodate, and the upper limit of the number of instances of the same tenant that each node can accommodate, etc. After setting the parameters in the management interface, a second instruction is generated and sent to the resource allocation device. The resource allocation device allocates the turned-on nodes to the specified availability zones based on the calculated number of nodes required by the plurality of tenants, and the turned-on nodes are also selected from the nodes indicated by the second instruction. Then, the instances of each tenant are placed on the turned-on nodes of each availability zone in combination with the second instruction, such as determining the specific placement scheme in combination with the upper limit of the number of instances that each node can accommodate and the upper limit of the number of instances of the same tenant that each node can accommodate. When the number of nodes set is not enough, a prompt message is sent and displayed in the management interface, reminding the operator to change the parameter settings.
[0159] As can be seen from FIG. 15a, the operator can also set the priority of the optimization target of the secondary scheduling stage in the management interface. The optimization target includes keeping the load balance among multiple availability zones, reducing the number of instance migration across availability zones, and reducing the number of newly added nodes. The instance migration scheme is different when the optimization target is different. When the priority of keeping the load balance among multiple availability zones is the highest, the load balance among availability zones is guaranteed first. To guarantee the load balance, instance migration across availability zones or newly added nodes across availability zones can be performed. When the priority of reducing the number of instance migration across availability zones is the highest, instance migration within an availability zone is performed first. When there is no node in the availability zone that can be migrated, a node is added in the availability zone. When the priority of reducing the number of newly added nodes is the highest, instance migration within an availability zone is performed first. When there is no node in the availability zone that can be migrated, instance migration across availability zones is performed. When setting the priority, a first priority, a second priority, and a third priority can be set. As shown in FIG. 15a, the load balance is the first priority, the number of instance migration across availability zones is the second priority, and the number of newly added nodes is the third priority. In addition to the above optimization targets, some other optimization targets can also be used, for example, reducing the total load value, increasing the number of instance migration within an availability zone, and reducing the number of newly added nodes across availability zones. After the operator sets the priority of the optimization target in the management interface, the first instruction is generated, and the resource allocation device determines the specific instance migration scheme in combination with the first instruction.
[0160] As shown in FIG. 15b, after the resource allocation device generates the placement scheme of the tenant instance, the distribution of the tenant instance can be presented in the management interface, that is, which availability zone and which node in the availability zone the tenant instance is placed in. In addition, the resource allocation device can quantify the resource occupation of each node and display it in the management interface. The resource occupation includes the occupation of the processor and the occupation of the memory. The distribution of the instance and the resource occupation of the node displayed in the management interface can have a load preview effect, thereby assisting the operator in decision-making.
[0161] The beneficial effects of the resource allocation method provided in the embodiments of the present application will be described below with reference to FIGS. 16a, 16b, 16c, and 16d.
[0162] FIG. 16a and FIG. 16b are diagrams of running conditions of a first scheduling stage. FIG. 16a is a diagram of running conditions of placing instances in a single available zone. As shown in FIG. 16a, the column of theoretical lower bound in the table of data set 1 and data set 2 is the objective function calculated by a data model, and the column of LBFF-DICH represents the difference between the scheme adopted in the embodiment of the present application and the theoretical lower bound. As can be seen from the diagram, the difference is very small and close to the theoretical lower bound, which indicates that the embodiment of the present application achieves good results. The column of average FF algorithm is the time required by the scheme in different numbers of physical machines (i.e. full tenant ratio) when the average FF algorithm is adopted, and the column of average random algorithm is the time required by the scheme in different numbers of physical machines when the average random algorithm is adopted. The coordinate diagram of FIG. 16a is the time required by the scheme adopted in the embodiment of the present application in different numbers of physical machines. As can be seen from the diagram, the time required by the scheme of data set 1 and data set 2 in different full tenant ratios is less than 70 seconds, which is greatly reduced compared with the several minutes to tens of minutes in the average FF algorithm and the average random algorithm, and prompts the placement efficiency.
[0163] FIG. 16b is a diagram of running conditions of placing tenant instances in multiple available zones. As can be seen from FIG. 16b, in the case of different instances and different numbers of tenants, the number of instances carried by each available zone is approximately equal, and the number of nodes used by each available zone is also approximately equal, that is, the load balancing between available zones is achieved.
[0164] FIG. 16c and FIG. 16d are diagrams of running conditions of a second scheduling stage. As can be seen from FIG. 16c, after the instances are relocated within the available zone and across the available zones, the number of instances carried by each available zone is still approximately equal, the number of nodes used by each available zone is also approximately equal, and the usage rate of nodes in each available zone is also close, that is, after the second scheduling using the resource allocation method provided in the embodiment, the load balancing between available zones can still be achieved.
[0165] Fig. 16d is an example of instance migration scheme when different optimization objectives are selected. "Load more balanced, more cross-AZ migration" is an instance migration scheme with higher priority of load balancing. As can be seen from the figure, in the first working condition (i.e. the working condition of 655 tenants), 180 instances are migrated within AZ, 1 node is added within AZ, 137 instances are migrated across AZ, and 4 nodes are added across AZ. "Less cross-AZ migration, relatively unbalanced load" is an instance migration scheme with higher priority of reducing the number of instances migrated across AZ. As can be seen from the figure, in the first working condition, 316 instances are migrated within AZ, 6 nodes are added within AZ, and both the number of instances migrated across AZ and the number of nodes added across AZ are 0. That is, compared with the scheme with high priority of load balancing, this scheme has more instances migrated within nodes and more nodes added, but does not migrate across AZ or add nodes across AZ, thereby reducing the number of migrations across AZ, which also causes the load of the original AZ to be relatively high. "Fewer cross-AZ added nodes" is an instance migration scheme with higher priority of reducing the number of added nodes. As can be seen from the figure, in the first working condition, 164 instances are migrated within the original AZ, 5 nodes are added within the original AZ, 152 instances are migrated across AZ, and 0 nodes are added across AZ. That is, compared with the first two migration schemes, this scheme migrates instances within AZ and across AZ, and the number of migrated instances is roughly the same, but does not add nodes across AZ, thereby reducing the number of added nodes across AZ while maintaining load balancing as much as possible.
[0166] The above describes the embodiments of the present application from the perspective of methods. The following introduces related devices in the embodiments of the present application from the perspective of specific device implementation.
[0167] Referring to Fig. 17, the embodiments of the present application provide a schematic diagram of a resource allocation device 1700. The resource allocation device 1700 includes an acquisition unit 1701, a calculation unit 1702, a determination unit 1703, an allocation unit 1704, and a placement unit 1705.
[0168] The acquisition unit 1701 is configured to acquire historical running data of a plurality of tenants, the historical running data including resource occupancy of each tenant of the plurality of tenants in a historical running process.
[0169] The calculation unit 1702 is configured to calculate a first number based on the historical running data, the first number being a number of nodes required by the plurality of tenants.
[0170] The determination unit 1703 is configured to determine a plurality of availability zones, the plurality of availability zones being used to place instances of the plurality of tenants, each availability zone of the plurality of availability zones including a plurality of nodes.
[0171] The distribution unit 1704 is configured to distribute the nodes required by the plurality of tenants to each of the plurality of available zones based on the first quantity, to obtain the started nodes of each of the plurality of available zones, and the difference between the number of the started nodes of different available zones is less than or equal to 1.
[0172] The distribution unit 1704 is further configured to distribute the instances of each tenant to each of the plurality of available zones, and the difference between the number of the instances of each tenant distributed to different available zones is less than or equal to 1.
[0173] The distribution unit 1704 is further configured to determine the number of instances of the plurality of tenants distributed to the first available zone based on the number of instances of each tenant distributed to each available zone, and the first available zone is any one of the plurality of available zones.
[0174] The placement unit 1705 is configured to place the instances of the plurality of tenants distributed to the first available zone on the started nodes of the first available zone based on the number of instances of the plurality of tenants distributed to the first available zone, and the difference between the number of instances placed on different nodes of the started nodes of the first available zone is less than or equal to 1.
[0175] Optionally, the started nodes of the first available zone include a first node, and the resource distribution apparatus 1700 further includes: a judgment unit 1706 configured to judge whether the first node is overloaded; an acquisition unit 1707 configured to acquire the resource occupation of a plurality of instances placed on the first node in a case where the first node is overloaded; and a migration unit 1708 configured to migrate K instances with a highest resource occupation from the plurality of instances to a second node, and the first node and the second node both satisfy the load constraint after the migration of the K instances.
[0176] Optionally, the migration unit 1708 is specifically configured to: select a second node from the first available zone, which still satisfies the load constraint after the placement of the K instances; and place the K instances on the second node one by one based on the resource occupation.
[0177] Optionally, the plurality of available zones further include a second available zone, and the second node is a started node of the second available zone.
[0178] Optionally, the plurality of available zones further include a second available zone, and the apparatus further includes: a starting unit 1709 configured to start a second node in the first available zone or the second available zone.
[0179] Optionally, the apparatus further includes a receiving unit 1710, configured to receive a first instruction, the first instruction being generated after an operator sets a priority of an optimization target through a management interface, the optimization target including keeping load balance among multiple availability zones, reducing a number of instances migrated across availability zones, and reducing a number of newly started nodes; and the migrating unit 1708 is specifically configured to migrate K instances with a highest resource occupation in the multiple instances to the second node according to the first instruction.
[0180] Optionally, the computing unit 1702 is further configured to calculate a second number of newly started nodes required by the multiple tenants based on a number of instances that are not placed in the started nodes of the multiple availability zones; and the allocating unit 1704 is further configured to allocate the newly started nodes required by the multiple tenants to each of the multiple availability zones based on the second number, and a difference between the number of newly started nodes in different availability zones of the multiple availability zones is less than or equal to 1.
[0181] Optionally, each of the started nodes is used to place only one instance of the same tenant.
[0182] Optionally, the receiving unit 1710 is further configured to receive a second instruction, the second instruction being generated after the operator sets a parameter through the management interface, the parameter including any one or more of the following: an availability zone, a number of availability zones, a node, an upper limit of the node, and a number of instances of the same tenant accommodated by each node; and the allocating unit 1704 is specifically configured to allocate the nodes required by the multiple tenants to each of the multiple availability zones based on the first number and in combination with the second instruction.
[0183] The modules in the resource allocation apparatus 1700 perform operations of the resource allocation apparatus as described in the foregoing embodiments of FIG. 3, FIG. 8 to FIG. 10, FIG. 13, and FIG. 14, and details are not described herein again.
[0184] Please refer to FIG. 18, which is a possible structural schematic diagram of a resource allocation apparatus 1800 provided by an embodiment of the present application, including a processor 1801, a communication interface 1802, a memory 1803, and a bus 1804. The processor 1801, the communication interface 1802, and the memory 1803 are connected with each other through the bus 1804. In an embodiment of the present application, the processor 1801 is configured to control and manage actions of the resource allocation apparatus, for example, the processor 1801 is configured to execute steps performed by the resource allocation apparatus in the method embodiment of FIG. 3. The communication interface 1802 is configured to support communication of the resource allocation apparatus. The memory 1803 is configured to store program codes and data of the resource allocation apparatus.
[0185] The processor 1801 can be a central processing unit, a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array, or other programmable logic device, transistor logic, hardware components, or any combination thereof, which can implement or execute the various exemplary logical blocks, modules, and circuits described in connection with the disclosure. The processor can also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and the like. The bus 1804 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in FIG. 18, but it does not mean that there is only one bus or only one type of bus.
[0186] The embodiments of the present application also provide a computer readable storage medium, which includes instructions, when the instructions are executed on a computer, cause the computer to perform the method in the embodiments shown in FIG. 3, FIG. 8 to FIG. 10, FIG. 13, and FIG. 14.
[0187] The embodiments of the present application also provide a computer program product including instructions, when the computer program product is executed on a computer, cause the computer to perform the method in the embodiments shown in FIG. 3, FIG. 8 to FIG. 10, FIG. 13, and FIG. 14.
[0188] The embodiments of the present application also provide a chip system, which includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is used to run a computer program or instructions to perform the method in the embodiments shown in FIG. 3, FIG. 8 to FIG. 10, FIG. 13, and FIG. 14.
[0189] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0190] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0191] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the described device embodiments are merely schematic. The division of the units is merely a logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0192] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments of the present application.
[0193] In addition, each functional unit in the embodiments of the present application can be integrated in one processing unit, or each unit can exist physically as a separate unit, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware, or in the form of a software functional unit.
[0194] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application essentially or substantially, or all or part of the technical solutions, can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), magnetic disk or optical disk, and various other media that can store program codes.
Claims
1. A resource allocation method, characterized in that, include: Obtain historical operational data from multiple tenants, including the resource consumption of each tenant during historical operation. A first quantity is calculated based on the historical operating data, where the first quantity is the number of nodes required by the multiple tenants; Multiple availability zones are identified, which are used to house instances of the multiple tenants, and each availability zone includes multiple nodes; Based on the first quantity, the nodes required by the multiple tenants are allocated to each of the multiple availability zones, resulting in the number of nodes enabled in each availability zone. The difference in the number of nodes enabled between different availability zones is less than or equal to 1. Each tenant's instance is assigned to each of the plurality of availability zones, wherein the difference in the number of instances of each tenant assigned to different availability zones is less than or equal to 1; The number of instances of the plurality of tenants allocated to the first availability zone is determined based on the number of instances of each tenant allocated to each availability zone, wherein the first availability zone is any one of the plurality of availability zones; Based on the number of instances allocated to the first availability zone by the multiple tenants, the instances allocated to the first availability zone by the multiple tenants are placed on the enabled nodes of the first availability zone, and the difference in the number of instances placed on different nodes among the enabled nodes of the first availability zone is less than or equal to 1.
2. The method according to claim 1, characterized in that, The first availability zone includes a first node. After placing the instances of the plurality of tenants assigned to the first availability zone on the first availability zone's enabled node, the method further includes: Determine if the first node is overloaded; If the first node is overloaded, obtain the resource usage of multiple instances placed on the first node; The top K instances with the highest resource consumption among the multiple instances are migrated to the second node. After the migration of the K instances, both the first node and the second node satisfy the load constraints.
3. The method according to claim 2, characterized in that, The step of migrating the K instances with the highest resource consumption among the multiple instances to the second node includes: Select a second node from the first availability zone that still satisfies the load constraints after placing the K instances; The K instances are placed in the second node one by one based on their resource usage.
4. The method according to claim 2, characterized in that, The plurality of availability zones also includes a second availability zone, wherein the second node is an enabled node in the second availability zone.
5. The method according to claim 2, characterized in that, The plurality of availability zones also includes a second availability zone. Before migrating the top K instances by resource usage from the first batch of instances to the second node, the method further includes: Start the second node in either the first availability zone or the second availability zone.
6. The method according to any one of claims 2 to 5, characterized in that, The method further includes: Receive a first instruction, which is generated by the operators after setting the priority of optimization goals through the management interface. The optimization goals include maintaining load balance among the multiple availability zones, reducing the number of instances migrated across availability zones, and reducing the number of new nodes. The step of migrating the K instances with the highest resource consumption among the multiple instances to the second node includes: Combined with the first instruction, migrate the K instances with the highest resource consumption among the multiple instances to the second node.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: When the number of instances of the multiple tenants cannot be accommodated by the nodes that are currently open in the multiple availability zones, a second number is calculated based on the number of instances that are not currently placed, and the second number is the number of nodes that need to be opened. Based on the second quantity, the newly opened nodes are allocated to each of the plurality of availability zones, and the difference in the number of newly opened nodes between different availability zones is less than or equal to 1.
8. The method according to any one of claims 1 to 7, characterized in that, Each open node is used to house only one instance of the same tenant.
9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: Receive a second instruction, which is generated by the operator after setting parameters through the management interface. The parameters include any one or more of the following: the availability zone, the number of availability zones, nodes, the upper limit of the number of nodes, and the number of instances of the same tenant that each node can accommodate. The step of allocating the nodes required by the plurality of tenants to each of the plurality of availability zones based on the first quantity includes: Based on the first quantity, and in conjunction with the second instruction, the nodes required by the multiple tenants are allocated to each of the multiple availability zones.
10. A resource allocation device, characterized in that, include: The acquisition unit is used to acquire historical operating data of multiple tenants, wherein the historical operating data includes the resource consumption of each of the multiple tenants during the historical operation process; A calculation unit is configured to calculate a first quantity based on the historical operating data, wherein the first quantity is the number of nodes required by the multiple tenants; A determining unit is used to determine multiple availability zones, which are used to place instances of the multiple tenants, and each of the multiple availability zones includes multiple nodes; The allocation unit is configured to allocate the nodes required by the plurality of tenants to each of the plurality of availability zones based on the first quantity, thereby obtaining the number of nodes enabled in each availability zone, wherein the difference in the number of nodes enabled between different availability zones is less than or equal to 1. The allocation unit is further configured to allocate each tenant's instance to each of the plurality of availability zones, wherein the difference in the number of instances of each tenant allocated to different availability zones among the plurality of availability zones is less than or equal to 1; The allocation unit is further configured to determine the number of instances of the plurality of tenants allocated to the first availability zone based on the number of instances of each tenant allocated to each availability zone, wherein the first availability zone is any one of the plurality of availability zones; The placement unit is used to place the instances allocated to the first availability zone by the multiple tenants on the enabled nodes of the first availability zone based on the number of instances allocated to the first availability zone by the multiple tenants, wherein the difference in the number of instances placed on different nodes among the enabled nodes of the first availability zone is less than or equal to 1.
11. The apparatus according to claim 10, characterized in that, The first availability zone's enabled node includes a first node, and the device further includes: A judgment unit is used to determine whether the first node is overloaded; The acquisition unit is used to acquire the resource usage of multiple instances placed on the first node when the first node is overloaded. The migration unit is used to migrate the K instances with the highest resource consumption among the multiple instances to the second node. After the K instances are migrated, both the first node and the second node satisfy the load constraints.
12. The apparatus according to claim 11, characterized in that, The migration unit is specifically used for: Select a second node from the first availability zone that still satisfies the load constraints after placing the K instances; The K instances are placed in the second node one by one based on their resource usage.
13. The apparatus according to claim 11, characterized in that, The plurality of availability zones also includes a second availability zone, wherein the second node is an enabled node in the second availability zone.
14. The apparatus according to claim 11, characterized in that, The plurality of availability zones also includes a second availability zone, and the device further includes: The activation unit is used to activate the second node in the first availability zone or the second availability zone.
15. The apparatus according to any one of claims 11 to 14, characterized in that, The device further includes: The receiving unit is used to receive a first instruction, which is generated by the operators after setting the priority of the optimization goals through the management interface. The optimization goals include maintaining load balance among the multiple availability zones, reducing the number of instances migrated across availability zones, and reducing the number of new nodes. The migration unit is specifically used for: Combined with the first instruction, migrate the K instances with the highest resource consumption among the multiple instances to the second node.
16. The apparatus according to any one of claims 10 to 15, characterized in that, The calculation unit is further configured to: when the nodes opened in the multiple availability zones cannot accommodate the instances of the multiple tenants, calculate a second number based on the number of unplaced instances, wherein the second number is the number of nodes that need to be opened. The allocation unit is further configured to: allocate the nodes that need to be newly opened to each of the plurality of availability zones based on the second quantity, wherein the difference in the number of newly opened nodes between different availability zones is less than or equal to 1.
17. The apparatus according to any one of claims 10 to 16, characterized in that, Each open node is used to house only one instance of the same tenant.
18. The apparatus according to any one of claims 10 to 17, characterized in that, The receiving unit is also used for: Receive a second instruction, which is generated by the operator after setting parameters through the management interface. The parameters include any one or more of the following: the availability zone, the number of availability zones, nodes, the upper limit of the number of nodes, and the number of instances of the same tenant that each node can accommodate. The allocation unit is specifically used for: Based on the first quantity, and in conjunction with the second instruction, the nodes required by the multiple tenants are allocated to each of the multiple availability zones.
19. A resource allocation device, characterized in that, include: Processor and memory; The memory is used to store instructions; The processor is configured to execute instructions stored in the memory to implement the method according to any one of claims 1 to 9.
20. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by one or more processors, it implements the method as described in any one of claims 1 to 9.
21. A computer program product containing instructions, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Resource division method and device
CN117216028A
Container platform-based tenant partitioning method, apparatus and device, medium and product
CN118157969A
Multi-Tenant Control Plane Management on Computing Platform
US20220188170A1
System and method for structuring and accessing tenant data in a hierarchical multi-tenant environment
US20220318074A1