Resource allocation method, device and electronic equipment
By obtaining the task resource occupancy and resource occupancy upper limit of the target account in the cloud computing system, the resource allocation is judged, and the resource occupancy of other accounts is reduced when resources are insufficient. This solves the problem of unfair cloud computing resource allocation and improves improve resource utilization and fairness.
Patent Information
- Application Number
- CN202111584851.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-12-21
AI Technical Summary
In existing cloud computing resource allocation methods, the problem of unfair resource allocation causes some users to seize a large amount of resources due to frequent task initiation, resulting in other users being unable to obtain sufficient resources.
By obtaining the task resource occupancy and resource occupancy upper limit of the target account, determine whether to allocate resources, and perform global resource reduction when resources are insufficient. Reduce the resource occupancy upper limit of other accounts to release idle resources and ensure that new tasks can be allocated. get enough resources.
It effectively avoids the problem of long-term inability to meet the pre-allocated resources due to resource preemption, and improves the fairness of resource allocation and the amount of idle resources in the system.
Smart Images

Figure CN114398173B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the computer field, and in particular, to a resource allocation method and device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] With the continuous development of Internet technology, cloud computing technology is rapidly becoming popular. Cloud computing can enable multiple users to share the same set of computer hardware resources, which can significantly improve resource utilization. How to allocate computing resources for user-initiated tasks has become a key research topic in cloud computing technology.
[0003] In related technologies, the maximum-min fairness algorithm is usually used to allocate computing resources to users. This method first allocates idle computing resources to each user according to a preset ratio. After a period of time, the remaining idle resources under each user's name are collected based on the resource occupancy of each user, and these remaining idle resources are reallocated to users whose computing resource needs are not met. The system continuously collects idle resources and allocates them to users whose resource needs are not met, so as to achieve the purpose of fully utilizing computing resources.
[0004] Since the resource allocation system only reallocates the remaining idle resources, and some users initiate tasks more frequently, some users may quickly seize the remaining resources and occupy a large amount of computing resources for a long time, leaving other users with no resources, resulting in serious unfairness in resource allocation. Summary of the invention
[0005] Embodiments of the present application provide a resource allocation method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product to solve the problem of poor fairness when allocating computing resources to multiple users in the related art.
[0006] In a first aspect, an embodiment of the present application provides a resource allocation method, the method comprising:
[0007] In response to a new task initiated by any target account among the multiple accounts, obtaining the task resource usage of the target account and the resource usage upper limit of the target account; wherein the task resource usage is used to represent the sum of the resource usage of the tasks being run by the target account and the required resource usage of the new task, and the resource usage upper limit is used to represent the maximum resource usage currently allowed by the target account;
[0008] When the resource occupation amount of the task is less than or equal to the resource occupation upper limit, allocating resources to the new task;
[0009] In the case where resource allocation for the new task fails, comparing the pre-allocated resource amount of the target account with the resource occupancy of the task; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account;
[0010] In the case where the task resource occupancy is less than or equal to the pre-allocated resource amount, instructing to perform global resource reduction; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset strategy;
[0011] After a preset delay time, resources are reallocated to the new task.
[0012] In an optional implementation manner, the instructing to perform global resource reduction includes:
[0013] Set resource reduction flags in the system;
[0014] According to the resource reduction mark, searching for a target other account whose resource occupancy exceeds the pre-allocated resource amount from the multiple accounts; wherein the target other account is an account other than the target account;
[0015] Reduce the resource usage upper limit of the target other accounts.
[0016] In an optional implementation manner, searching, according to the resource reduction mark, for target other accounts whose resource occupancy exceeds the pre-allocated resource amount from the multiple accounts includes:
[0017] traversing the multiple accounts in a loop at a preset time interval, and for each traversed account, obtaining the resource usage of the account and the pre-allocated resource amount of the account when there is a resource reduction mark in the system;
[0018] In a case where the resource usage of the account is greater than the pre-allocated resource amount of the account, the account is determined as the target other account.
[0019] In an optional implementation manner, reducing the upper limit of resource usage of the target other account includes:
[0020] Updating the resource usage upper limit of the target other account to the pre-allocated resource amount of the target other account;
[0021] Clears a resource reduction flag in the system.
[0022] In an optional implementation manner, allocating resources to the new task includes:
[0023] Obtaining an amount of idle resources, where the amount of idle resources is used to represent the total amount of idle resources remaining in the system;
[0024] In a case where the idle resource amount is greater than or equal to the required resource amount of the new task, allocating resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task;
[0025] When the amount of idle resources is less than the amount of required resources for the new task, it is determined that resource allocation for the new task fails.
[0026] In an optional implementation, the method further includes:
[0027] Acquire a resource expansion step of the target account, where the resource expansion step is used to update an upper limit value of resource usage of the target account;
[0028] The resource occupancy upper limit of the target account is initialized to a smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
[0029] In an optional implementation manner, obtaining the resource expansion step of the target account includes:
[0030] Obtaining an upper limit expiration duration and an upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from updating to expiration of the resource occupation upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length from the initial value of the resource occupation upper limit value of the target account to the pre-allocated resource amount;
[0031] The product of the upper limit expiration time and the pre-allocated resource amount is calculated, and the resource expansion step of the target account is determined according to the ratio of the product to the upper limit transition time.
[0032] In an optional implementation, the method further includes:
[0033] Loop through the multiple accounts at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the pre-allocated resource amount and the resource occupancy amount of the account;
[0034] When the resource usage of the account is less than or equal to the pre-allocated resource usage of the account, and the upper limit value of the resource usage of the account is expired, the upper limit value of the resource usage of the account is updated to the smaller value between the sum of the resource usage of the account and the resource expansion step of the account and the pre-allocated resource usage.
[0035] In an optional implementation, the method further includes:
[0036] Looping through the multiple accounts at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtaining the resource occupation amount of the account;
[0037] The resource occupation upper limit of the account is updated to the sum of the resource occupation amount of the account and the resource expansion step of the account.
[0038] In a second aspect, an embodiment of the present application provides a resource allocation device, the device comprising:
[0039] an acquisition module, configured to, in response to a new task initiated by any target account among the multiple accounts, acquire the task resource usage of the target account and the resource usage upper limit of the target account; wherein the task resource usage is used to represent the sum of the resource usage of the task being run by the target account and the required resource usage of the new task, and the resource usage upper limit is used to represent the maximum resource usage currently allowed by the target account;
[0040] an allocation module, configured to allocate resources to the new task when the resource occupation amount of the task is less than or equal to the resource occupation upper limit;
[0041] A comparison module is configured to compare the pre-allocated resource amount of the target account with the resource occupancy of the task when resource allocation for the new task fails; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account;
[0042] A reduction module is configured to instruct global resource reduction when the task resource occupancy is less than or equal to the pre-allocated resource amount; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset policy;
[0043] The delay module is configured to re-allocate resources to the new task after delaying for a preset period of time.
[0044] In an optional implementation, the reduction module includes:
[0045] a marking submodule, configured to set a resource reduction mark in the system;
[0046] a reduction target submodule, configured to search, from the multiple accounts, for target other accounts whose resource occupancy exceeds the pre-allocated resource amount according to the resource reduction mark; wherein the target other accounts are accounts other than the target account;
[0047] The reduction submodule is configured to reduce the resource usage upper limit of the target other account.
[0048] In an optional implementation, the reduction target submodule includes:
[0049] A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the resource usage of the account and the pre-allocated resource amount of the account;
[0050] The reduction target determination submodule is configured to determine the account as the target other account when the resource occupation of the account is greater than the pre-allocated resource amount of the account.
[0051] In an optional implementation, the reduction submodule includes:
[0052] An upper limit reduction submodule is configured to update the resource occupation upper limit value of the target other account to the pre-allocated resource amount of the target other account;
[0053] The clearing submodule is configured to clear the resource reduction mark in the system.
[0054] In an optional implementation, the allocation module includes:
[0055] An idle acquisition submodule is configured to acquire an idle resource amount, where the idle resource amount is used to represent the total amount of idle resources remaining in the system;
[0056] A new task allocation submodule is configured to allocate resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task when the idle resource amount is greater than or equal to the required resource amount of the new task;
[0057] The failure submodule is configured to determine that resource allocation to the new task fails when the amount of free resources is less than the amount of required resources for the new task.
[0058] In an optional embodiment, the device further comprises:
[0059] A step length acquisition module is configured to acquire a resource expansion step length of the target account, wherein the resource expansion step length is used to update the resource occupation upper limit value of the target account;
[0060] The upper limit initialization module is configured to initialize the resource occupation upper limit value of the target account to the smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
[0061] In an optional implementation, the step length acquisition module includes:
[0062] The duration acquisition submodule is configured to acquire the upper limit expiration duration and the upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from the update to the expiration of the resource occupation upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length from the initial value of the resource occupation upper limit value of the target account to the pre-allocated resource amount;
[0063] The step length calculation submodule is configured to calculate the product of the upper limit expiration time and the pre-allocated resource amount, and determine the resource expansion step length of the target account according to the ratio of the product to the upper limit transition time.
[0064] In an optional embodiment, the device further comprises:
[0065] A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the pre-allocated resource amount and the resource usage of the account;
[0066] The first updating submodule is configured to update the upper limit of resource occupation of the account to the smaller value between the sum of the resource occupation of the account and the resource expansion step of the account and the pre-allocated resource amount when the resource occupation of the account is less than or equal to the pre-allocated resource amount and the upper limit of resource occupation of the account is expired.
[0067] In an optional embodiment, the device further comprises:
[0068] A second traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtain the resource occupation amount of the account;
[0069] The second updating submodule is configured to update the resource occupation upper limit of the account to the sum of the resource occupation of the account and the resource expansion step of the account.
[0070] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the resource allocation method.
[0071] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the resource allocation method.
[0072] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which implements the resource allocation method when executed by a processor.
[0073] In an embodiment of the present application, in response to a new task initiated by any target account among multiple accounts, the target account's task resource occupancy and the target account's resource occupancy upper limit value can be obtained; when the task resource occupancy is less than or equal to the resource occupancy upper limit value, resources are allocated to the new task; when resource allocation to the new task fails, the target account's pre-allocated resource amount and the task resource occupancy amount are compared; when the task resource occupancy is less than or equal to the pre-allocated resource amount, global resource reduction is indicated; and resources are allocated to the new task again after a preset delay. When a new task initiated by a target account that does not exceed the resource usage cannot allocate computing resources, the resource occupancy of other accounts can be reduced, thereby increasing the system's idle resources, avoiding the long-term occupation of resources by other accounts, resulting in the long-term inability to meet the target account's pre-allocated resources, and greatly improving the fairness of computing resource allocation to each account.
[0074] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0076] Figure 1 is a flowchart of a resource allocation method provided by an embodiment of the present application;
[0077] Figure 2 is a flowchart of another resource allocation method provided by an embodiment of the present application;
[0078] Figure 3 is a resource allocation flow chart provided in an embodiment of the present application;
[0079] Figure 4This is a resource occupancy upper limit value update strategy flow chart provided in an embodiment of the present application;
[0080] Figure 5 It is a structural diagram of a resource allocation model provided in an embodiment of the present application;
[0081] Figure 6 is a logic block diagram of an electronic device according to an embodiment of the present application;
[0082] Figure 7 It is a logic block diagram of an electronic device according to another embodiment of the present application. DETAILED DESCRIPTION
[0083] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0084] Figure 1 is a flowchart of a resource allocation method provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0085] Step 101 : In response to a new task initiated by any target account among a plurality of accounts, the task resource usage of the target account and the resource usage upper limit of the target account are obtained.
[0086] The cloud computing system can access multiple target accounts, and each target account can submit tasks to the cloud computing system. After receiving the processing task submitted by the target account, the cloud computing system can allocate computing resources to the task according to the resource configuration corresponding to the target account to process the task. For example, the cloud computing system can be a batch processing system (Batch Processing System, BPS), which is also known as a batch processing operating system. After the user submits one or a batch of tasks to the batch processing system, he will no longer intervene. The batch processing system can automatically allocate computing resources to the task and execute the task. Through the batch processing system, the utilization rate of computing resources can be significantly improved. It is easy to understand that the cloud computing system can also be other systems that can access multiple users and allocate resources for task requests from different users.
[0087] Computing resources can include central processing unit (CPU) resources, graphics processing unit (GPU) resources, memory resources, network bandwidth resources, and any other computer resources required for the operation of a program.
[0088] When the target account generates a new task, the new task can be submitted to the cloud computing system. The cloud computing system receives the new task submitted by the target account and determines the amount of computing resources required to execute the new task. The measurement of the amount of computing resources can be a specific resource value. For example, when the computing resources are central processing unit resources, the measurement of the amount of computing resources can be expressed as TOPS (Tera Operations Per Second). The measurement of the amount of computing resources can also be expressed as a proportion of the total computing resources of the system. For example, when the computing resources are central processing unit resources, the amount of computer resources can be expressed as 1%, that is, 1% of the total computing power of the central processing unit in the cloud computing system.
[0089] After obtaining a new task initiated by the target account, the target account's task resource usage can be calculated based on the determined computing resources required for the new task and the computing resources occupied by the tasks actually running in the system, and the target account's resource usage upper limit can be obtained. The task resource usage is used to represent the sum of the resource usage of the tasks currently running in the target account and the required resources of the new task, and the resource usage upper limit is used to represent the maximum amount of resources currently allowed to be used by the target account. If a new task of the target account is allocated computing resources, the total amount of computing resources occupied by the target account will exceed the target account's resource usage upper limit, then the system will not allocate computing resources for the new task.
[0090] Step 102: When the resource occupation amount of the task is less than or equal to the resource occupation upper limit, allocate resources to the new task.
[0091] Since the current resource usage upper limit of the target account determines the total amount of computing resources that the target account can currently use, for each new task of the target account, it is necessary to first determine whether the task resource usage of the target account exceeds the resource usage upper limit of the target account, so as to use this as the basis for allocating computing resources to the new task of the target account.
[0092] If the target account's task resource usage is less than or equal to the target account's resource usage upper limit, it means that after allocating computing resources to the target account's new task, the target account's resource usage will not exceed the target account's resource usage upper limit, and you can try to allocate computing resources to the target account's new task.
[0093] If the amount of free resources in the system can meet the amount of computing resources required by the new task, the operation of allocating computing resources can be executed successfully. If the amount of free resources in the system cannot meet the amount of computing resources required by the new task, the operation of allocating computing resources cannot be executed successfully, that is, the operation of allocating computing resources to the new task fails.
[0094] It should be noted that the system can independently allocate each specific computing resource required for the new task and execute the new task after all running resources are allocated. It can also allocate all the computing resources required for the new task at one time according to the proportion of all computing resources required for the new task in the total computing resources of the system.
[0095] Step 103: When resource allocation for the new task fails, compare the pre-allocated resource amount of the target account with the resource occupancy of the task; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account.
[0096] In the case of failure to allocate computing resources for a new task, it means that the remaining idle resources in the system cannot meet the required resources of the new task. In order to enable the new task to be executed as soon as possible, it is necessary to increase the remaining idle resources in the system to meet the required resources of the new task of the target account.
[0097] Since the total amount of system resources is fixed, in order to increase the amount of idle resources remaining in the system, it is necessary to reduce the resource usage of other accounts. For example, the total amount of system resources is 100, and two accounts A and B are added to the system. Accounts A and B both have tasks in progress and occupy 50 computing resources respectively. At this time, if account A initiates a new task, since the current idle resources in the system are 0, the allocation of computing resources for the new task initiated by account A will fail. In order to enable the new task initiated by account A to be executed as soon as possible, it is necessary to reduce the resource usage of account B to generate idle resources in the system to meet the resource requirements of the new task initiated by account A.
[0098] Therefore, it is necessary to confirm whether the target user is eligible to occupy the resources already occupied by other users to execute the new task initiated by the target user. A pre-allocated resource amount can be preset for each account. The pre-allocated resource amount can be agreed upon by the owner of the account and the provider of the cloud computing service to characterize the rated configuration resource amount of the target account. The pre-allocated resource amount can also represent the amount of resources purchased by the account owner from the cloud computing service provider. The target user's task resource occupancy is obtained by adding the target account's resource occupancy to the required resource amount of the new task. Among them, the resource occupancy is the total amount of resources occupied by all tasks initiated by the target user and currently running.
[0099] In the event that the target account's new task allocation for computing resources fails, in order to determine whether the amount of resources occupied by other users can be reduced to provide the target user with more free resources to perform new tasks, the target account's task resource usage and pre-allocated resource usage can be obtained, and the relationship between the task resource usage and the pre-allocated resource usage can be determined, so as to determine whether the resources occupied by other accounts can be reduced based on the relationship in subsequent steps.
[0100] Step 104: when the task resource occupancy is less than or equal to the pre-allocated resource amount, instruct to perform global resource reduction; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset strategy.
[0101] Since the pre-allocated resources of the target account are represented by the rated resources of the target account. The task resource usage is the actual resources occupied by the tasks currently running in the target account and the resources required by the new tasks of the target account. Therefore, if the task resource usage of the target account does not exceed the pre-allocated resources of the target account, it means that after allocating resources to the new tasks of the target account, the total resources occupied by the target account do not exceed the rated resources configured for the target account, that is, the resources occupied by the target account are not overspent. Therefore, the resource demand of the target account should be met. At this time, the resource usage of other accounts can be actively reduced to prevent the new tasks of other accounts from continuing to occupy idle resources after the old tasks of other accounts have finished running and released computing resources.
[0102] For example, after receiving the new task m of the target account A, the cloud computing system determines that the new task m needs to occupy 10Tflops of GPU resources and allocates computing resources to the new task m. If the resource allocation for the new task m fails, it means that the remaining idle GPU resources in the system are insufficient. At this time, the task resource occupancy of the target account A is obtained to be 100Tflops, and the pre-allocated resource amount of the target account A is 120Tflops. Since 100 is less than 120, it means that after the execution of the new task m of the target account A, its resource occupancy does not exceed the pre-allocated resource amount, and there is no excess occupancy of resources. The resource occupancy of other users can be reduced, and idle resources can be released for the target account A to execute the new task m.
[0103] Specifically, in order to reduce the resource usage of other users, the system can issue instructions for global resource reduction, which can suspend the tasks being executed by other users and release the computing resources occupied by the suspended tasks, waiting for the target account's new tasks to be completed before continuing to execute the suspended tasks of other users. In addition, it is also possible to stop allocating computing resources to new tasks of other users, suspend new tasks of other users, and wait for the tasks being executed by other users to be completed before releasing the occupied computing resources.
[0104] It is also possible not to directly interrupt the tasks being processed by other accounts. Instead, the resource usage limit of other accounts can be reduced to below the resource usage of other accounts. In this way, since the resource usage limit of other accounts is lower than the resource usage of the target account, new tasks of other accounts cannot be processed by the system. The system will suspend the new tasks of other accounts, and the computing resources will be released after the old tasks of other accounts are completed, so that the actual resource usage of other accounts will gradually reach the reduced resource usage limit of other accounts. In this way, the resource usage of other accounts can be reduced and the idle resources of the system can be increased.
[0105] Step 105: re-allocate resources for the new task after a preset delay.
[0106] Since it takes a certain amount of time to perform global resource reduction, whether it is directly pausing tasks currently running in other accounts or reducing the resource usage limit of other accounts, there is an execution process. For example, pausing tasks currently running in other accounts requires interrupting the tasks, taking snapshots of the tasks and storing them, in order to release the resources occupied by other tasks; reducing the resource usage limit of other accounts requires waiting for the tasks currently running in other accounts to be completed before the computing resources can be released. Therefore, after instructing to perform global resource reduction, new tasks initiated by the target account can be added to the waiting queue, and after a preset delay, retry to allocate computing resources for the new tasks initiated by the target account.
[0107] In addition, after adding the new task initiated by the target account to the waiting queue, the system can also calculate and monitor the idle resources of the system, and retry to allocate computing resources to the new task when the idle resources can meet the required resource amount of the new task.
[0108] Furthermore, since the pre-allocated resources of the target account are represented by the rated resources of the target account, and the task resource usage is the actual resources occupied by the tasks currently running in the target account and the resources required by the new tasks of the target account, if the task resource usage of the target account exceeds the pre-allocated resources of the target account, it means that after allocating resources to the new tasks of the target account, the total resources occupied by the target account will exceed the rated resources of the target account, that is, the resources occupied by the target account will be overspent. At this time, the resource demand of the target account should not be met, and the resource usage of other accounts cannot be actively reduced. In other words, the task execution of other users cannot be affected because the target account exceeds the rated resource usage demand.
[0109] Specifically, when it is detected that the target account's task resource usage is less than or equal to the target account's pre-allocated resource amount, the target account's new task can be suspended, and after being suspended, it enters the waiting queue, and waits for the system's idle resources to meet the new task's running requirements before allocating computing resources to the target account's new task and executing it. Alternatively, after suspending the target account's new task, it can continuously try to allocate computing resources to the target account's new task at intervals of a preset suspension time until the computing resources are successfully allocated to the target account's new task.
[0110] In an embodiment of the present application, a resource allocation method is disclosed, which can respond to a new task initiated by any target account among multiple accounts, obtain the target account's task resource occupancy and the target account's resource occupancy upper limit; when the task resource occupancy is less than or equal to the resource occupancy upper limit, allocate resources to the new task; when resource allocation to the new task fails, compare the target account's pre-allocated resource amount with the task resource occupancy; when the task resource occupancy is less than or equal to the pre-allocated resource amount, instruct to perform global resource reduction; and re-allocate resources to the new task after a preset delay. When a new task initiated by a target account that does not overuse resources cannot allocate computing resources, the resource occupancy of other accounts can be reduced, thereby increasing the system's idle resources, avoiding other accounts from occupying resources for a long time, resulting in a situation where the target account's pre-allocated resources cannot be met for a long time, and greatly improving the fairness of allocating computing resources to each account.
[0111] Figure 2 is a flowchart of another resource allocation method provided by an embodiment of the present application. Figure 2 As shown, the method includes:
[0112] Step 201: Obtain a resource expansion step of the target account, where the resource expansion step is used to update an upper limit value of resource usage of the target account.
[0113] The resource usage upper limit is used to limit the amount of computing resources that the target account can currently occupy. After the target account accesses or logs into the cloud computing system, the system needs to initialize the resource usage upper limit of the target account.
[0114] The resource usage upper limit value will also be dynamically updated as the resource usage of the target account changes. When the resource usage upper limit value is updated, the resource usage upper limit value of the target account is adjusted according to the resource expansion step of the target account.
[0115] Step 201 may also include:
[0116] Sub-step 2011, obtaining the upper limit expiration duration and upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from the update to the expiration of the resource occupancy upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length for the resource occupancy upper limit value of the target account to reach the pre-allocated resource amount from the initial value.
[0117] In actual applications, after the target account is connected to the system, the system's computing resources may already be saturated, and it is impossible to immediately set a resource usage upper limit for the target account that is equivalent to the pre-allocated resources. It takes time to allocate and schedule system resources. However, since the pre-allocated resources of the target account are the resource usage that is configured for the user, the user usually has requirements for the time it takes for the target account's resource usage upper limit to increase from the initial value to the pre-allocated resources. Therefore, it is necessary to set an upper limit transition duration. The upper limit transition duration indicates that the task initiated by the target account at the first time of access to the system reaches the pre-allocated resources. In this case, the expected length of time for the target account's resource usage upper limit to reach the pre-allocated resources from the initial value.
[0118] For example, the initial resource usage limit of target account A after accessing the system is 50, the corresponding pre-allocated resources of target account A are 1000, and target account A initiates task 1 with a required resource amount of 1000 as soon as it accesses the system. Then the system needs to increase the resource usage limit of target account A to 1000 after the upper limit transition period of target account A (for example, 50 seconds).
[0119] The upper limit expiration duration is used to indicate the length of time from the target account's resource usage upper limit to its expiration after each update. For example, if the upper limit expiration duration of target account A is 10 seconds, then 10 seconds after each update of the resource usage upper limit of target account A, the resource usage upper limit of target account A cannot be used and needs to be initialized or updated again before it can be used.
[0120] Sub-step 2012: multiply the upper limit expiration time by the pre-allocated resource amount, and then determine the ratio of the obtained product to the upper limit transition time as the resource expansion step of the target account.
[0121] Since the resource usage upper limit of the target account needs to be updated after at least the upper limit expiration time, and the pre-allocated resources need to be reached within the upper limit transition time, the resource expansion step can be calculated based on the upper limit expiration time and the pre-allocated resources to meet the resource usage upper limit limit conditions.
[0122] For example, the upper limit expiration time of target account A is 10 seconds, the pre-allocated resource amount is 1000, and the upper limit transition time is 50 seconds. Then the resource expansion step corresponding to target account A is calculated to be 200.
[0123] In an embodiment of the present application, by setting an upper limit expiration period, an upper limit transition period, and a pre-allocated resource amount for the target account, different resource expansion steps can be calculated for different target accounts. For customers with higher requirements for resource response speed, a shorter upper limit transition period can be set, so that the resource occupancy upper limit value can be increased according to a larger resource expansion step, thereby better meeting the needs of different types of users and improving the user experience.
[0124] Step 202: Initialize the resource occupancy upper limit of the target account to the smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
[0125] After the target account accesses or logs into the cloud computing system and the resource expansion step of the target account is determined, the resource occupation upper limit value of the target account may be initialized first.
[0126] Specifically, since the resource expansion step of the target account may be greater than the pre-allocated resource amount, and the pre-allocated resource amount is the rated resource quota of the target account, the resource occupancy upper limit value of the target account should not exceed the pre-allocated resource amount after initialization. Therefore, the resource occupancy upper limit value of the target account can be initialized by using the smaller value between the pre-allocated resource amount of the target account and the resource expansion step of the target account.
[0127] For example, the resource expansion step of target account A is 200, and the pre-allocated resources of target account A are 1000. Obviously, the resource expansion step of target account A is smaller, so the resource occupancy upper limit of target account A is initialized to 200.
[0128] Step 203: traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtain the resource occupation amount of the account.
[0129] As new tasks are constantly added to the accounts connected to the system and old tasks are constantly processed, the resource usage of each account will change, that is, the load of each account will change over time. For example, some accounts occupy more resources at night, some accounts occupy more resources during the day, some accounts occupy more resources, and some accounts occupy more resources.
[0130] Therefore, it is necessary to update the resource usage upper limit of the target account so that it can adapt to the actual needs of the target account, thereby improving the fairness of resource allocation and resource usage of the system and avoiding resource waste.
[0131] When there is a new task in the cloud computing system that cannot be allocated with system idle resources, and the task resource occupancy corresponding to the new task is less than or equal to the pre-allocated resource amount of the account corresponding to the new task, the resource allocation module of the cloud computing system will set a global resource reduction mark, so that the upper limit value adjustment module of the cloud computing system can use the first upper limit value update strategy to update the resource occupancy upper limit value of the target account when the global resource reduction mark is detected in the system. That is to say, in the embodiment of the present application, as long as a new task cannot be allocated with computing resources within the pre-allocated resource amount range of the corresponding account, the resource reduction mark of the system will be triggered.
[0132] For example, account A requests a new task 1. The pre-allocated resources of account A are 1000, and the resource demand of new task 1 is 50. At this time, the resource usage of account A is 900, and the corresponding task resource usage is 950. If the remaining idle resources in the system are less than 50, resulting in a failure to allocate computing resources for new task 1, then since the task resource usage corresponding to new task 1 is less than the resource usage of account A, the system will trigger a global resource reduction mark.
[0133] Specifically, when traversing each account, first determine whether there is a resource reduction mark in the system. The resource reduction mark can be represented by a global variable. For example, set a global variable a. When the value of a is 1, it indicates that there is a resource reduction mark. When the value of a is 0, it indicates that there is no resource reduction mark. Obtain the pre-allocated resource amount and the resource usage of the account. Further adopt the first upper limit value update strategy to update the resource usage upper limit value of the target account.
[0134] Step 204: Update the resource occupation upper limit of the account to the sum of the resource occupation of the account and the resource expansion step of the account.
[0135] After obtaining the resource usage of the account, the second upper limit update strategy can be used to update the resource usage upper limit of the account. Specifically, the resource usage of the account is added to the resource expansion step of the account to obtain a sum value, and the sum value is used as the updated resource usage upper limit of the account.
[0136] For example, for example, the expansion step of account A is 200, and the resource usage of account A is 980. If it is detected that the upper limit of resource usage of account A has expired, the upper limit of account A can be updated according to the second upper limit update strategy: determine the sum of the account's resource usage and the account's resource expansion step, that is, the sum is 1180, and determine the sum as the updated upper limit of resource usage of account A, that is, 1180.
[0137] In the embodiment of the present application, after the resource occupation upper limit value of the account expires, the resource occupation upper limit value of the account can be updated according to the current actual amount of resources occupied by the account, and the updated resource occupation upper limit value is made higher than the current actual amount of resources occupied, so that the resource occupation upper limit value of the account can be dynamically adjusted with the task volume of the account, which helps to meet the computing resource requirements of the account that change at any time. In addition, if the pre-allocated resource amounts of all accounts in the system can be met, the updated resource occupation upper limit value of the account can also be allowed to exceed the pre-allocated resource amount of the account, so as to meet the resource requirements of the account as much as possible without affecting the basic requirements of other accounts, which can not only meet the sudden resource requirements of users, but also improve the resource utilization rate of the system.
[0138] Step 205: traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtain the resource occupation amount of the account.
[0139] If, when traversing to a certain account, it is detected that there is no resource reduction mark in the system, it means that there is currently no account in the system that cannot be satisfied with the pre-allocated resources. At this time, if the resource occupancy upper limit of the account needs to be updated, the updated resource occupancy upper limit of the account can be allowed to exceed the pre-allocated resources of the account, so as to meet the resource needs of the account as much as possible without affecting the basic needs of other accounts. That is to say, when there is no resource reduction mark in the system, the resource occupancy upper limit of the account can be updated according to the second upper limit update strategy. At this time, since there is no need to consider whether the updated resource occupancy upper limit exceeds the pre-allocated resources of the account, only the resource occupancy of the account can be obtained.
[0140] Specifically, after traversing the account, first determine whether there is a resource reduction mark in the system. If there is no resource reduction mark in the system, determine whether the resource usage upper limit value of the account has expired. If the resource usage upper limit value of the account is expired, obtain the resource usage of the account.
[0141] Step 206: When the resource usage of the account is less than or equal to the pre-allocated resource usage of the account, and the upper limit value of the resource usage of the account is expired, the upper limit value of the resource usage of the account is updated to the smaller value between the sum of the resource usage of the account and the resource expansion step of the account and the pre-allocated resource usage.
[0142] For the traversed accounts, after obtaining the account's pre-allocated resources and the account's resource usage, determine the size relationship between the account's pre-allocated resources and the account's resource usage.
[0143] Since the system has resource reduction marks, it means that the remaining idle resources in the system are currently insufficient to meet the pre-allocated resource requirements of some accounts. Therefore, when updating the resource usage upper limit of an account, the updated resource usage upper limit cannot exceed the pre-allocated resource amount of the account, that is, the account is not allowed to over-use system resources at this time. Therefore, when it is determined that the resource usage upper limit of an account has expired, when updating the resource usage upper limit of the account, the resource usage upper limit of the account can at most be updated to the pre-allocated resource amount of the account.
[0144] Specifically, when the resource usage of an account is less than or equal to the pre-allocated resource usage of the account, and the upper limit value of the resource usage of the account is expired, the upper limit value of the resource usage of the account is updated to the smaller value between the sum of the resource usage of the account and the resource expansion step of the account and the pre-allocated resource usage.
[0145] For example, the expansion step of account A is 200, the resource usage of account A is 980, and the pre-allocated resources of account A is 1000, then the resource usage of account A is less than the pre-allocated resources of the account. If it is detected at this time that the upper limit of the resource usage of account A has expired, the upper limit of account A can be updated according to the first upper limit update strategy: determine the sum of the resource usage of the account and the resource expansion step of the account, that is, the sum is 1180, determine the pre-allocated resources of the account, that is, 1000, and determine the smaller value of the sum and the pre-allocated resources as the updated upper limit of the resource usage of account A, that is, 1000.
[0146] In an embodiment of the present application, if it is detected that there are accounts in the system whose pre-allocated resources cannot be met, when updating the resource usage upper limit of each account, the resource usage upper limit of each account will no longer be allowed to exceed its pre-allocated resources, thereby avoiding the unfair phenomenon of allowing other accounts to occupy computing resources in excess when the pre-allocated resources of some accounts cannot be met, thereby improving the fairness of the cloud computing system in allocating computing resources to each account.
[0147] Step 207: In response to a new task initiated by any target account among the multiple accounts, obtain the task resource occupancy of the target account and the resource occupancy upper limit of the target account; wherein the task resource occupancy is used to represent the sum of the resource occupancy of the tasks running by the target account and the required resources of the new task, and the resource occupancy upper limit is used to represent the maximum amount of resources currently allowed to be used by the target account.
[0148] Step 208: When the resource occupation amount of the task is less than or equal to the resource occupation upper limit, allocate resources to the new task.
[0149] After obtaining the resource occupation upper limit value of the target account, it is necessary to first determine whether the resource occupation upper limit value of the target account is expired. If the resource occupation upper limit value of the target account is expired, the resource occupation upper limit value of the target account can be updated in the manner of steps 203 to 206. If the target account has not been allocated a resource occupation upper limit value, the resource occupation upper limit value of the target account can be initialized to the smaller value between the pre-allocated resource amount of the target account and the resource expansion step length of the target account in the manner of steps 201 to 202.
[0150] After determining that the resource occupation upper limit value of the target account is in a valid state, it is determined whether the task resource occupation amount of the target account is less than or equal to the resource occupation upper limit value of the target account.
[0151] Step 208 may also include:
[0152] Sub-step 2081: Obtain the amount of idle resources, where the amount of idle resources is used to represent the total amount of idle resources remaining in the system.
[0153] When it is determined that the target account's task resource usage is less than or equal to the target account's resource usage upper limit, the method disclosed in substeps 2081 to 2083 can be used to try to allocate computing resources to the target account's new task. First, the idle resource amount of the cloud computing system needs to be obtained.
[0154] Sub-step 2082: when the idle resource amount is greater than or equal to the required resource amount of the new task, allocate resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task.
[0155] After determining the required resource amount of the new task, if the idle resources in the system can meet the computing resource amount required by the new task, ie, the required resource amount of the new task, then the operation of allocating computing resources can be successfully executed.
[0156] Sub-step 2083: When the amount of free resources is less than the amount of required resources for the new task, determine that resource allocation for the new task has failed.
[0157] If the amount of idle resources in the system cannot meet the amount of computing resources required by the new task, the operation of allocating computing resources cannot be successfully executed, that is, the operation of allocating computing resources to the new task fails.
[0158] Step 209: When the resource usage of the task is greater than the resource usage upper limit, suspend the new task.
[0159] If the target account's task resource usage is greater than the target account's resource usage upper limit, it means that after the current allocation of computing resources to the target account's new task, the target account's resource usage will exceed the target account's resource usage upper limit, and the target account's new task cannot be allocated computing resources. The target account's new task needs to be suspended, and step 208 needs to be continuously attempted at a preset allocation time interval. Since the target account's resource usage upper limit will be dynamically adjusted during the update process from step 203 to step 206, the target account's resource usage upper limit may be increased, and at the same time, the target account's old task being executed will be released after completion, reducing the target account's resource usage. Therefore, in the subsequent repeated allocation process, it is possible that the target account's task resource usage is less than or equal to the target account's resource usage upper limit.
[0160] In an embodiment of the present application, after receiving a new task request, it can be determined whether to allocate computing resources to the new task based on the resource occupancy upper limit of the target account corresponding to the new task, and the new task can be suspended and placed in a waiting queue when the resource occupancy upper limit of the target account is insufficient to run the new task, and computing resources can be allocated to the new task after the resource occupancy upper limit of the target account is increased and / or the actual resource occupancy value of the target account is decreased. When there are multiple suspended new tasks in the target account, if the resource demand of a new task with a smaller amount of required resources is met first, but the new task with a smaller amount of required resources is initiated later, computing resources will be allocated to the new task with a smaller amount of required resources immediately, which can make full use of the idle resources of the system and improve the utilization rate of system resources.
[0161] Step 210: When resource allocation for the new task fails, compare the pre-allocated resource amount of the target account with the resource occupancy of the task; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account.
[0162] This step can refer to step 103, and will not be described in detail in this embodiment of the present application.
[0163] Step 211: When the task resource occupancy is less than or equal to the pre-allocated resource amount, instruct to perform global resource reduction; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset policy.
[0164] After failing to allocate computing resources for the target account's new task, that is, after determining that the idle resources in the system are insufficient to execute the target account's new application, it is necessary to determine whether the resources occupied by other accounts in the system can be reduced.
[0165] Specifically, when the task resource usage of the target account is less than or equal to the pre-allocated resource amount of the target account, a resource reduction flag may be set in the system.
[0166] Reference Figure 3 , Figure 3 A resource allocation flow chart provided in an embodiment of the present application is shown. Figure 3As shown, after receiving the new task of the target account from step B1, perform the operation of step B2 to determine whether resources can be allocated to the new task. If so, perform step B4 to try to allocate. If not, perform step B3 to suspend the new task and enter step B2 again after a period of time. If step B4 is successfully allocated, perform step B5 to execute the new task. If step B4 fails to allocate, perform step B6 to determine whether the actual occupied resources of other accounts can be reduced. If step B6 is judged as yes, perform step B7 to set the resource reduction mark, and then perform step B8 to suspend the new task and enter step B2 again after a period of time. If step B6 is judged as no, perform step B8 directly from step B6 to suspend the new task and enter step B2 again after a period of time.
[0167] Optionally, step 211 may include:
[0168] Sub-step 2111: Set a resource reduction flag in the system.
[0169] Sub-step 2112: searching, according to the resource reduction mark, for target other accounts whose resource occupancy exceeds the pre-allocated resource amount from the multiple accounts; wherein the target other accounts are accounts other than the target account.
[0170] In the embodiment of the present application, if the idle resources of the system are sufficient, the account is allowed to occupy system computing resources exceeding its pre-allocated resource amount. Further, when there is a resource reduction mark in the system, it means that the idle resources of the system are insufficient at this time, and the excess computing resources can be recovered. Specifically, the method in sub-steps A1 to A2 can be used to determine the target other accounts for recovering the excess computing resources.
[0171] Optionally, sub-step 2112 may include:
[0172] Sub-step A1: looping through the multiple accounts at a preset time interval, and for each traversed account, obtaining the resource usage of the account and the pre-allocated resource amount of the account when there is a resource reduction mark in the system.
[0173] The method for updating the pre-allocated resource amount in the above steps 203 to 206 can be used to perform a traversal operation on other accounts. When traversing to each other account, it is determined whether there is a resource reduction mark in the system. If there is a resource reduction mark in the system, the resource usage of other accounts and the pre-allocated resource amount of other accounts are further obtained.
[0174] It should be noted that regardless of whether there is a resource reduction mark in the system, the embodiment of the present application can loop through all accounts at preset time intervals.
[0175] Sub-step A2: when the resource usage of the account is greater than the pre-allocated resource amount of the account, determine the account as the target other account.
[0176] If the resource usage of another account exceeds the pre-allocated resources of this account, it means that this account is currently overusing the system's computing resources and its computing resources need to be reduced as soon as possible to meet the new task resource requirements of the target account that has not overused the computing resources.
[0177] Specifically, when the resource usage of other accounts is greater than the pre-allocated resource usage of other accounts, the other accounts are determined as target other accounts, and the target other accounts are accounts whose occupied resources need to be reduced. Accounts that are overusing system computing resources can be determined relatively quickly.
[0178] Sub-step 2113: reducing the upper limit of resource usage of the target other accounts.
[0179] In the embodiment of the present application, in order to avoid affecting the task being processed by the target other account, the task being processed by the target other account may not be directly interrupted, but the resource occupation limit of the target other account may be reduced to the same level as or lower than the resource occupation of the target other account.
[0180] In this way, since the resource usage upper limit of the target other accounts is lower than the resource usage of the target account, the new tasks of the target other accounts cannot be processed by the system, and the system will suspend the new tasks of the target other accounts. After the old tasks of the target other accounts are completed, the computing resources will be released, so that the actual resource usage of the target other accounts will gradually reach the lowered resource usage upper limit of the target other accounts. In this way, the resource usage of the target other accounts is reduced and the idle resources of the system are increased.
[0181] Specifically, the target other accounts may be processed in the manner of the following sub-steps B1 and B2.
[0182] Optionally, sub-step 2113 may also include:
[0183] Sub-step B1: Update the resource usage upper limit of the target other account to the pre-allocated resources of the target other account
[0184] After determining the target other account, you can directly update the resource usage upper limit of the target other account to the pre-allocated resource amount of the target other account. In this way, after a period of time, as the old tasks of the target other account are completed, the actual resource usage of the target other account will be reduced to a level less than or equal to the pre-allocated resource amount.
[0185] Sub-step B2: clearing the resource reduction flag in the system.
[0186] In sub-step B1, after a period of time when the resource occupation upper limit of the target other accounts is updated, the resource occupation of the target other accounts will be reduced, so the purpose of releasing resources has been achieved, and the resource reduction mark in the system can be cleared. After the resource mark is cleared, the other accounts traversed in steps 203 to 206 will not be further reduced, so that the system can maintain a smaller amount of idle resources as much as possible while meeting the pre-allocated resource requirements of all accounts, thereby achieving the purpose of efficient operation.
[0187] Since the embodiment of the present application continuously attempts to allocate resources to the new task of the target account at a preset time interval, when the target account attempts to allocate resources to the new task next time, if the change in idle resources is large enough to successfully allocate resources, the new task will continue to be executed. If the next attempt to allocate resources to the new task still fails, a resource reduction flag will be set to wait for the resource usage upper limit of other accounts to be reduced.
[0188] Reference Figure 4 , shows a resource occupancy upper limit value update strategy flow chart provided by an embodiment of the present application. Figure 4 As shown, step C1 periodically traverses each account, and for each traversed account, step C2 is entered to determine whether there is a resource reduction mark in the current system. If the judgment result of step C2 is no, step C3 is entered to determine whether the resource occupancy upper limit of the account is expired. If the judgment result of step C3 is yes, the second upper limit value update strategy of step C4 is used to update the resource occupancy upper limit of the account. If the judgment result of step C2 is yes, step C5 is entered to further determine whether the resource occupancy of the account exceeds the limit. If the judgment result of step C5 is no, step C6 is used to determine whether the resource occupancy upper limit of the account is expired. If the judgment result of C6 is yes, it means that the resource occupancy of the account has not exceeded the limit and the resource occupancy upper limit of the account has expired, and the resource occupancy upper limit of the account is updated according to the first upper limit value update strategy of step C7. If the judgment result of step C5 is yes, it means that there is a resource reduction mark at this time and the resource usage of the account exceeds the limit. It is necessary to enter step C8 to reset the resource usage upper limit of the account to reduce the resource usage of the account, and clear the resource reduction mark to avoid the resource usage upper limit of the subsequently traversed accounts from being repeatedly reduced.
[0189] In an embodiment of the present application, when a new task of a target account that has not yet reached the pre-allocated resource amount cannot be allocated computing resources, a global resource reduction mark can be set. The system can reduce the resource occupancy upper limit of other accounts whose current resource occupancy exceeds the pre-allocated resource amount according to the resource reduction mark while continuously traversing each account, so as to release the excess computing resources, thereby increasing the idle resources of the system. At the same time, it continuously attempts to allocate computing resources to the new task, and continuously repeats the process until the new task successfully allocates resources, thereby avoiding the long-term excessive occupation of resources by other accounts, resulting in the long-term inability to meet the pre-allocated resource amount of the target account, and greatly improving the fairness of allocating computing resources to each account.
[0190] In summary, another resource allocation method provided in the embodiment of the present application can respond to a new task initiated by any target account among multiple accounts, obtain the target account's task resource occupancy and the target account's resource occupancy upper limit; when the task resource occupancy is less than or equal to the resource occupancy upper limit, allocate resources to the new task; when resource allocation to the new task fails, compare the target account's pre-allocated resource amount with the task resource occupancy; when the task resource occupancy is less than or equal to the pre-allocated resource amount, instruct to perform global resource reduction; and re-allocate resources to the new task after a preset delay. When a new task initiated by a target account that has not exceeded the resource quota cannot allocate computing resources, the resource occupancy of other accounts can be reduced, thereby increasing the system's idle resources, avoiding other accounts from occupying resources for a long time, resulting in a situation where the target account's pre-allocated resources cannot be met for a long time, and greatly improving the fairness of allocating computing resources to each account.
[0191] Corresponding to the method provided by the resource allocation method embodiment of the present invention, see Figure 5 The present invention also provides a structure diagram of a resource allocation device. In this embodiment, the device may include:
[0192] The acquisition module 301 is configured to, in response to a new task initiated by any target account among the multiple accounts, acquire the task resource usage of the target account and the resource usage upper limit of the target account; wherein the task resource usage is used to represent the sum of the resource usage of the task being run by the target account and the required resource usage of the new task, and the resource usage upper limit is used to represent the maximum resource usage currently allowed by the target account;
[0193] An allocation module 302 is configured to allocate resources to the new task when the resource occupation amount of the task is less than or equal to the resource occupation upper limit;
[0194] The comparison module 303 is configured to compare the pre-allocated resource amount of the target account with the resource occupancy of the task when resource allocation for the new task fails; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account;
[0195] The reduction module 304 is configured to instruct to perform global resource reduction when the task resource occupancy is less than or equal to the pre-allocated resource amount; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset policy;
[0196] The delay module 305 is configured to re-allocate resources to the new task after a delay of a preset time.
[0197] In an optional implementation, the reduction module includes:
[0198] a marking submodule, configured to set a resource reduction mark in the system;
[0199] a reduction target submodule, configured to search, from the multiple accounts, for target other accounts whose resource occupancy exceeds the pre-allocated resource amount according to the resource reduction mark; wherein the target other accounts are accounts other than the target account;
[0200] The reduction submodule is configured to reduce the resource usage upper limit of the target other account.
[0201] In an optional implementation, the reduction target submodule includes:
[0202] A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the resource usage of the account and the pre-allocated resource amount of the account;
[0203] The reduction target determination submodule is configured to determine the account as the target other account when the resource occupation of the account is greater than the pre-allocated resource amount of the account.
[0204] In an optional implementation, the reduction submodule includes:
[0205] An upper limit reduction submodule is configured to update the resource occupation upper limit value of the target other account to the pre-allocated resource amount of the target other account;
[0206] The clearing submodule is configured to clear the resource reduction mark in the system.
[0207] In an optional implementation, the allocation module includes:
[0208] An idle acquisition submodule is configured to acquire an idle resource amount, where the idle resource amount is used to represent the total amount of idle resources remaining in the system;
[0209] A new task allocation submodule is configured to allocate resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task when the idle resource amount is greater than or equal to the required resource amount of the new task;
[0210] The failure submodule is configured to determine that resource allocation to the new task fails when the amount of free resources is less than the amount of required resources for the new task.
[0211] In an optional embodiment, the device further comprises:
[0212] A step length acquisition module is configured to acquire a resource expansion step length of the target account, wherein the resource expansion step length is used to update the resource occupation upper limit value of the target account;
[0213] The upper limit initialization module is configured to initialize the resource occupation upper limit value of the target account to the smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
[0214] In an optional implementation, the step length acquisition module includes:
[0215] The duration acquisition submodule is configured to acquire the upper limit expiration duration and the upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from the update to the expiration of the resource occupation upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length from the initial value of the resource occupation upper limit value of the target account to the pre-allocated resource amount;
[0216] The step length calculation submodule is configured to calculate the product of the upper limit expiration time and the pre-allocated resource amount, and determine the resource expansion step length of the target account according to the ratio of the product to the upper limit transition time.
[0217] In an optional embodiment, the device further comprises:
[0218] A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the pre-allocated resource amount and the resource usage of the account;
[0219] The first updating submodule is configured to update the upper limit of resource occupation of the account to the smaller value between the sum of the resource occupation of the account and the resource expansion step of the account and the pre-allocated resource amount when the resource occupation of the account is less than or equal to the pre-allocated resource amount and the upper limit of resource occupation of the account is expired.
[0220] In an optional embodiment, the device further comprises:
[0221] A second traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtain the resource occupation amount of the account;
[0222] The second updating submodule is configured to update the resource occupation upper limit of the account to the sum of the resource occupation of the account and the resource expansion step of the account.
[0223] In summary, the embodiment of the present application provides a resource allocation model generation device, which can respond to a new task initiated by any target account among multiple accounts, obtain the target account's task resource occupancy and the target account's resource occupancy upper limit; when the task resource occupancy is less than or equal to the resource occupancy upper limit, allocate resources to the new task; when resource allocation to the new task fails, compare the target account's pre-allocated resource amount with the task resource occupancy; when the task resource occupancy is less than or equal to the pre-allocated resource amount, instruct to perform global resource reduction; and re-allocate resources to the new task after a preset delay. When a new task initiated by a target account that does not exceed the resource usage cannot allocate computing resources, the resource occupancy of other accounts can be reduced, thereby increasing the system's idle resources, avoiding other accounts from occupying resources for a long time, resulting in a situation where the target account's pre-allocated resources cannot be met for a long time, and greatly improving the fairness of allocating computing resources to each account.
[0224] Figure 6 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0225] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0226] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0227] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0228] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0229] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0230] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0231] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0232] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0233] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0234] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to implement a resource allocation method provided in an embodiment of the present application.
[0235] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0236] Figure 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Figure 7 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions that can be executed by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform a resource allocation method provided in an embodiment of the present application.
[0237] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0238] An embodiment of the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the resource allocation method is implemented.
[0239] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0240] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A resource allocation method, It is characterized in that The method comprises: In response to a new task initiated by any target account among the multiple accounts, obtaining the task resource usage of the target account and the resource usage upper limit of the target account; wherein the task resource usage is used to represent the sum of the resource usage of the tasks being run by the target account and the required resource usage of the new task, and the resource usage upper limit is used to represent the maximum resource usage currently allowed by the target account; When the resource occupation amount of the task is less than or equal to the resource occupation upper limit, allocating resources to the new task; In the case where resource allocation for the new task fails, comparing the pre-allocated resource amount of the target account with the resource occupancy of the task; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account; In the case where the task resource occupancy is less than or equal to the pre-allocated resource amount, instructing to perform global resource reduction; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset strategy; After a preset delay time, resources are reallocated to the new task.
2. The method according to claim 1, It is characterized in that The instruction to perform global resource reduction includes: Set resource reduction flags in the system; According to the resource reduction mark, searching for a target other account whose resource occupancy exceeds the pre-allocated resource amount from the multiple accounts; wherein the target other account is an account other than the target account; Reduce the resource usage upper limit of the target other accounts.
3. The method according to claim 2, It is characterized in that The step of searching, according to the resource reduction mark, from the multiple accounts for target other accounts whose resource occupancy exceeds the pre-allocated resource amount comprises: traversing the multiple accounts in a loop at a preset time interval, and for each traversed account, obtaining the resource usage of the account and the pre-allocated resource amount of the account when there is a resource reduction mark in the system; In a case where the resource usage of the account is greater than the pre-allocated resource amount of the account, the account is determined as the target other account.
4. The method according to claim 2 or 3, It is characterized in that The reducing the upper limit of resource usage of the target other accounts includes: Updating the resource usage upper limit of the target other account to the pre-allocated resource amount of the target other account; Clears a resource reduction flag in the system.
5. The method according to claim 1, It is characterized in that The allocating resources to the new task comprises: Obtaining an amount of idle resources, where the amount of idle resources is used to represent the total amount of idle resources remaining in the system; In a case where the idle resource amount is greater than or equal to the required resource amount of the new task, allocating resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task; When the amount of idle resources is less than the amount of required resources for the new task, it is determined that resource allocation for the new task fails.
6. The method according to claim 1, It is characterized in that The method further comprises: Acquire a resource expansion step of the target account, where the resource expansion step is used to update an upper limit value of resource usage of the target account; The resource occupancy upper limit of the target account is initialized to a smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
7. The method according to claim 6, It is characterized in that The obtaining of the resource expansion step of the target account includes: Obtaining an upper limit expiration duration and an upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from updating to expiration of the resource occupation upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length from the initial value of the resource occupation upper limit value of the target account to the pre-allocated resource amount; The product of the upper limit expiration time and the pre-allocated resource amount is calculated, and the resource expansion step of the target account is determined according to the ratio of the product to the upper limit transition time.
8. The method according to claim 1, It is characterized in that The method further comprises: Loop through the multiple accounts at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the pre-allocated resource amount and the resource occupancy amount of the account; When the resource usage of the account is less than or equal to the pre-allocated resource usage of the account, and the upper limit value of the resource usage of the account is expired, the upper limit value of the resource usage of the account is updated to the smaller value between the sum of the resource usage of the account and the resource expansion step of the account and the pre-allocated resource usage.
9. The method according to claim 1, It is characterized in that The method further comprises: Looping through the multiple accounts at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtaining the resource occupation amount of the account; The resource occupation upper limit of the account is updated to the sum of the resource occupation amount of the account and the resource expansion step of the account.
10. A resource allocation device, It is characterized in that The device comprises: an acquisition module, configured to, in response to a new task initiated by any target account among the multiple accounts, acquire the task resource usage of the target account and the resource usage upper limit of the target account; wherein the task resource usage is used to represent the sum of the resource usage of the task being run by the target account and the required resource usage of the new task, and the resource usage upper limit is used to represent the maximum resource usage currently allowed by the target account; an allocation module, configured to allocate resources to the new task when the resource occupation amount of the task is less than or equal to the resource occupation upper limit; A comparison module is configured to compare the pre-allocated resource amount of the target account with the resource occupancy of the task when resource allocation for the new task fails; wherein the pre-allocated resource amount is used to represent the resource amount rated for the target account; A reduction module is configured to instruct global resource reduction when the task resource occupancy is less than or equal to the pre-allocated resource amount; wherein the global resource reduction is used to lower the resource occupancy upper limit of the account whose task resource occupancy exceeds the pre-allocated resource amount among the multiple accounts according to a preset policy; The delay module is configured to re-allocate resources to the new task after delaying for a preset period of time.
11. The device according to claim 10, It is characterized in that The reduction module comprises: a marking submodule, configured to set a resource reduction mark in the system; a reduction target submodule, configured to search, from the multiple accounts, for target other accounts whose resource occupancy exceeds the pre-allocated resource amount according to the resource reduction mark; wherein the target other accounts are accounts other than the target account; The reduction submodule is configured to reduce the resource usage upper limit of the target other account.
12. The device according to claim 11, It is characterized in that The reduction target submodule includes: A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the resource usage of the account and the pre-allocated resource amount of the account; The reduction target determination submodule is configured to determine the account as the target other account when the resource occupation of the account is greater than the pre-allocated resource amount of the account.
13. The device according to claim 11 or 12, It is characterized in that The reduction submodule comprises: An upper limit reduction submodule is configured to update the resource occupation upper limit value of the target other account to the pre-allocated resource amount of the target other account; The clearing submodule is configured to clear the resource reduction mark in the system.
14. The device according to claim 10, It is characterized in that The allocation module comprises: An idle acquisition submodule is configured to acquire an idle resource amount, where the idle resource amount is used to represent the total amount of idle resources remaining in the system; A new task allocation submodule is configured to allocate resources of the same size as the required resource amount from the idle resource amount to the target account to execute the new task when the idle resource amount is greater than or equal to the required resource amount of the new task; The failure submodule is configured to determine that resource allocation to the new task fails when the amount of free resources is less than the amount of required resources for the new task.
15. The device according to claim 10, It is characterized in that The device also includes: A step length acquisition module is configured to acquire a resource expansion step length of the target account, wherein the resource expansion step length is used to update the resource occupation upper limit value of the target account; The upper limit initialization module is configured to initialize the resource occupation upper limit value of the target account to the smaller value between the pre-allocated resource amount and the resource expansion step of the target account.
16. The device according to claim 15, It is characterized in that The step length acquisition module comprises: The duration acquisition submodule is configured to acquire the upper limit expiration duration and the upper limit transition duration of the target account, wherein the upper limit expiration duration is used to characterize the time length from the update to the expiration of the resource occupation upper limit value of the target account, and the upper limit transition duration is used to characterize the expected time length from the initial value of the resource occupation upper limit value of the target account to the pre-allocated resource amount; The step length calculation submodule is configured to calculate the product of the upper limit expiration time and the pre-allocated resource amount, and determine the resource expansion step length of the target account according to the ratio of the product to the upper limit transition time.
17. The device according to claim 10, It is characterized in that The device also includes: A first traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is a resource reduction mark in the system, obtain the pre-allocated resource amount and the resource usage of the account; The first updating submodule is configured to update the upper limit of resource occupation of the account to the smaller value between the sum of the resource occupation of the account and the resource expansion step of the account and the pre-allocated resource amount when the resource occupation of the account is less than or equal to the pre-allocated resource amount and the upper limit of resource occupation of the account is expired.
18. The device according to claim 10, It is characterized in that The device also includes: A second traversal submodule is configured to traverse the multiple accounts in a loop at a preset time interval, and for each traversed account, if there is no resource reduction mark in the system and the resource occupation upper limit value of the account is in an expired state, obtain the resource occupation amount of the account; The second updating submodule is configured to update the resource occupation upper limit of the account to the sum of the resource occupation of the account and the resource expansion step of the account.
19. An electronic device, It is characterized in that include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method as claimed in any one of claims 1 to 9.
20. A computer-readable storage medium, It is characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 9.
21. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
