Automatic expansion and contraction method, device, equipment and readable storage medium
By collecting and comparing indicators of container clusters and containerized applications, and automatically judging and performing scaling operations, the dynamic problem of scaling requirements in container technology applications is solved, the matching of resources and business requirements is achieved, and the flexibility and efficiency of container clusters are improved.
Patent Information
- Application Number
- CN202111595247.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-12-23
AI Technical Summary
In container technology application scenarios, how to automatically achieve capacity expansion or shrinkage to adapt to load changes and dynamics of resource requirements.
By collecting machine indicators of container clusters and business indicators of containerized applications, comparing these indicators with preset expected indicators, determining whether capacity expansion or capacity reduction is needed, and obtaining the capacity expansion plan based on the current allocation quota of resources, and finally performing the capacity expansion operation.
It realizes automatic expansion or reduction in load changes, ensuring that resource allocation matches business requirements, and improving the flexibility and efficiency of container clusters.
Smart Images

Figure CN114327884B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to an automatic scaling method, device, equipment, and readable storage medium. Background Art
[0002] Container technology can effectively divide the resources of a single operating system into isolated groups so as to better balance conflicting resource usage requirements between isolated groups. Therefore, based on the technical effects that container technology itself can bring, container technology has been widely used in the computer field.
[0003] However, in actual application scenarios, we often encounter situations where we need to expand capacity. As the scale grows, more and more applications need to use container technology, and the number of users increases. At this time, we need to expand capacity. In addition, we often encounter situations where we need to shrink capacity. As the load decreases and the number of users decreases, we need to shrink capacity. Therefore, how to achieve expansion or shrinkage in the corresponding scenarios has become the focus of people's attention. Summary of the invention
[0004] In view of this, the present application provides an automatic scaling method, apparatus, device and readable storage medium for achieving scaling in or out in corresponding scenarios.
[0005] In order to achieve the above objectives, the proposed solution is as follows:
[0006] An automatic expansion and contraction method, comprising:
[0007] Collecting machine indicators of the container cluster, business indicators of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application;
[0008] Compare the sizes of the machine indicators, the business indicators of each type and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result;
[0009] When capacity expansion or reduction is required, obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result;
[0010] Execute the capacity expansion plan or the capacity reduction plan.
[0011] Optionally, comparing the sizes of the machine indicators and the business indicators of each type with preset expected indicators includes:
[0012] According to the business's demand for each type of resource, determine the target resource type that needs to be allocated to the business, the target resource type includes any one or more of the following: CPU resources, memory resources, network bandwidth, and number of containers;
[0013] Referring to the preset correspondence between each resource type and the indicator, determining the machine indicator and the business indicator corresponding to each of the target resource types from among the collected machine indicators and business indicators;
[0014] Calculate the ratio between the machine index and business index corresponding to each target resource type and the preset expected index as the comparison result;
[0015] The determining whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result includes:
[0016] If the ratio is greater than 1, it is determined that the containerized application needs to be expanded;
[0017] If the ratio is less than 1, it is determined that the containerized application needs to be scaled down.
[0018] Optionally, the acquiring a capacity expansion plan or a capacity reduction plan based on the current resource allocation amount and the comparison result includes:
[0019] Based on the current allocation amount of the resource and the ratio, obtaining a target allocation amount of the resource;
[0020] Based on the resource target allocation quota, a capacity expansion or reduction plan is obtained.
[0021] Optionally, obtaining a target resource allocation amount based on the current resource allocation amount and the ratio includes:
[0022] Obtaining a preset correction coefficient for controlling the expansion and contraction range;
[0023] Multiplying the ratio, the current allocation amount of the resource and the correction coefficient;
[0024] The result after multiplication is rounded to obtain a rounded result;
[0025] Based on the rounded result, the resource target allocation amount is obtained.
[0026] Optionally, obtaining a resource target allocation amount based on the rounded result includes:
[0027] Determine whether the rounded result is less than a preset maximum resource allocation amount and greater than a preset minimum resource allocation amount, and obtain a determination result;
[0028] When the judgment result indicates that the rounded result is less than the preset maximum resource allocation amount and greater than the preset minimum resource allocation amount, the rounded result is used as the final resource target allocation amount.
[0029] Optionally, after determining whether the rounded result is less than a preset maximum resource allocation amount and greater than a preset minimum resource allocation amount, obtaining the determination result, the method further includes:
[0030] When the judgment result shows that the rounded result is less than the preset minimum resource allocation amount, the preset minimum resource allocation amount is used as the final resource target allocation amount;
[0031] or,
[0032] When the judgment result indicates that the rounded result is greater than the preset maximum resource allocation amount, the maximum resource allocation amount is used as the final resource target allocation amount.
[0033] Optionally, the executing the capacity expansion plan or the capacity reduction plan includes:
[0034] Use horizontal expansion and / or vertical expansion to implement expansion or reduction plans.
[0035] An automatic expansion and contraction device, comprising:
[0036] An indicator collection unit, used to collect indicators of each machine in the container cluster and various types of business indicators of the same business of the containerized application and the current allocation quota of resources allocated to the containerized application;
[0037] A capacity expansion and contraction confirmation unit, used to compare the sizes of the machine indicators, the business indicators of each type and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result;
[0038] A solution confirmation unit, used for obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result when capacity expansion or reduction is required;
[0039] A solution execution unit is used to execute the capacity expansion solution or the capacity reduction solution.
[0040] An automatic expansion and contraction device includes a memory and a processor;
[0041] The memory is used to store programs;
[0042] The processor is used to execute the program to implement each step of the above-mentioned automatic expansion and contraction method.
[0043] A readable storage medium stores a computer program, and when the computer program is executed by a processor, each step of the automatic scaling method described above is implemented.
[0044] It can be seen from the above technical solutions that the present application provides an automatic scaling method. First, the machine indicators of the container cluster and the various types of business indicators of the same business of the containerized application and the current allocation quota of resources allocated to the containerized application can be collected, wherein each type of business indicator corresponds to the business and is an indicator reported by the business, such as, for example, the query rate per second and the number of transactions per second and other indicators; then, the size of the machine indicators, the various types of business indicators and the preset expected indicators can be compared, and based on the comparison results, it can be judged whether it is necessary to expand or shrink the containerized application; that is, by comparing the size of the machine indicators, the various types of business indicators and the preset expected indicators, it is judged whether it is necessary to allocate more resources to the business or allocate fewer resources to the business; then, when expansion or shrinking is required, based on the current allocation quota of the resources and the comparison results, an expansion plan or a shrinking plan is obtained, and the expansion plan or the shrinking plan includes the resources that need to be allocated to the containerized application; finally, the expansion plan or the shrinking plan can be executed, that is, expansion or shrinking is achieved. It can be seen that the present application can realize automatic expansion in scenarios where expansion is required and automatic reduction in scenarios where reduction is required.
[0045] In addition, the basis for this application to confirm the expansion plan and the reduction plan is not only the machine indicators of the container cluster, but also includes various types of business indicators. Each type of business indicator corresponds to a certain business in the containerized application, and each type of business indicator is an indicator reported by the business. In this way, when confirming the business expansion plan and the reduction plan, this application can more comprehensively and accurately perceive the needs of business expansion or reduction, and is more targeted. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0047] Figure 1 This is a flow chart of an automatic expansion and contraction method disclosed in this application;
[0048] Figure 2 This is a structural block diagram of an automatic expansion and contraction device disclosed in this application;
[0049] Figure 3 This is a hardware structure block diagram of an automatic expansion and contraction device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] Next, combine Figure 1 The automatic expansion and contraction method of the present application is introduced in detail, including the following steps:
[0052] Step S110 : Collect the machine indicators of the container cluster, the business indicators of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application.
[0053] Specifically, the indicator collector can be used to collect the indicators of each machine in the container cluster, the business indicators of various types of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application.
[0054] Among them, machine indicators can include container CPU usage, container memory usage, container mounted disk device IO and network bandwidth IO, etc.
[0055] Each type of business indicator is any business in the containerized application. For example, for a containerized live broadcast app, various types of business indicators for the business of sending gifts to live broadcast hosts can be collected.
[0056] In some embodiments, the business may transmit various types of business indicators related to container performance to the port, at which time the business indicators corresponding to the business may be obtained in the corresponding port. Therefore, each type of business indicator is strongly related to the business, and business indicators may be of multiple types. Different businesses may correspond to different types of business indicators, or they may have the same type of business indicators. For example, in the same containerized application, the business indicators corresponding to each business are of different types; in the same containerized application, different businesses contain the same type of business indicators.
[0057] The machine indicators of the collection container cluster, the business indicators of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application can be persistently stored in the memory.
[0058] Step S120: compare the sizes of the machine indicators, the business indicators of each type, and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result.
[0059] Specifically, the preset expected index may be a peak value, moving average value, variance, standard deviation, slope, cosine distance, etc. obtained by using various types of historical business indicators. For example, the expected index may be the average of the number of transactions per second over seven days, or the value obtained by multiplying the user-defined value by the average of the number of transactions per second over seven days may be used as the expected index.
[0060] Users can directly define the numerical value of the expected indicator according to business needs, or define the expected indicator as requiring calculation by calling data in memory. For example, you can use the field spec to directly refer to a numerical value, or you can use the field spec to refer to a formula that needs to be calculated, and then obtain the size of the expected indicator by calculating the formula.
[0061] Among them, the correspondence between each expected indicator and each business indicator can be stored in the policy configuration file. The field scaleTargetRef can be used to refer to the name, application type or version number of each containerized application to distinguish different containerized applications. Thereafter, the field metrics can be used to refer to the various types of business indicators corresponding to each business in the containerized application to distinguish different businesses in the same containerized application, and the field spec can be used to refer to the preset expected indicators corresponding to the same business.
[0062] Step S130: When capacity expansion or capacity reduction is required, a capacity expansion plan or a capacity reduction plan is obtained based on the current resource allocation quota and the comparison result.
[0063] Specifically, when the judgment result in step S120 indicates that the containerized application needs to be expanded or reduced in capacity, an expansion plan or a reduction plan can be obtained based on the current allocation quota of the resource and the comparison result.
[0064] The expansion plan or the reduction plan may include the allocation order of different types of resources, the allocation quotas of different types of resources, and the containerized applications that need to be expanded or reduced when allocating resources.
[0065] Step S140: Execute the capacity expansion plan or the capacity reduction plan.
[0066] Specifically, capacity expansion or capacity reduction is performed according to the plan, and resources can be allocated according to the allocation order of different types of resources and the amounts to be allocated of different types of resources, so as to implement the capacity expansion plan or capacity reduction plan.
[0067] In some embodiments, a change instruction may be sent to the container cluster to implement the expansion or reduction plan. When the control center of the container cluster receives the change instruction, the change instruction may be executed so that each type of business indicator meets the expected value. The change instruction includes the allocation order of different types of resources and the amount of different types of resources to be allocated.
[0068] It can be seen from the above technical solutions that the automatic expansion and contraction method provided in the embodiment of the present application can first collect the machine indicators of the container cluster and the various types of business indicators of the same business of the containerized application and the current allocation quota of resources allocated to the containerized application, wherein each type of business indicator corresponds to the business and is an indicator reported by the business, such as, for example, the query rate per second and the number of transactions per second and other indicators; then, the size of the various machine indicators, the various types of business indicators and the preset expected indicators can be compared, and based on the comparison results, it can be judged whether it is necessary to expand or shrink the containerized application; that is, by comparing the size of each machine indicator, each type of business indicator and the preset expected indicator, it is judged whether it is necessary to allocate more resources to the business or allocate fewer resources to the business; then, when expansion or shrinking is required, based on the current allocation quota of the resources and the comparison results, an expansion plan or a shrinking plan is obtained, and the expansion plan or the shrinking plan includes the resources that need to be allocated to the containerized application; finally, the expansion plan or the shrinking plan can be executed, that is, expansion or shrinking is achieved. It can be seen that the present application can realize automatic expansion in scenarios where expansion is required and automatic reduction in scenarios where reduction is required.
[0069] In addition, the basis for this application to confirm the expansion plan and the reduction plan is not only the machine indicators of the container cluster, but also includes various types of business indicators. Each type of business indicator corresponds to a certain business in the containerized application, and each type of business indicator is an indicator reported by the business. In this way, when confirming the business expansion plan and the reduction plan, this application can more comprehensively and accurately perceive the needs of business expansion or reduction, and is more targeted.
[0070] In some embodiments of the present application, step S120, comparing the sizes of the machine indicators, the business indicators of each type, and the preset expected indicators, and judging whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison results, is described in detail, and the steps are as follows:
[0071] S10. Determine the target resource type that needs to be allocated to the business according to the demand degree of the business for each type of resource.
[0072] Specifically, the target resource type may include any one or more of the following: CPU resources, memory resources, network bandwidth, and number of containers, etc.
[0073] Among them, the user can preset the degree of demand for each type of resource of the business, that is, the target resource type required by the business and its corresponding allocation order can be preset. Specifically, the degree of demand for the target resource type corresponding to the business can include multiple situations. Next, two optional situations will be provided. For example, the business may only have a demand for any one type of resource. In this case, the target resource type is one, which can be CPU resources. When allocating resources, only CPU resources can be allocated to the containerized application; for another example, the business may also have a demand for three types of resources. In this case, the target resource type can be memory resources, network bandwidth and number of containers. The allocation order of memory resources, network bandwidth and number of containers can be determined according to the degree of demand.
[0074] When the business has a demand for more than one type of resources, the allocation order of each resource type can be specified in advance. For example, when the business has a demand for CPU resources and memory resources, you can specify whether to allocate CPU resources first or memory resources first. Similarly, you can also allocate CPU resources and memory resources at the same time. The specific situation can be set by the user according to actual needs, and this application does not limit it.
[0075] The actions field of type list can be used to store the degree of demand for each type of resource by each business.
[0076] S11. Referring to the pre-set correspondence between each resource type and the indicator, determine the machine indicator and the business indicator corresponding to each of the target resource types from among the collected machine indicators and business indicators.
[0077] Specifically, the corresponding relationship between each resource type and the indicator can be preset in advance. For example, one type of business indicator can be preset to correspond to one resource type, or multiple types of business indicators can be preset to correspond to the same resource type.
[0078] In the same business, you can set one type of business indicator to correspond to one resource type, and the remaining types of indicators to correspond to another resource type. For example, each machine indicator includes container CPU usage and container memory usage, each type of business indicator includes transaction rate per second, query rate per second, and application rate per second, and the target resource types include two types, namely CPU resources and memory resources. In this case, you can set the container CPU usage and transaction rate per second to correspond to CPU resources, and the container memory usage, query rate per second, and application rate per second to correspond to memory resources.
[0079] S12. Calculate the ratio between the machine index and business index corresponding to each target resource type and the preset expected index as a comparison result.
[0080] Specifically, the ratio between the machine index and the business index corresponding to each target resource type and the preset expected index may be calculated.
[0081] There are multiple ways to calculate the ratio between the machine index and the business index corresponding to each target resource type and the preset expected index. Next, two optional methods will be provided.
[0082] The first one,
[0083] Each type of indicator can be pre-set with a corresponding expected indicator. On this basis, the ratio between each indicator and the corresponding expected indicator in the machine indicator and business indicator corresponding to each target resource type is calculated, and then the average value of the ratio corresponding to each indicator is calculated, and the average value is used as the comparison result. For example, the CPU utilization rate in the machine indicator can be preset to correspond to the first expected indicator 0.2, and the transaction rate per second in the business indicator can correspond to the second expected indicator 1500; at a certain moment, the CPU utilization rate can be collected to be 0.3 and the transaction rate per second is 1800. At this time, the ratio between the CPU utilization rate 0.3 and the first expected indicator 0.2 can be calculated to be 1.5, and the ratio between the transaction rate per second 1800 and the second expected indicator 1500 can be calculated to be 1.2. The average value between 1.5 and 1.2 is calculated to be 1.35, and 1.35 is used as the comparison result.
[0084] The second type
[0085] An overall expected indicator is set for the machine indicators and business indicators corresponding to the target resource type, and the expected indicator is used to compare with the sum of the machine indicators and business indicators corresponding to the target resource type. Specifically, the machine indicators and business indicators corresponding to each target resource type can be added, and the result of the addition can be divided by the overall expected indicator. For example, the CPU utilization rate in the machine indicators and the transaction rate per second in the business indicators can be preset to correspond to an overall expected indicator of 1500. At a certain moment, the CPU utilization rate can be collected to be 0.3 and the transaction rate per second can be 1800. At this time, the ratio of the sum of the CPU utilization rate of 0.3 and the transaction rate per second of 1800 to the expected indicator of 1500 can be calculated, that is, the ratio of 1800.3 to 1500 is calculated, which is 1.2002, and this is used as the comparison result.
[0086] S13. If the ratio is greater than 1, it is determined that the capacity of the containerized application needs to be expanded.
[0087] Specifically, when the ratio is greater than 1, it can be considered that the allocated resources are insufficient to meet the business needs. Therefore, at this time, it can be considered that the containerized application needs to be expanded.
[0088] S14. If the ratio is less than 1, it is determined that the containerized application needs to be scaled down.
[0089] Specifically, when the ratio is less than 1, it can be considered that the resources allocated at this time are sufficient to meet the business needs, and even cause idle resources. Therefore, at this time, it can be considered that the containerized application needs to be scaled down.
[0090] It can be seen from the above technical solution that, compared with the previous embodiment, this embodiment provides an optional way to determine whether it is necessary to expand or shrink the capacity of a containerized application. The specific method is to first determine the target resource type to be allocated; then, determine the ratio between the machine index and business index corresponding to the target resource type to be allocated and the preset expected index, and finally, determine whether it is necessary to expand or shrink the capacity according to the ratio. It can be seen that the above steps can well determine whether it is necessary to expand or shrink the capacity of a containerized application.
[0091] In some embodiments of the present application, when calculating the ratio between the machine index and business index corresponding to each target resource type and the preset expected index, the ratio can be used to determine the expansion plan or reduction plan. Based on this, step S130, when expansion or reduction is required, the process of obtaining the expansion plan or reduction plan based on the current allocation amount of the resource and the comparison result is described in detail, and the steps are as follows:
[0092] S20. Obtain a target resource allocation amount based on the current resource allocation amount and the ratio.
[0093] Specifically, the current resource allocation quota is the resource quota allocated by the container cluster to the containerized application.
[0094] Based on this, the current resource allocation amount can be multiplied by the ratio calculated in step S12, and the multiplied value can be used as the resource target allocation amount; the multiplied value can also be used to obtain the resource target allocation amount.
[0095] S21. Based on the resource target allocation quota, obtain a capacity expansion or reduction plan.
[0096] Specifically, the resource target allocation quota may include allocation quotas of multiple types of resources, and a capacity expansion or reduction plan may be determined based on the preset demand level of the business for each type of resource.
[0097] It can be seen from the above technical solution that, compared with the previous embodiment, this embodiment provides an optional way to determine the expansion plan or reduction plan, specifically, the current resource allocation quota and ratio can be used to determine the resource target allocation quota; finally, based on the resource target allocation quota, the expansion plan or reduction plan is determined. It can be seen that the above steps can better and more targetedly determine the expansion plan or reduction plan of the containerized application.
[0098] In some embodiments of the present application, the process of obtaining a capacity expansion or reduction plan based on the resource target allocation quota in step S21 is described in detail, and the steps are as follows:
[0099] S210: Obtain a preset correction coefficient for controlling the expansion and contraction range.
[0100] Specifically, a correction coefficient for controlling the expansion and contraction range can be preset, and there can be multiple situations for the preset correction coefficient, that is, the same correction coefficient for controlling the expansion and contraction range can be preset for the same container cluster, and the same correction coefficient for controlling the expansion and contraction range can also be preset for the same containerized application, but the correction coefficients for different containerized applications can be different.
[0101] The correction coefficient is determined to control the extent of expansion or contraction to prevent the scope of expansion or contraction from differing too much from the current resource allocation amount.
[0102] S211. Multiply the ratio, the current resource allocation amount and the correction coefficient.
[0103] Specifically, the ratio, the current allocation amount of resources allocated to the containerized application, and the correction coefficient obtained in step S210 may be multiplied together to obtain a result of the multiplication of the three.
[0104] S212, rounding the multiplication result to obtain a rounded result.
[0105] Specifically, the result after multiplication can be rounded. The rounding can be rounding the smallest unit of resources. For example, when calculating the target allocation amount of CPU resources, the result after multiplication is 892.6m, indicating that the business needs to use 892.6m of CPU resources. The smallest adjustable unit of CPU resources is 1m. Based on this, the result after multiplication can be rounded, and the rounded result is 893m, indicating that the amount of CPU resources that need to be allocated to the containerized application is 893m.
[0106] S213: Based on the rounded result, obtain the resource target allocation amount.
[0107] Specifically, the resource target allocation amount can be obtained based on the rounded result in a variety of ways, and one optional way is provided here. For example, the rounded result can be directly used as the resource target allocation amount.
[0108] It can be seen from the above technical solution that compared with the previous embodiment, this embodiment provides an optional way to obtain an expansion or reduction plan. The specific method is to first obtain the correction coefficient, then multiply the ratio, the current resource allocation quota and the correction coefficient, and then round the multiplied result; finally, based on the rounded result, the resource target allocation quota is obtained. It can be seen that the setting of the above steps takes into account the expansion and reduction range and the minimum unit of resource allocation, and can more comprehensively and better determine the resource target allocation quota, thereby better containerizing the expansion or reduction plan of the application.
[0109] In some embodiments of the present application, step S213, a process of obtaining a resource target allocation amount based on the rounded result, is described in detail, and the steps are as follows:
[0110] S30, determine whether the rounded result is less than the preset maximum resource allocation amount and greater than the preset minimum resource allocation amount, and obtain a determination result. When the determination result indicates that the rounded result is less than the preset maximum resource allocation amount and greater than the preset minimum resource allocation amount, execute step S31; when the determination result indicates that the rounded result is less than the preset minimum resource allocation amount, execute step S32; when the determination result indicates that the rounded result is greater than the preset maximum resource allocation amount, execute step S33.
[0111] Specifically, the maximum resource allocation quota and the minimum resource allocation quota can be preset for each resource, and the correspondence between the maximum resource allocation quota and the minimum resource allocation quota and the resource type can be established. For example, the minimum resource allocation quota of the CPU resource can be preset to 500m, and the maximum resource allocation quota can be preset to 1000m. In addition, the maximum resource allocation quota and the minimum resource allocation quota can be set as needed. For example, the maximum resource allocation quota and the minimum resource allocation quota of the same resource type in the same type of containerized application can be set to be the same or different.
[0112] In some embodiments, the field value maxResources of type object can be used to refer to the maximum cpu resources, the maximum memory resources or the maximum bandwidth resources; the field value minResources of type object can be used to refer to the minimum cpu resources, the minimum memory resources or the minimum bandwidth resources; the field value maxReplicas of type integer can be used to refer to the maximum number of containers; the field value minReplicas of type integer can be used to refer to the minimum number of containers.
[0113] S31. Using the rounded result as the final resource target allocation amount.
[0114] Specifically, when the rounded result is less than the preset maximum resource allocation amount and greater than the preset minimum resource allocation amount, it indicates that the resource target allocation amount is not too large, and the rounded result can be directly used as the final resource target allocation amount.
[0115] S32: Using the preset minimum resource allocation amount as the final resource target allocation amount.
[0116] Specifically, when the rounded result is less than the preset minimum resource allocation amount, it indicates that the resource target allocation amount is too small. A resource target allocation amount that is too small may be unfavorable for containerized applications to process various types of businesses. Based on this, the preset minimum resource allocation amount can be used as the final resource target allocation amount.
[0117] S33: Using the maximum resource allocation amount as the final resource target allocation amount.
[0118] Specifically, when the rounded result is less than or equal to the preset maximum resource allocation amount, it indicates that the resource target allocation amount is too large. If the resource target allocation amount is too large, it may have an adverse impact on the resources allocated to other containerized applications in the container cluster, which is not conducive to other containerized applications processing business. Based on this, the maximum resource allocation amount can be used as the final resource target allocation amount.
[0119] It can be seen from the above technical solution that this embodiment provides an optional way to determine the resource target allocation quota, which can control the resource allocation quota within an appropriate range. It can be seen that the setting of the above steps takes into account that the allocated resources should be within a reasonable range, which cannot exceed the maximum value or be less than the minimum value, and can more comprehensively and better determine the resource target allocation quota, thereby better containerizing the expansion plan or reduction plan of the application.
[0120] In some embodiments of the present application, step S140, the process of executing the capacity expansion plan or the capacity reduction plan is described in detail.
[0121] Specifically, the capacity expansion plan or the capacity reduction plan may be implemented by horizontal expansion and / or vertical expansion and reduction.
[0122] Among them, the horizontal expansion and contraction method can be used to adjust the number of containers allocated to the containerized application, thereby achieving expansion or contraction.
[0123] Similarly, vertical scaling can be used to adjust the CPU resources and memory resources allocated to containerized applications to achieve expansion or reduction.
[0124] In some embodiments, the capacity can be expanded or reduced by horizontal expansion or reduction and / or vertical expansion or reduction according to the needs of the containerized application.
[0125] For example, when a containerized application needs to adjust both the number of containers used and the CPU and memory resources, an expansion plan or a reduction plan can be executed based on the resource type requirements of the containerized application. When the containerized application is in urgent need of increasing the number of containers, the number of containers can be increased by horizontal expansion and then the CPU and memory resources can be allocated to the containerized application by vertical expansion and reduction.
[0126] Horizontal scaling and vertical scaling are two different scaling methods. By setting the orchestration order, you can make scaling compatible with both methods at the same time. If the user only sets one, it can become a traditional single horizontal scaling or vertical scaling.
[0127] The automatic expansion and contraction device provided by the present application is described below. The automatic expansion and contraction device described below and the automatic expansion and contraction method described above can be referred to each other.
[0128] First, combine Figure 2 , introduce the automatic expansion and contraction device, such as Figure 2 As shown, the automatic expansion and contraction device may include:
[0129] The indicator collection unit 100 is used to collect the indicators of each machine in the container cluster and the various types of business indicators of the same business of the containerized application and the current allocation quota of resources allocated to the containerized application;
[0130] The expansion and contraction confirmation unit 110 is used to compare the sizes of the machine indicators, the business indicators of each type and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result;
[0131] A solution confirmation unit 120 is used to obtain a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result when capacity expansion or reduction is required;
[0132] The solution execution unit 130 is used to execute the capacity expansion solution or the capacity reduction solution.
[0133] Furthermore, the expansion and contraction confirmation unit may include:
[0134] A type determination unit, configured to determine the target resource type to be allocated to the business according to the demand degree of the business for each type of resource, wherein the target resource type includes any one or more of the following: CPU resources, memory resources, network bandwidth, and number of containers;
[0135] An indicator determination unit, used to determine the machine indicator and business indicator corresponding to each target resource type from among the collected machine indicators and business indicators, referring to the preset correspondence between each resource type and the indicator;
[0136] A ratio calculation unit, used to calculate the ratio between the machine index and the business index corresponding to each target resource type and the preset expected index as a comparison result;
[0137] The expansion and contraction determination unit is used to determine the need to expand the capacity of the containerized application when the ratio between the machine indicators and business indicators corresponding to each target resource type and the preset expected indicators is greater than 1; when the ratio between the machine indicators and business indicators corresponding to each target resource type and the preset expected indicators is less than 1, it is used to determine the need to shrink the capacity of the containerized application.
[0138] Furthermore, the expansion and contraction determination unit may include:
[0139] An allocation quota determination unit, configured to obtain a target resource allocation quota based on the current resource allocation quota and the ratio;
[0140] A solution acquisition unit is used to acquire a capacity expansion or reduction solution based on the resource target allocation quota.
[0141] Furthermore, the allocation quota determination unit may include:
[0142] A coefficient acquisition unit, used to obtain a preset correction coefficient for controlling the expansion and contraction range;
[0143] A numerical multiplication unit, used for multiplying the ratio, the current allocation amount of the resource and the correction coefficient;
[0144] A rounding acquisition unit, used for rounding the result after multiplication to obtain a rounded result;
[0145] A quota acquisition unit is used to acquire the resource target allocation quota based on the rounded result.
[0146] Furthermore, the credit limit obtaining unit may include:
[0147] A first quota obtaining unit, used to determine whether the rounded result is less than a preset maximum resource allocation quota and greater than a preset minimum resource allocation quota, and obtain a determination result;
[0148] A second quota acquisition unit, configured to use the rounded result as the final resource target allocation quota when the judgment result indicates that the rounded result is less than the preset maximum resource allocation quota and greater than the preset minimum resource allocation quota;
[0149] A third quota acquisition unit is used to use the preset minimum resource allocation quota as the final resource target allocation quota when the judgment result shows that the rounded result is less than the preset minimum resource allocation quota;
[0150] The fourth quota acquisition unit is used to use the maximum resource allocation quota as the final resource target allocation quota when the judgment result shows that the rounded result is greater than the preset maximum resource allocation quota.
[0151] Furthermore, the solution execution unit may include:
[0152] The mode adopting unit is used to implement the expansion plan or the reduction plan by adopting the mode of horizontal expansion and contraction and / or vertical expansion and contraction.
[0153] The automatic expansion and contraction device provided in this application can be applied to automatic expansion and contraction equipment, such as servers, PC terminals, etc. Optionally, Figure 3 The hardware structure diagram of the automatic expansion and contraction device is shown. Figure 3 , the hardware structure of the automatic expansion and contraction device may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
[0154] In the embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4;
[0155] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention, etc.;
[0156] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0157] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to:
[0158] Collecting machine indicators of the container cluster, business indicators of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application;
[0159] Compare the sizes of the machine indicators, the business indicators of each type and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result;
[0160] When capacity expansion or reduction is required, obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result;
[0161] Execute the capacity expansion plan or the capacity reduction plan.
[0162] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0163] The embodiment of the present application further provides a storage medium, which may store a program suitable for execution by a processor, wherein the program is used to:
[0164] Collecting machine indicators of the container cluster, business indicators of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application;
[0165] Compare the sizes of the machine indicators, the business indicators of each type and the preset expected indicators, and determine whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result;
[0166] When capacity expansion or reduction is required, obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result;
[0167] Execute the capacity expansion plan or the capacity reduction plan.
[0168] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0169] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0170] The above description of the disclosed embodiments enables professionals and technicians in the field to implement or use the present application. Various modifications to these embodiments will be apparent to professionals and technicians in the field, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. The various embodiments of the present application can be combined with each other. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An automatic expansion and contraction method, characterized in that: include: Collecting machine indicators of the container cluster, business indicators of various types of the same business of the containerized application, and the current allocation quota of resources allocated to the containerized application, wherein the containerized application includes multiple businesses; According to the business's demand for each type of resource, determine the target resource type that needs to be allocated to the business, the target resource type includes any one or more of the following: CPU resources, memory resources, network bandwidth, and number of containers; Referring to the preset correspondence between each resource type and the indicator, determining the machine indicator and the business indicator corresponding to each of the target resource types from among the collected machine indicators and business indicators; Calculate the ratio between the machine index and business index corresponding to each target resource type and the preset expected index as the comparison result; Based on the comparison results, determine whether to expand or reduce the capacity of the containerized application; When capacity expansion or reduction is required, obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result; The capacity expansion plan or the capacity reduction plan is executed.
2. The method according to claim 1, characterized in that The determining whether it is necessary to expand or reduce the capacity of the containerized application based on the comparison result includes: If the ratio is greater than 1, it is determined that the containerized application needs to be expanded; If the ratio is less than 1, it is determined that the containerized application needs to be scaled down.
3. The method according to claim 1, characterized in that The obtaining of a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result includes: Based on the current allocation amount of the resource and the ratio, obtaining a target allocation amount of the resource; Based on the resource target allocation quota, a capacity expansion or reduction plan is obtained.
4. The method according to claim 3, characterized in that Based on the current resource allocation amount and the ratio, obtaining a target resource allocation amount includes: Obtaining a preset correction coefficient for controlling the expansion and contraction range; Multiplying the ratio, the current allocation amount of the resource and the correction coefficient; The result after multiplication is rounded to obtain a rounded result; Based on the rounded result, the resource target allocation amount is obtained.
5. The method according to claim 4, characterized in that Based on the rounded result, the resource target allocation amount is obtained, including: Determine whether the rounded result is less than a preset maximum resource allocation amount and greater than a preset minimum resource allocation amount, and obtain a determination result; When the judgment result indicates that the rounded result is less than the preset maximum resource allocation amount and greater than the preset minimum resource allocation amount, the rounded result is used as the final resource target allocation amount.
6. The method according to claim 5, characterized in that After determining whether the rounded result is less than a preset maximum resource allocation amount and greater than a preset minimum resource allocation amount, the method further includes: When the judgment result shows that the rounded result is less than the preset minimum resource allocation amount, the preset minimum resource allocation amount is used as the final resource target allocation amount; or, When the judgment result indicates that the rounded result is greater than the preset maximum resource allocation amount, the maximum resource allocation amount is used as the final resource target allocation amount.
7. The method according to any one of claims 1 to 6, characterized in that: The execution of the expansion plan or the reduction plan includes: Use horizontal expansion and / or vertical expansion to implement expansion or reduction plans.
8. An automatic expansion and contraction device, characterized in that: include: An indicator collection unit, used to collect indicators of each machine in the container cluster and various types of business indicators of the same business of the containerized application and the current allocation quota of resources allocated to the containerized application, wherein the containerized application includes multiple businesses; A capacity expansion and contraction confirmation unit is used to determine the target resource type that needs to be allocated to the business according to the degree of demand for each type of resource by the business, and the target resource type includes any one or more of the following: CPU resources, memory resources, network bandwidth, and number of containers; referring to the correspondence between each resource type and the indicator set in advance, determine the machine indicator and business indicator corresponding to each of the target resource types from the collected machine indicators and business indicators; calculate the ratio between the machine indicator and business indicator corresponding to each target resource type and the preset expected indicator as a comparison result, and determine whether it is necessary to expand or shrink the capacity of the containerized application based on the comparison result; A solution confirmation unit, used for obtaining a capacity expansion plan or a capacity reduction plan based on the current resource allocation quota and the comparison result when capacity expansion or reduction is required; A solution execution unit is used to execute the capacity expansion solution or the capacity reduction solution.
9. An automatic expansion and contraction device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the automatic scaling method according to any one of claims 1 to 7.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the automatic scaling method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Resource allocation method and device
CN106484540A