Resource management method and device, electronic equipment and storage medium
By obtaining resource consumption information of cluster applications and triggering alarms, the problem that K8s resource quota management cannot adapt to resource pool elastic scaling in public cloud environments is solved, and dynamic management and cost control of resource consumption are achieved.
Patent Information
- Application Number
- CN202510327904.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-07-04
AI Technical Summary
The existing K8s resource quota management model does not adapt to the elastic scaling of the resource pool in a public cloud environment, and cannot effectively control resource consumption, resulting in users being unable to control costs based on actual needs.
By obtaining resource consumption information applied in the cluster, alarms are triggered to assist users in cost control. The quota control conditions are pre-configured by the user, including preset consumption rate, concurrent consumption and usage time, so as to achieve dynamic management of resource use.
Accurate cost control in the elastic scaling environment of the resource pool is realized, and users can allocate resources reasonably through the alarm mechanism to adapt to the flexible resource usage needs of the public cloud.
Smart Images

Figure CN120256105A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and particularly to a resource management method, apparatus, electronic device, and storage medium. Background Art
[0002] Resource quotas are used to limit or control the use of cluster resources. For example, in K8s (Kubernetes), resource quotas are used to limit and control the use of cluster resources by Pods (the smallest / simplest basic unit created or deployed by K8s, and a Pod represents a process running on the cluster), Namespaces (namespace), or users, etc. And quota management is the management of resource quotas. Currently, for the traditional situation, that is, when the total resource pool size is fixed and resources are allocated proportionally among different services (cost sharing), when K8s and other public clouds perform resource allocation, quota management uses a static fixed number, and the K8s application cannot exceed this fixed number at any time during operation. In this mode, it does not care about the resource consumption of the application, and users purchase a fixed amount of resources and pay the cost corresponding to this fixed amount of resources. However, currently in the public cloud environment, the public cloud provides a powerful elastic scaling ability for the resource pool, and the total resource pool size is no longer fixed, so the above quota management mode is no longer applicable to this new environment. Summary of the Invention
[0003] The purpose of the embodiments of the present invention is to provide a resource management method, apparatus, electronic device, and storage medium to manage the resource consumption for users to control costs and adapt to the new environment of elastic scaling of the resource pool. The specific technical solutions are as follows:
[0004] In the first aspect of the present invention, a resource management method is provided, including:
[0005] Obtain the resource consumption information of the applications deployed in the cluster, where the resource consumption information is used to represent the resource usage of the applications within a preset time range;
[0006] If the resource consumption information meets the quota control conditions of the application, trigger an alarm, where the alarm is used to assist the users using the application to control costs, and the quota control conditions are pre-configured by the users using the application, where the quota control conditions represent the conditions for controlling the application's usage quota.
[0007] Optionally, the quota control conditions include a preset consumption rate condition and / or a preset concurrent consumption amount condition;
[0008] The step of triggering an alarm if the resource consumption information meets the quota control conditions of the application includes:
[0009] Calculate the consumption rate of the application for resources based on the relationship between the preset time range and the preset time window; if the consumption rate meets the preset consumption rate condition, trigger a first alarm; and / or,
[0010] Based on the resource consumption information, count the types of resources used by the application within the preset time range as the concurrent consumption amount of resources by the application; if the concurrent consumption amount meets the preset concurrent consumption amount condition, trigger a second alarm.
[0011] Optionally, the consumption rate includes the consumption rates of different time windows; the preset consumption rate condition includes the consumption rate conditions corresponding to different time windows respectively;
[0012] The step of triggering a first alarm if the consumption rate meets the preset consumption rate condition includes:
[0013] If the consumption rate of any time window meets the consumption rate condition corresponding to the time window respectively, trigger a first alarm.
[0014] Optionally, the quota control condition includes a preset usage duration condition;
[0015] The step of triggering an alarm if the resource consumption information meets the quota control condition of the application includes:
[0016] Deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota. The initial value of the resource quota is determined according to the total amount of resources configured by the user using the application, and the resource quota changes as the application is used;
[0017] Take the quotient of the updated quota and the current consumption rate as the available resource usage duration, where the current consumption rate is obtained based on the resource consumption information acquired within the current period;
[0018] If the available resource usage duration meets the preset usage duration condition, trigger a third alarm.
[0019] Optionally, the step of triggering an alarm if the resource consumption information meets the quota control condition of the application includes:
[0020] Deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota. The initial value of the resource quota is determined according to the amount of resources configured by the user using the application;
[0021] If the updated resource quota is not greater than a preset threshold, trigger a fourth alarm.
[0022] Optionally, after triggering the fourth alarm, the method further includes:
[0023] Determine whether processing of the quota for the application is received within a preset duration, where the processing includes increasing the quota;
[0024] If not, downgrade the specification of the application to the lowest level, where downgrading the specification to the lowest level means that the application cannot use the resources in the cluster.
[0025] In a second aspect of the implementation of the present invention, a resource management device is provided, including:
[0026] An acquisition module, configured to acquire resource consumption information of applications deployed in a cluster, where the resource consumption information is used to represent the resource usage of the application within a preset time range;
[0027] An alarm module, configured to trigger an alarm if the resource consumption information meets the quota control condition of the application, where the alarm is used to assist the user using the application in cost control, and the quota control condition is pre-configured by the user using the application, where the quota control condition represents the condition for controlling the quota used by the application.
[0028] Optionally, the quota control condition includes a preset consumption rate condition and / or a preset concurrent consumption amount condition;
[0029] Specifically, the alarm module is configured to calculate the consumption rate of the application for resources based on the relationship between the preset time range and the preset time window; if the consumption rate meets the preset consumption rate condition, trigger a first alarm; and / or, based on the resource consumption information, count the types of resources used by the application within the preset time range as the concurrent consumption amount of the application for resources; if the concurrent consumption amount meets the preset concurrent consumption amount condition, trigger a second alarm.
[0030] In yet another aspect of the implementation of the present invention, an electronic device is further provided, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0031] The memory is used to store a computer program;
[0032] The processor is configured to implement the resource management method described in any one of the above when executing the program stored in the memory.
[0033] In yet another aspect of the implementation of the present invention, a computer-readable storage medium is further provided, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the resource management method described in any one of the above is implemented.
[0034] In yet another aspect of the implementation of the present invention, there is also provided a computer-readable storage medium storing a computer program therein, and when the computer program is executed by a processor, the resource management method described in any one of the above is implemented.
[0035] In yet another aspect of the implementation of the present invention, there is also provided a computer program product containing instructions, and when it runs on a computer, it causes the computer to execute the resource management method described in any one of the above.
[0036] In an embodiment of the present invention, resource consumption information of an application deployed in a cluster is obtained, and the resource consumption information is used to represent the resource usage situation of the application within a preset time range; if the resource consumption information meets the quota control condition of the application, an alarm is triggered, and the alarm is used to assist the user using the application in cost control, and the quota control condition is pre-configured by the user using the application. In this way, an alarm is triggered based on the matching situation between the resource consumption information of the application and the quota control condition to assist the user using the application in cost control. In the face of elastic scaling of the resource pool, cost control can also be achieved by managing resource consumption so as to facilitate cost control for the user, such as adapting to the new environment of elastic scaling of the resource pool. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art.
[0038] Figure 1 It is a flowchart of the resource management method provided by an embodiment of the present application;
[0039] Figure 2 It is an application schematic diagram of the resource management method provided by an embodiment of the present application;
[0040] Figure 3 It is another application schematic diagram of the resource management method provided by an embodiment of the present application;
[0041] Figure 4 It is yet another application schematic diagram of the resource management method provided by an embodiment of the present application;
[0042] Figure 5 It is a schematic structural diagram of a resource management device provided by an embodiment of the present application;
[0043] Figure 6 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0044] The following will describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention.
[0045] An embodiment of the present invention provides a resource management method, as follows Figure 1 shown, including:
[0046] S101, obtaining resource consumption information of applications deployed in the cluster, where the resource consumption information is used to represent the resource usage of the applications within a preset time range;
[0047] S102, if the resource consumption information meets the quota control condition of the application, triggering an alarm, where the alarm is used to assist the users using the application in cost control, and the quota control condition is pre-configured according to the users using the application, where the quota control condition represents the condition for controlling the application usage quota.
[0048] In the embodiment of the present invention, resource consumption information of applications deployed in the cluster is obtained, where the resource consumption information is used to represent the resource usage of the applications within a preset time range; if the resource consumption information meets the quota control condition of the application, an alarm is triggered, and the alarm is used to assist the users using the application in cost control, and the quota control condition is pre-configured according to the users using the application. In this way, an alarm is triggered based on the matching of the resource consumption information of the application and the quota control condition to assist the users using the application in cost control. In the face of the elastic scaling of the resource pool, the resource consumption can also be managed to facilitate the users in cost control, such as to adapt to the new environment of the elastic scaling of the resource pool.
[0049] The resource management method provided by the embodiment of the present invention can be applied to an electronic device, specifically a server, a controller, etc. In one implementation manner, the resource management method provided by the embodiment of the present invention is specifically applied to a quota controller, and the quota controller is used to interact with applications, business terminals, etc. in the cluster.
[0050] In S101, the cluster can specifically be K8s.
[0051] The resource is the cluster resource, where the cluster resource can include resources such as storage, memory, CPU (Central Processing Unit), and various types of GPUs (Graphics Processing Unit).
[0052] The preset time range can be determined according to actual needs or experience, etc. For example, regularly obtaining the resource usage of the application, such as obtaining the resource usage of the application weekly, daily, or hourly, and the preset time range can be one week, one day, or one hour, etc.
[0053] In S102, the quota control condition is pre-configured according to the users using the application, and can specifically be configured according to experience and actual needs.
[0054] Quota control conditions may include conditions for controlling an application's use of cluster resources from different dimensions. Different dimensions may include dimensions such as resource consumption, concurrent resource use, remaining quota available usage duration, etc. The condition for controlling an application's use of cluster resources from the dimension of resource consumption can be understood as a preset consumption rate condition, the condition for controlling an application's use of cluster resources from the dimension of concurrent resource use can be understood as a preset concurrent consumption amount condition, and the condition for controlling an application's use of cluster resources from the dimension of resource consumption can be understood as a preset usage duration condition.
[0055] In an embodiment of the present invention, triggering an alarm may be sending an alarm message to the service end, and the service end may be a client installed in the device used by the user who uses the above application, etc.
[0056] The alarm is used to assist the user using the application in cost control. After the alarm is triggered, when the user receives the alarm, they can determine whether to increase the cost according to actual requirements, etc. If needed, the total amount of resources that the application can use can be configured; if not, no processing is required.
[0057] In an optional embodiment, the quota control conditions include a preset consumption rate condition and / or a preset concurrent consumption amount condition;
[0058] S102 includes: calculating the consumption rate of resources by the application based on the relationship between a preset time range and a preset time window; if the consumption rate meets the preset consumption rate condition, triggering a first alarm; and / or, based on the resource consumption information, counting the types of resources used by the application within the preset time range as the concurrent consumption amount of resources by the application; if the concurrent consumption amount meets the preset concurrent consumption amount condition, triggering a second alarm.
[0059] Alarms are triggered through these two parameters, the consumption rate and the concurrent consumption amount, to accurately reflect the resource usage situation.
[0060] The first alarm and the second alarm are essentially both alarms, and the only difference between them is that they are alarms triggered by different types of quota control conditions.
[0061] Regarding the quota control condition including a preset consumption rate condition, if the consumption rate meets the preset consumption rate condition, the following explanation is made for triggering the first alarm:
[0062] Among them, the preset consumption rate condition represents a limiting condition for using resources within a preset time window, such as not exceeding a certain amount per day (such as can be expressed as "not exceeding XX per day", and "XX" can also be understood as the consumption rate defined in the preset consumption rate condition), not exceeding a certain maximum amount per hour (such as can be expressed as "not exceeding YY per hour", and "YY" can also be understood as the consumption rate defined in the preset consumption rate condition), etc.
[0063] The consumption rate meets the preset consumption rate condition, which may specifically include that the consumption rate is not less than the consumption rate defined in the preset consumption rate condition.
[0064] The resource consumption information is used to represent the resource usage of an application within a preset time range. In one implementation, the preset time range is equal to the preset time window, and the consumption rate corresponding to the preset time window is the above-obtained resource consumption information. For example, both the preset time range and the preset time window are one day, one hour, etc.
[0065] In another implementation, the preset time range is greater than the preset time window, and based on the relationship between the preset time range and the preset time window, the consumption rate of the application for resources is calculated. For example, the above preset time range is one week, the preset time window is one day, and one week contains 7 days, then the ratio of the above-obtained resource consumption information to 7 is used as the consumption rate corresponding to the preset time window.
[0066] In yet another implementation, the preset time range is less than the preset time window, then the resource consumption information of multiple target preset time ranges (the cumulative sum of multiple target preset time ranges is equal to the preset time window) can be first counted, and the sum of the resource consumption information of multiple target preset time ranges is used as the consumption rate corresponding to the preset time window. For example, the preset time range is one hour, the preset time window is one day, then the resource consumption information per hour within each day can be counted, and the total sum of the resource consumption information for 24 hours in a day is used as the consumption rate for one day.
[0067] This situation can also be understood as calculating the consumption rate corresponding to the preset time window by combining historical data. For example, the preset time range is one hour, the preset time window is one day. After obtaining the resource consumption information of the preset time range, multiple historical data before the preset time range can be obtained, such as the resource consumption information per hour for the previous 23 hours. In this way, the resource consumption information for these 24 hours is counted, and the total sum of the resource consumption information for 24 hours is used as the consumption rate for one day. Or, the total sum of the resource consumption information for 24 hours within a day can be counted at a fixed time every day (such as 23:59 every day) as the consumption rate for this day.
[0068] When the quota control condition includes the preset consumption rate condition, in the process of calculating the consumption rate of the application for resources based on the relationship between the preset time range and the preset time window, in one implementation, the consumption rate includes the consumption rates for different time windows; the preset consumption rate condition includes the consumption rate conditions corresponding to different time windows respectively;
[0069] If the consumption rate meets the preset consumption rate condition, then a first alarm is triggered, including:
[0070] If the consumption rate of any time window meets the consumption rate conditions corresponding to the time window respectively, a first alarm is triggered.
[0071] In this case, there are at least two time windows, such as the time windows including 1 day and 1 hour.
[0072] Each time window respectively corresponds to the consumption rate condition corresponding to the time window. For a time window, the consumption rate condition corresponding to the time window represents the restriction condition for using resources within the time window. For example, when the time window is 1 day, the corresponding consumption rate condition is not exceeding a certain amount per day, and when the time window is 1 hour, the corresponding consumption rate condition is not exceeding a certain maximum amount per hour. The embodiments of the present invention simultaneously include the consumption rate conditions corresponding to a 1-day time window and a 1-hour time window.
[0073] The method for calculating the consumption rate corresponding to a single time window is the same as that in the above embodiments based on the relationship between the preset time range and the preset time window, calculating the consumption rate of the application for resources. It has been described in detail in the above embodiments and will not be elaborated here.
[0074] Calculate the consumption rate corresponding to each time window respectively. For each time window, if the consumption rate of the time window meets the consumption rate conditions corresponding to the time window respectively, an alarm is triggered.
[0075] In the embodiments of the present invention, by calculating the consumption rates corresponding to each of the multiple time windows respectively and controlling different time windows, the management accuracy can be improved.
[0076] Regarding the quota control condition including the preset concurrent consumption amount condition, if the concurrent consumption amount meets the preset concurrent consumption amount condition, a second alarm is triggered and the following is described:
[0077] The concurrent consumption amount can be understood as the types of resources used simultaneously at the same time, or the types of resources can also be referred to as the amount of resources, that is, several types of resources. In an example, the amount of resources can specifically include the amounts of different types of resources, such as how much CPU and how much memory.
[0078] The preset concurrent consumption amount condition is used to limit the amount of resources used simultaneously at the same time, and specifically can be the maximum concurrent consumption amount.
[0079] The concurrent consumption amount meets the preset concurrent consumption amount condition, which can specifically include that the concurrent consumption amount is not less than the maximum concurrent consumption amount defined by the preset concurrent consumption amount condition.
[0080] In another alternative embodiment, the quota control condition may include a preset usage duration condition;
[0081] In this case, S102 may include: deducting the resource consumption information from the resource quota of the application to obtain the updated resource quota. The initial value of the resource quota is determined according to the total amount of resources configured by the user using the application, and the resource quota changes as the application is used; taking the quotient of the updated quota and the current consumption rate as the available resource duration, where the current consumption rate is obtained based on the resource consumption information acquired within the current period; if the available resource duration meets the preset usage duration condition, then trigger the third alarm.
[0082] The third alarm is essentially the same as the above-mentioned first alarm and second alarm, all being alarms, with the only difference being the conditions for triggering the alarm.
[0083] The initial value of the resource quota is also the total amount of the resource quota initially set. The resource quota changes as it is used, and it has an initial total amount, which is the above-mentioned initial value of the resource quota.
[0084] For example, the quota is 100 * 365 cores * days, and the deduction is counted according to the actual usage amount every day.
[0085] The available resource duration can also be understood as the estimated remaining consumption time of the quota remaining amount.
[0086] The preset usage duration condition is used to limit the available resource duration, and specifically can be that the remaining quota usage time is less than x days, y hours, etc.
[0087] The available resource duration meeting the preset usage duration condition may specifically include that the available resource duration is less than the available resource duration limited by the preset usage duration condition, such as the above-mentioned x days, y hours, etc.
[0088] In one implementable manner, when the application changes the specification or the number of running instances, a request is made to check the quota. At this time, the duration that can be continuously used under this configuration can be calculated, that is, the above-mentioned preset usage duration condition calculated, and provided for the business reference.
[0089] In another alternative embodiment, if the resource consumption information meets the quota control condition of the application, then trigger an alarm, including:
[0090] Deducting the resource consumption information from the resource quota of the application to obtain the updated resource quota. The initial value of the resource quota is determined according to the amount of resources configured by the user using the application; if the updated resource quota is not greater than the preset threshold, then trigger the fourth alarm.
[0091] The fourth alarm is essentially the same as the above-mentioned first alarm, second alarm, and third alarm, all being alarms, with the only difference being the conditions for triggering the alarm.
[0092] The preset threshold can be determined according to actual requirements, experience, etc.
[0093] In the embodiments of the present invention, alarms can also be triggered from the perspective of the remaining resource quota to further assist users in cost control from more dimensions and achieve more refined management.
[0094] In yet another alternative embodiment, after triggering the fourth alarm, it may further include: determining whether a processing for the quota of the application is received within a preset duration, where the processing includes increasing the quota; if not, downgrading the specification of the application to the lowest level, and downgrading the specification to the lowest level means that the application cannot use the resources in the cluster.
[0095] Downgrading the specification can be understood as a more severe processing after the alarm. In the early stage, triggering the alarm reminds the business personnel to process, such as increasing the quota, that is, purchasing resources. However, if it is not processed in time, the configured application cannot use the cluster resources. Specifically, the specification of the application is downgraded to the lowest level, for example, downgrading the specification to level 0.
[0096] The resource management method provided by the embodiments of the present invention will be described below in conjunction with specific embodiments.
[0097] When allocating resources in public clouds such as K8s, quota management uses a static fixed number, and the K8s application cannot exceed this fixed number at any time during operation. This mode is suitable for traditional situations, that is, the total resource pool size is fixed and resources are allocated proportionally among various services (sharing costs). However, currently in the public cloud environment, the public cloud provides a powerful elastic scaling ability for the resource pool, and the total resource pool size is no longer fixed. Services can use resources more flexibly. Correspondingly, the way to control budget expenditure also needs to change from controlling the fixed amount of resources to controlling the actual cost within the billing cycle. For example, in some periods, the business volume is relatively large, so the application uses more resources, while in another period, the business volume is relatively small, so the application uses fewer resources. If the existing method of controlling that the application cannot exceed a static fixed number at any time is used, the way that users purchase resources with a fixed number and pay the cost corresponding to the resources with this fixed number is obviously no longer applicable.
[0098] For example, the budget of the service supports the use of 100 cores for one year. In the old mode, the quota is 100 cores (or slightly higher than 100 cores according to the utilization rate), and the usage amount cannot exceed the threshold at any time.
[0099] In the new mode, the quota is 100 * 365 core * days, and the actual usage amount is deducted daily for statistics. The embodiments of the present invention can implement a K8s resource quota management that can be prepaid.
[0100] Embodiments of the present invention perform cost control according to the actual usage of resources to adapt to a new environment with elastic scaling of the resource pool. Specifically, resource consumption information indicating the actual resource usage of an application is obtained, and an alarm is triggered based on the matching between the resource consumption information of the application and the quota control conditions to assist the user using the application in cost control. In the face of elastic scaling of the resource pool, cost control can also be achieved by managing the resource consumption to facilitate the user's cost control, such as adapting to a new environment with elastic scaling of the resource pool.
[0101] In embodiments of the present invention, the time dimension is introduced into the quota management mechanism, and the control method for the upper limit of application usage is changed from a fixed value to the cumulative value of a time window to more accurately manage the consumption of elastically scalable resources (server costs) in a cloud-native environment.
[0102] Specifically, it can be applied to the process of accurately controlling the costs of each service in a public cloud K8s.
[0103] In embodiments of the present invention, a new quota controller is added, and the resource management method provided by embodiments of the present invention is implemented through this quota controller.
[0104] Such as Figure 2 As shown, a business person (such as a user using an application in a cluster) submits quota control conditions and the total amount of resource quotas to the quota controller through the business terminal. The total amount of resource quotas is the initially set total amount of resource quotas, that is, the initial value of the resource quota, and its value changes with usage.
[0105] Specifically, the business terminal can send a submission request to the quota controller. After receiving the submission request, the quota controller triggers the business terminal to display an interactive interface, and the business person inputs the information to be submitted through the interactive interface displayed on the business terminal.
[0106] Among them, submitting the initial value of the resource quota can also be simply understood as submitting a quota. The unit of the resource quota is CPU core number * duration, memory size × duration, disk size * duration, etc.
[0107] The quota control conditions can also be understood as a general term for quota usage control conditions and alarm conditions.
[0108] The quota usage control conditions can include the above-mentioned preset consumption rate conditions and the above-mentioned preset concurrent consumption amount conditions. Among them, the preset consumption rate conditions are such as the consumption rate (not exceeding how much per day, not exceeding the maximum per hour), and the preset concurrent consumption amount conditions are such as the maximum concurrent consumption amount (the number of resources used simultaneously), etc.
[0109] The alarm conditions mentioned here can include the above-mentioned preset usage duration conditions, such as the remaining quota usage time is less than x days, y hours, etc.
[0110] To prevent unreasonable budget consumption, in the embodiments of the present invention, the maximum usage amount (such as the above-mentioned maximum concurrent consumption amount) can be restricted, or the consumption rate can be evaluated daily and an exception alarm can be issued (such as the above-mentioned if the consumption rate meets the preset consumption rate condition, the first alarm is triggered), and so on.
[0111] As Figure 3 shown, when the application changes the specification or the number of running instances, a request for checking the quota is sent to the quota controller, and the quota controller calculates the sustainable usage duration under this configuration and provides it for the business reference.
[0112] The specification mentioned in the application specification change can be understood as the specification of the running instances used by the application, specifically the amount of resources used by the instances, such as the memory size occupied by the instances, the CPU size occupied, etc.
[0113] Specifically, the change of the application specification or the number of running instances can be triggered by the business side. After the quota controller receives the request for quota check sent by the application, it calculates the sustainable usage duration.
[0114] The sustainable usage duration is the remaining quota sustainable usage duration, specifically the above-mentioned resource available duration, and the specific calculation method is as follows:
[0115] Deduct the resource consumption information from the resource quota of the application to obtain the updated resource quota. The initial value of the resource quota is determined according to the total amount of resources configured by the user using the application, and the resource quota changes as the application is used; take the quotient of the updated quota and the current consumption rate as the resource available duration, and the current consumption rate is obtained based on the resource consumption information obtained within the current period.
[0116] As Figure 4 shown, the quota controller manages the resource quota according to the actual resource usage of the application, and specifically can perform the following process:
[0117] 1. Periodically check the usage amount of the application and deduct it from the quota;
[0118] The quota controller regularly obtains the resource usage amounts of each application and deducts them from the quota.
[0119] Specifically, the resource consumption information of the applications deployed in the cluster can be obtained, and the resource consumption information is deducted from the resource quota of the application to obtain the updated resource quota, and the updated resource quota is also the current remaining resource quota.
[0120] 2. Calculate the consumption rates in different time windows, and issue an alarm if the quota usage control condition is reached;
[0121] The quota usage control conditions here specifically include the above-mentioned preset consumption rate conditions. Specifically, the method of calculating the consumption rate for different time windows has been described in detail in the above embodiments and will not be elaborated here.
[0122] 3. Calculate the estimated remaining consumption time of the quota remaining amount according to the current consumption rate, and give an alarm if the alarm condition is met;
[0123] This process can also be understood as: calculating the duration that each application can continue to use; if the alarm condition is met, notify the business personnel.
[0124] Specifically, deduct the resource consumption information from the resource quota of the application to obtain the updated resource quota. The initial value of the resource quota is determined according to the total amount of resources configured by the user using the application, and the resource quota changes as the application is used; take the quotient of the updated quota and the current consumption rate as the duration that the resources can be used. The current consumption rate is obtained based on the resource consumption information acquired within the current period; if the duration that the resources can be used meets the preset usage duration condition, an alarm is triggered.
[0125] 4. If the quota balance is insufficient, notify the business personnel to handle it. If it is not handled after the timeout, downgrade the application specification to 0.
[0126] Specifically, deduct the resource consumption information from the resource quota of the application to obtain the updated resource quota, that is, the current remaining resource quota. If the current remaining resource quota is not greater than the preset threshold, an alarm is triggered.
[0127] Downgrading the application specification to 0 can specifically be configuring the application to be unable to use the cluster resources.
[0128] The specification downgrade can be understood as a more serious handling after the alarm. In the early stage, an alarm is triggered to remind the business personnel to handle it, such as increasing the quota, that is, purchasing resources. However, if it is not handled after the timeout, configure the application to be unable to use the cluster resources, specifically downgrading the application specification to the lowest level, for example, downgrading the specification to level 0.
[0129] In view of the existing resource quota management, regardless of how much is used, a fixed amount of resources is purchased at a fixed cost. Therefore, the specific usage situation is not concerned during the usage process. The embodiments of the present invention are to apply to the scenario of this quota management, to give an alarm according to the specific usage situation to remind the user whether it is necessary to increase the cost, etc., and give an alarm according to the specific resource usage situation to facilitate the user to control the cost and adapt to the elastic scaling cluster environment.
[0130] Corresponding to the resource management method provided in the above embodiment, the embodiment of the present invention also provides a resource management device, as Figure 5 shown, including:
[0131] An acquisition module 501 is configured to acquire resource consumption information of an application deployed in a cluster, where the resource consumption information is used to represent the resource usage of the application within a preset time range;
[0132] An alarm module 502 is configured to trigger an alarm if the resource consumption information meets the quota control condition of the application. The alarm is used to assist the user using the application in cost control. The quota control condition is pre-configured by the user using the application, where the quota control condition represents the condition for controlling the application usage quota.
[0133] Optionally, the quota control condition includes a preset consumption rate condition and / or a preset concurrent consumption amount condition;
[0134] The alarm module 502 is specifically configured to calculate the consumption rate of the application for resources based on the relationship between the preset time range and the preset time window; if the consumption rate meets the preset consumption rate condition, trigger a first alarm; and / or, based on the resource consumption information, count the types of resources used by the application within the preset time range as the concurrent consumption amount of the application for resources; if the concurrent consumption amount meets the preset concurrent consumption amount condition, trigger a second alarm.
[0135] Optionally, the consumption rate includes the consumption rates of different time windows; the preset consumption rate condition includes the consumption rate conditions respectively corresponding to different time windows;
[0136] The alarm module 502 is specifically configured to trigger a first alarm if the consumption rate of any time window meets the consumption rate condition respectively corresponding to the time window.
[0137] Optionally, the quota control condition includes a preset usage duration condition;
[0138] The alarm module 502 is specifically configured to deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota. The initial value of the resource quota is determined according to the total amount of resources configured by the user using the application, and the resource quota changes as the application is used; take the quotient of the updated quota and the current consumption rate as the available resource usage duration, where the current consumption rate is obtained based on the resource consumption information acquired within the current period; if the available resource usage duration meets the preset usage duration condition, trigger a third alarm.
[0139] The alarm module 502 is specifically configured to deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota. The initial value of the resource quota is determined according to the amount of resources configured by the user using the application; if the updated resource quota is not greater than a preset threshold, trigger a fourth alarm.
[0140] Optionally, the device further includes:
[0141] A downgrading module is used to determine whether a process for the quota of an application is received within a preset duration. The process includes increasing the quota. If not, the specification of the application is downgraded to the lowest level, and downgrading the specification to the lowest level means that the application cannot use the resources in the cluster.
[0142] An embodiment of the present invention further provides an electronic device, as Figure 6 shown, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604. Among them, the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0143] The memory 603 is used to store a computer program.
[0144] When the processor 601 is used to execute the program stored on the memory 603, the method steps of the above resource management method are implemented.
[0145] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0146] The communication interface is used for communication between the above terminal and other devices.
[0147] The memory may include a Random Access Memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0148] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU for short), a Network Processor (NP for short), etc.; it may also be a Digital Signal Processor (DSP for short), an Application Specific Integrated Circuit (ASIC for short), a Field-Programmable Gate Array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0149] In another embodiment provided by the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the resource management method described in any one of the above embodiments is implemented.
[0150] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, and when it runs on a computer, the computer is caused to execute the resource management method described in any one of the above embodiments.
[0151] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server, data center, etc. that includes one or more integrated available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
[0152] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0153] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the apparatus, electronic device, storage medium and computer program product, since they are basically similar to the method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for the relevant content.
[0154] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.
Claims
1. A resource management method, characterized in that, Including: Obtain the resource consumption information of the applications deployed in the cluster, where the resource consumption information is used to represent the resource usage of the applications within a preset time range; If the resource consumption information meets the quota control conditions of the application, trigger an alarm, where the alarm is used to assist the users using the application in cost control, and the quota control conditions are pre-configured by the users using the application, where the quota control conditions represent the conditions for controlling the usage quota of the application.
2. The method according to claim 1, wherein The quota control conditions include preset consumption rate conditions and / or preset concurrent consumption quantity conditions; The "if the resource consumption information meets the quota control conditions of the application, trigger an alarm" includes: Based on the relationship between the preset time range and the preset time window, calculate the consumption rate of the application for resources; If the consumption rate meets the preset consumption rate conditions, trigger a first alarm; and / or, Based on the resource consumption information, count the types of resources used by the application within the preset time range as the concurrent consumption quantity of the application for resources; if the concurrent consumption quantity meets the preset concurrent consumption quantity conditions, trigger a second alarm.
3. The method according to claim 2, wherein The consumption rate includes the consumption rates of different time windows; the preset consumption rate conditions include the consumption rate conditions corresponding to different time windows respectively; The "if the consumption rate meets the preset consumption rate conditions, trigger a first alarm" includes: If the consumption rate of any time window meets the consumption rate conditions corresponding to the time window respectively, trigger a first alarm.
4. The method according to claim 1, wherein The quota control conditions include preset usage duration conditions; The "if the resource consumption information meets the quota control conditions of the application, trigger an alarm" includes: Deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota, where the initial value of the resource quota is determined according to the total amount of resources configured by the users using the application, and the resource quota changes as the application is used; Take the quotient of the updated quota and the current consumption rate as the available resource usage duration, where the current consumption rate is obtained based on the resource consumption information acquired within the current period; If the available resource usage duration meets the preset usage duration conditions, trigger a third alarm.
5. The method according to claim 4, wherein The "if the resource consumption information meets the quota control conditions of the application, trigger an alarm" includes: Deduct the resource consumption information from the resource quota of the application to obtain an updated resource quota, where the initial value of the resource quota is determined according to the amount of resources configured by the users using the application; If the updated resource quota is not greater than a preset threshold, trigger a fourth alarm.
6. The method according to claim 5, characterized in that, After triggering the fourth alarm, the method further includes: Judge whether a processing for the quota of the application is received within a preset duration, where the processing includes increasing the quota; If not, downgrade the specification of the application to the lowest level, where downgrading the specification to the lowest level means that the application cannot use the resources in the cluster.
7. A resource management device, characterized in that, Including: An acquisition module, configured to acquire resource consumption information of an application deployed in a cluster, where the resource consumption information is used to represent the resource usage of the application within a preset time range; An alarm module, configured to trigger an alarm if the resource consumption information meets the quota control condition of the application, where the alarm is used to assist the user using the application in cost control, and the quota control condition is pre-configured by the user using the application, and where the quota control condition represents a condition for controlling the usage quota of the application.
8. The device according to claim 7, characterized in that, The quota control condition includes a preset consumption rate condition and / or a preset concurrent consumption amount condition; The alarm module is specifically configured to calculate the consumption rate of the application for resources based on the relationship between the preset time range and the preset time window; if the consumption rate meets the preset consumption rate condition, trigger a first alarm; and / or, based on the resource consumption information, count the types of resources used by the application within the preset time range as the concurrent consumption amount of the application for resources; if the concurrent consumption amount meets the preset concurrent consumption amount condition, trigger a second alarm.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store a computer program; The processor, when executing the program stored on the memory, implements the method steps described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the method steps described in any one of claims 1-6.