Resource updating method and device, equipment, storage medium and computer program product
By obtaining POD resource consumption information and multiple configuration template information, and finding and updating POD resource configuration, the problem of resource waste in temporary task scenarios of POD resource scheduling is solved, and efficient resource utilization and task processing performance are achieved.
Patent Information
- Application Number
- CN202411824463.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-05-06
AI Technical Summary
Existing POD resource scheduling methods are prone to waste of resources when dealing with temporary task scenarios, especially because the working time is short and it is not easy to trigger load balancing measurements, and more fixed POD resource templates are used.
A resource update method is proposed, by obtaining the resource usage configuration information corresponding to the POD within a preset time and the resource usage configuration information corresponding to the multiple configuration template information, searching out the second configuration template information, and updating the resources according to the first and second configuration template information, so as to dynamically optimize the POD resource configuration.
By dynamically optimizing POD resource configuration, avoid resource waste caused by inappropriate POD configuration, improve resource utilization, and ensure task processing performance.
Smart Images

Figure CN119938218A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a resource updating method, device, equipment, storage medium and computer program product. Background Art
[0002] The container group (POD) resource scheduling method mainly optimizes the scheduling operation of the POD number or deployment nodes with POD as the operation unit. For scenarios where a large number of PODs are used to process temporary tasks, it is not easy to trigger load balancing measurement due to the short working time, and most of them use fixed POD resource templates, which can easily cause waste of resources. Summary of the invention
[0003] The present application provides a resource updating method, apparatus, device, storage medium and computer program product, which can avoid resource waste.
[0004] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
[0005] In a first aspect, the present application proposes a resource update method, which is applied to POD, and the method comprises:
[0006] Obtain resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information;
[0007] Acquire multiple resource usage configuration information corresponding to the multiple configuration template information;
[0008] searching for second configuration template information from the plurality of configuration template information based on the resource consumption information and the plurality of resource usage configuration information;
[0009] The first resource is updated according to the first configuration template information and the second configuration template information.
[0010] In a second aspect, the present application proposes a resource updating device, applied to a POD, the device comprising:
[0011] A first acquisition unit is used to acquire resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information;
[0012] A second acquisition unit, configured to acquire a plurality of resource usage configuration information corresponding to the plurality of configuration template information;
[0013] A searching unit, configured to search for second configuration template information from the plurality of configuration template information based on the resource consumption information and the plurality of resource usage configuration information;
[0014] An updating unit, configured to update the first resource according to the first configuration template information and the second configuration template information.
[0015] In a third aspect, the present application proposes a resource updating device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above methods when executing the program.
[0016] In a fourth aspect, the present application proposes a storage medium having a computer program stored thereon, which implements the steps of any of the above methods when executed by a processor.
[0017] In a fifth aspect, the present application proposes a computer program product, comprising a computer program, which implements the steps of any of the above methods when executed by a processor.
[0018] The present application proposes a resource update method, device, equipment, storage medium and computer program product, which are applied to POD. The method includes: obtaining resource consumption information of POD for a first resource within a preset time; the first resource is created by POD according to first configuration template information; the first configuration template information is one of multiple configuration template information; obtaining multiple resource usage configuration information corresponding to multiple configuration template information; searching for second configuration template information from multiple configuration template information based on resource consumption information and multiple resource usage configuration information; updating the first resource according to the first configuration template information and the second configuration template information. With the above implementation scheme, by obtaining resource consumption information of the first resource created by POD according to the first configuration template information within a preset time, and multiple resource usage configuration information corresponding to multiple configuration template information, searching for the second configuration template information according to the resource consumption information and multiple configuration information, and updating the first resource according to the first configuration template information and the second configuration template information, the first configuration template information and the second configuration template information can be compared, thereby dynamically optimizing the POD resource configuration and avoiding resource waste caused by inappropriate POD configuration. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic diagram of a resource updating method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of an exemplary Voronoi diagram provided in an embodiment of the present application;
[0021] Figure 3An example flow chart of an exemplary method for POD expansion and contraction based on adaptive template matching provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of the relationship between an exemplary POD resource usage vector and a template set resource usage threshold vector provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of a resource updating device provided in an embodiment of the present application;
[0024] Figure 6 A schematic diagram of the structure of a resource updating device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0027] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. It should also be noted that the terms "first\second" and the like involved in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second" and the like may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0028] POD is the smallest scheduling unit of the open source container orchestration system (kubernetes, K8s) cluster. It is a combination of one or more containers. The K8s cluster implements basic features such as application deployment, monitoring, and scheduling by operating POD. Usually, the focus is on scheduling PODs of a certain size to appropriate nodes so that the resource utilization of each node in the cluster is balanced.
[0029] For example, by calculating the resource utilization of the POD, the POD with redundant resources will be appropriately reduced so that the new POD can be migrated to other nodes to enhance the overall resource utilization. By evaluating the actual resource utilization of the POD in a cycle, the resource limit of the POD is modified according to the actual resource utilization of the POD in each time period and the preset resource utilization threshold, the memory in the resource status request of the POD is reset, and then it is rescheduled to other nodes to ensure the maximum utilization of node resources.
[0030] Alternatively, a data collector is used to collect the resource usage of the POD, and the expansion and contraction strategy is determined according to the resource utilization rate. The expansion and contraction of the POD is dynamically configured according to the actual resource utilization to improve the resource utilization rate.
[0031] Alternatively, the application center will read the corresponding deployment continuous integration server (Jenkins) container execution template and notify the serverless jenkins module to create the corresponding slave service. At the same time, Jenkins will also provide the corresponding container startup markup language (Yet Another Markup Language, YAML) template (kubernetes PODtemplate) as the slaveek8s POD resource description. The application container engine (docker) account involved in the build process is dynamically read according to the application parameter configuration.
[0032] The existing POD expansion and contraction technology generally sets a resource threshold and instance number range. When the resource utilization rate of the POD reaches the resource threshold, the expansion strategy is triggered to meet business needs by increasing the number of instances to avoid business anomalies due to insufficient computing resources. When the resource utilization rate meets the contraction condition, the contraction strategy is triggered to reduce the number of instances to save computing resources. In addition, the resource utilization rate of each node is balanced by migrating the POD to different nodes.
[0033] The existing POD resource scheduling method mainly optimizes the number of PODs or deployment nodes for POD as the operation unit, which is suitable for scenarios where software applications are deployed stably and for a long time. For scenarios where a large number of PODs are used to handle temporary tasks, such as Jenkins tasks on K8s clusters, it is not easy to trigger the load balancing strategy due to the short working time. In addition, the existing technology mostly uses fixed POD resource templates, which is very likely to cause resource waste. The traditional template division that relies on experience values cannot well balance the contradiction between computational complexity and sample coverage.
[0034] Based on this, the embodiment of the present application provides a resource update method, which is applied to POD. Figure 1A schematic diagram of a resource updating method provided in an embodiment of the present application; Figure 1 As shown, the method includes:
[0035] S101. Obtain resource consumption information of a POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of a plurality of configuration template information.
[0036] It should be noted that, in practical applications, the POD resource update method can be understood as a POD expansion and contraction method.
[0037] In the embodiment of the present application, the preset time can be understood as a period of time, which can be determined specifically according to actual conditions and is not limited here. Resource consumption information can be understood as resource usage mean information, specifically including central processing unit (CPU) usage information and memory usage information. The CPU usage information and memory usage information are recorded in the form of vectors, which is the resource consumption information. Obtaining the resource consumption information of the POD for the first resource within the preset time can be understood as using a sidecar container to obtain the resource consumption information of the POD for the first resource within the preset time; wherein, the sidecar container is a container added to the POD to monitor resource usage indicators.
[0038] In an embodiment of the present application, the method also includes: obtaining multiple third configuration template information, and determining multiple CPU parameter information and multiple memory parameter information corresponding to the multiple third configuration template information respectively; constructing a first Voronoi diagram based on the multiple CPU parameter information and the multiple memory parameter information; generating multiple configuration template information based on the first Voronoi diagram; the number of the multiple configuration template information is greater than the number of the multiple third configuration template information.
[0039] It should be noted that the plurality of third configuration template information can be understood as a small amount of configuration template information based on preset experience values. The plurality of configuration template information can be understood as configuration template set information generated based on the plurality of third configuration template information that can more evenly cover the possibility of POD resource usage.
[0040] It should be noted that the Voronoi diagram is composed of a set of continuous polygons composed of perpendicular bisectors connecting two adjacent points. N points that are different on the plane divide the plane according to the nearest neighbor principle; each point is associated with its nearest neighbor area. Constructing the first Voronoi diagram based on multiple CPU parameter information and multiple memory parameter information can be understood as obtaining the configuration combination [CPU, MEM] of each third configuration template information based on the CPU parameter information and memory (Memory, MEM) information corresponding to each third configuration template information, and using the configuration combination [CPU, MEM] of each third configuration template information as a sample point to create the first Voronoi diagram.
[0041] In an embodiment of the present application, the process of generating multiple configuration template information based on the first Voronoi diagram specifically includes: obtaining multiple centroid information corresponding to multiple first shapes in the first Voronoi diagram; each of the multiple first shapes contains a sample point information; the sample point information is generated according to the CPU parameter information and memory parameter information of each third configuration template information; respectively determining the distance information between the centroid information and the sample point information in each first shape; and generating multiple configuration template information based on the distance information, multiple centroid information and multiple sample point information.
[0042] It should be noted that the multiple first shapes can be understood as multiple polygons in the first Voronoi diagram, and the specific shapes need to be determined based on the configuration combination [CPU, MEM] of each third configuration template information as a sample point, which is not limited here. The sample point information can be understood as the configuration combination [CPU, MEM] of each third configuration template information; the configuration combination [CPU, MEM] of multiple third configuration template information generates a sample point set.
[0043] In the embodiment of the present application, multiple configuration template information is generated based on distance information, multiple centroid information and multiple sample point information. It can be understood that multiple distance information and preset distances are compared respectively. When the distance information is greater than the preset distance, the coordinate information corresponding to the centroid point is added to the sample point set as a new sample point; when the distance information is less than or equal to the preset distance, the coordinate information corresponding to the centroid point is not processed. Among them, the preset distance can be understood as the minimum template spacing, which can be recorded as k, and k satisfies: in, Indicates the minimum memory allowed in multiple third configuration template information. Indicates the configuration difference allowed between CPUs in multiple third configuration template information.
[0044] It should be noted that when the distance information is greater than the preset distance, the coordinate information corresponding to the centroid point is added to the sample point set as a new sample point. It is necessary to regenerate the Voronoi diagram based on the new sample point set, and then determine the centroid of each polygon in the Voronoi diagram, calculate the distance between the centroid and the sample point in each polygon, and if the distance is greater than the preset distance, add the centroid coordinates to the sample point set as a new sample point, otherwise no processing is performed.
[0045] The solution of the embodiment of the present application generates a Voronoi diagram based on multiple third configuration template information. The template generation algorithm based on the Voronoi diagram can solve the problem that a small number of samples cannot effectively cover all application scenarios and a large number of dense samplings lead to an increase in the overall calculation amount.
[0046] S102: Acquire multiple resource usage configuration information corresponding to multiple configuration template information.
[0047] It should be noted that resource usage configuration information can be understood as resource usage threshold information. In actual applications, resource usage threshold information includes resource usage thresholds of CPU and memory. The resource usage configuration information is template vector information composed of resource usage thresholds of CPU and memory.
[0048] S103: Search for second configuration template information from multiple configuration template information based on the resource consumption information and multiple resource usage configuration information.
[0049] In an embodiment of the present application, the process of searching for second configuration template information from multiple configuration template information based on resource consumption information and multiple resource usage configuration information specifically includes: determining multiple offset information based on resource consumption information and multiple resource usage configuration information; searching for first offset information within a preset range from multiple offset information; and searching for second configuration template information corresponding to the first offset information from multiple configuration template information.
[0050] It should be noted that the offset information can be understood as offset vector information. In practical applications, resource consumption information can be understood as Multiple resource usage configuration information can be recorded as etc., the multiple offset information can be understood as the offset vector information from the resource consumption information to the multiple resource usage configuration information, that is, Respectively Determining multiple offset information according to resource consumption information and multiple resource usage configuration information can be understood as calculating multiple offset vector information between resource consumption information and multiple resource usage configuration information.
[0051] In an embodiment of the present application, the first offset information can be understood as target offset vector information screened out from multiple offset information, and searching for the first offset information within a preset range from multiple offset information includes: respectively obtaining multiple angle information between multiple offset information and preset information; searching for multiple first angle information that meets preset requirements from multiple angle information; and searching for the first offset information from multiple offset information based on multiple first angle information.
[0052] It should be noted that the preset information can be understood as a unit vector. In practical applications, the unit vector can be expressed as The angle information can be understood as the angle information between the offset information and the preset information. Acquiring multiple angle information between multiple offset information and the preset information can be understood as selecting the third offset information located in the first quadrant from the multiple offset information, and calculating multiple angle information between the third offset information and the preset information; in practical applications, it can be illustrated as selecting the third offset vector information located in the first quadrant from the multiple offset vector information, and calculating the angle information between the third offset vector information and the unit vector.
[0053] It should be noted that the first angle information can be understood as the cosine value of the first angle information being less than a preset value; wherein the preset value can be Searching for multiple first angle information meeting the preset requirements from multiple angle information can be understood as respectively determining multiple cosine values of the multiple angle information, and selecting from the multiple cosine values the first angle information that is less than The cosine value of The angle information corresponding to the cosine value of is used as the first angle information.
[0054] In an embodiment of the present application, the process of searching for first offset information from multiple offset information based on multiple first angle information specifically includes: searching for multiple second offset information corresponding to multiple first angle information from multiple offset information, and determining multiple numerical information corresponding to multiple second offset information; searching for the first numerical information with the smallest value from multiple numerical information; and using the offset information corresponding to the first numerical information as the first offset information.
[0055] It should be noted that the multiple numerical information can be understood as the modulus values corresponding to the multiple second offset information. Searching for the first numerical information with the smallest value from the multiple numerical information can be understood as sorting the multiple modulus values in descending order and taking the one with the smallest modulus value as the first numerical information.
[0056] It should be noted that searching for multiple second offset information corresponding to multiple first angle information from multiple offset information, determining multiple numerical information corresponding to multiple second offset information; searching for the first numerical information with the smallest value from multiple numerical information; and using the offset information corresponding to the first numerical information as the first offset information can be understood as searching for the first numerical information with a cosine value less than 0.001 from multiple offset vector information. The plurality of second offset vector information corresponding to the angle information are determined, a plurality of module values corresponding to the plurality of second offset vector information are determined, the plurality of module values are sorted, the minimum module value is selected, and the vector information corresponding to the minimum module value is used as the first offset vector information.
[0057] The solution of the embodiment of the present application can make good use of the vector modulus and direction data through the resource offset vector, filter adjacent values with the vector modulus, and interpret the trend with the vector direction, which can reduce the calculation complexity.
[0058] S104: Update the first resource according to the first configuration template information and the second configuration template information.
[0059] In the embodiment of the present application, updating the first resource can be understood as expanding or shrinking the first resource of the POD. The process of updating the first resource according to the first configuration template information and the second configuration template information specifically includes: respectively obtaining the first configuration information corresponding to the first configuration template information and the second configuration information corresponding to the second configuration template information; when the first configuration information and the second configuration information are different, updating the first resource according to the second configuration template information.
[0060] It should be noted that the first configuration information can be understood as the first label information of the first configuration template information; the second configuration information can be understood as the second label information of the second configuration template information. In practical applications, the first label information and the second label information can be recorded as [rid, cpu, mem, cpu t , mem t ], rid indicates the unique identifier id of the resource configuration template tag, cpu is the CPU parameter configuration in the yaml configuration of the POD, mem is the memory parameter configuration in the yaml configuration of the POD, cpu t and mem t The resource usage threshold is used to describe the optimal upper limit of the usage of this type of resources and is set based on experience.
[0061] It should be noted that the first configuration information and the second configuration information are different, which can be understood as the content of the first tag information and the second tag information are different, indicating that the first configuration template information is not the optimal choice for the POD, triggering the expansion and contraction strategy. Updating the first resource according to the second configuration template information can be understood as updating the configuration of the first resource of the POD according to the second configuration information of the second configuration template information.
[0062] It should be noted that, when the first configuration information and the second configuration information are the same, it means that the first configuration template information is the optimal choice for the POD, and no processing is performed at this time.
[0063] The solution of the embodiment of the present application, the POD expansion and contraction method based on adaptive template matching can dynamically optimize the POD resource configuration, and avoid inappropriate POD configuration affecting the task processing performance and causing resource waste.
[0064] For ease of understanding, the above solution is illustrated here. In practical applications, the above resource update method can be called a POD scaling method based on adaptive template matching, which mainly includes:
[0065] (1) An improved centroid Voronoi diagram generation algorithm is introduced to generate a more fine-grained configuration template set based on a small number of configuration templates. This algorithm can not only cover the hotspot area, but also expand the number of configuration templates, solving the problems of low quality of the method of dividing templates according to empirical values and the inability of the traditional centroid Voronoi diagram algorithm to adaptively increase samples.
[0066] (2) A resource offset vector matching method is proposed to vectorize the template matching process to improve matching efficiency and accuracy, solving the problem that existing technologies cannot optimize the optimal resource configuration of a single POD.
[0067] The above scheme can be specifically described as follows: First, in the preparation stage, this proposal proposes a configuration template generation algorithm based on the centroid Voronoi diagram, generates an appropriate number of configuration template sets that can evenly cover the possibility of POD resource usage based on a small number of preset configuration templates derived from empirical values, determines the resource configuration size and resource usage threshold of the template, and constructs a template feature vector; then uses the average resource usage over a period of time to construct a real-time resource consumption vector, and calculates the offset vector between the real-time resource consumption vector and the template feature vector to confirm the best matching template for the current POD. When the calculated best matching template is different from the initial configuration template used when the POD was created, the expansion and contraction strategy is triggered, and the initial configuration template of this type of POD is updated to the configuration value of the best matching template.
[0068] (I) Build a configuration template set.
[0069] The Voronoi diagram is composed of a set of continuous polygons composed of perpendicular bisectors connecting two adjacent points. N points that are distinct on the plane are divided into the plane according to the nearest neighbor principle; each point is associated with its nearest neighbor region. The coordinate system is established with the CPU and memory values of the POD resource configuration, and the configuration combination [CPU, MEM] obtained according to the empirical value is used as the sample point to create the Voronoi diagram. In order to obtain a more uniform distribution of configuration template samples, the centroid Voronoi diagram algorithm is improved, a template minimum spacing k is set, and the centroid points of the polygons in the Voronoi diagram whose distance to the sample points in the polygon is greater than k are recorded as new sample points, and the centroid points whose distance is less than k are not processed. Repeat multiple iterations until no new sample points are generated and the algorithm ends. Figure 2 A schematic diagram of an exemplary Voronoi diagram provided in an embodiment of the present application; Figure 2 As shown, Figure 2 The circular points are sample points (configuration combination [CPU, MEM] obtained based on empirical values), the triangular points are the centroid points of the polygons in the Voronoi diagram whose distance to the sample points in the polygon is greater than k, and the rectangular points are the centroid points whose distance is less than k.
[0070] The key steps of the configuration template generation algorithm based on the centroid Voronoi diagram are detailed as follows:
[0071] 1. Initialization.
[0072] According to the actual node capacity and business needs, prepare a certain number of configuration templates that can cover most business scenarios. Combine the CPU and memory parameters of all configuration templates into a set of sample points and put them into the coordinate system for subsequent calculations. Use the maximum allowable configuration of POD as the calculation boundary. Set the minimum template spacing k, k satisfies: in, Indicates the minimum memory allowed in multiple third configuration template information. Indicates the configuration difference allowed between CPUs in multiple third configuration template information.
[0073] 2. Generate the centroid Voronoi diagram.
[0074] Step 1: Generate a Voronoi diagram based on the sample point set and the calculated boundary;
[0075] Step 2: Calculate the centroid of each polygon in the Voronoi diagram;
[0076] Step 3: Calculate the distance d between the centroid and the sample point in each polygon. If d>k, add the centroid coordinates to the sample point set as a new sample point, otherwise, do not process it.
[0077] Step 4: If new sample points are added in step 3, repeat steps 1-3; otherwise, the algorithm ends.
[0078] 3. Generate a configuration template.
[0079] Extract the coordinates of each sample point in the sample point set, and fill the CPU and memory configuration into the yaml configuration template according to its coordinate value. The configuration template is stored in the configuration template library.
[0080] (ii) Best template matching.
[0081] First, establish a resource configuration template to set the resource usage threshold of each template, use the resource usage indicator to build a vector, and calculate the offset vector between the vector and the configuration template to confirm whether the POD's resource usage is optimal. For the POD that needs to adjust the configuration, you only need to recreate the POD according to the filtered configuration template without considering the expansion and contraction status. Figure 3 An exemplary flow chart of an exemplary POD expansion and contraction method based on adaptive template matching provided in an embodiment of the present application; Figure 3 As shown, the specific steps are as follows:
[0082] 1. Start.
[0083] 2. Apply resource configuration template.
[0084] 3. Configure the template library.
[0085] It should be noted that when a POD is created, a template is selected from the configuration template library to create a POD resource.
[0086] 4. Resource usage detection.
[0087] It should be noted that a sidecar container is added to each working Pod to monitor resource usage indicators and calculate the average resource usage over a period of time.
[0088] 5. Calculate the offset vector.
[0089] 6. Filter the offset vector.
[0090] 7. Compare with the initial configuration.
[0091] It should be noted that the configuration corresponding to the screened offset vector is compared with the initial configuration. If the two are different, step 8 is executed; if the two are the same, step 9 is executed.
[0092] 8. Expand or reduce POD capacity.
[0093] It should be noted that when the POD is expanded or reduced in capacity, the POD configuration is updated and step 2 is executed again.
[0094] 9. End.
[0095] For ease of understanding, the above steps are explained here with examples, specifically:
[0096] (1) Resource template configuration.
[0097] According to the resource capacity of each node in the deployment cluster and the experience value of the task POD resource requirements, the resource configuration template labels [rid, cpu, mem, cpu t , mem t ], rid indicates the unique identifier id of the resource configuration template tag, cpu is the CPU parameter configuration in the yaml configuration of the POD, mem is the memory parameter configuration in the yaml configuration of the POD, cpu t and mem t The resource usage threshold is used to describe the optimal upper limit of the usage of this type of resources and is set based on experience.
[0098] A task is defined as a purposeful activity that needs to be implemented through a POD. A task can use a variety of PODs with different combinations. In the embodiment of the present application, each task needs to select an initial POD configuration template based on experience.
[0099] Configuration templates are stored in the configuration template library. Each time a POD is created, a template is selected from the configuration template library to create a POD resource.
[0100] (2) Resource utilization monitoring.
[0101] Add a sidecar container to each working Pod to monitor resource usage indicators and calculate the average resource usage over a period of time.
[0102] (3) Resource offset vector matching method.
[0103] Figure 4 A schematic diagram of the relationship between an exemplary POD resource usage vector and a template set resource usage threshold vector provided in an embodiment of the present application; Figure 4 As shown, Figure 4 middle, Indicates the CPU and memory usage in the collected POD; The template vector is composed of the resource usage thresholds of CPU and memory in the template set.
[0104] 1. Calculate the offset vector.
[0105] The offset vector from P to each template vector is calculated by formula (1). Formula (1) is as follows:
[0106]
[0107] 2. Filter the offset vector.
[0108] Filter the offset vectors in the first quadrant and calculate the offset vector With unit vector The angle θ, screening The calculation method is shown in formula (2), which is as follows:
[0109]
[0110] Will satisfy The vector is added to the set U, and the vector with the smallest modulus value is selected from the set U.
[0111] (3) POD expansion and reduction optimization strategy.
[0112] Filtered offset vector The corresponding template set S[rid, cpu, mem, cpu s , mem s ] is the best resource configuration calculated. When the configuration template S is the same as the initial template for creating the POD, it means that the current configuration is optimal and does not need to be changed; when the configuration template S is different from the initial template for creating the POD, it means that the configuration template is not the best choice, triggering the expansion and contraction strategy, updating the POD configuration according to the configuration S, recreating the POD to complete the task, and updating the configuration set S to the initial resource configuration of the task.
[0113] The embodiment of the present application provides a resource updating device, which is applied to a POD. Figure 5 A schematic diagram of a resource updating device provided in an embodiment of the present application; Figure 5 As shown, the resource updating device 500 includes:
[0114] The first acquisition unit 501 is used to acquire resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information;
[0115] The second acquisition unit 502 is used to acquire multiple resource usage configuration information corresponding to the multiple configuration template information;
[0116] A searching unit 503, configured to search for second configuration template information from the plurality of configuration template information based on the resource consumption information and the plurality of resource usage configuration information;
[0117] The updating unit 504 is configured to update the first resource according to the first configuration template information and the second configuration template information.
[0118] Optionally, the resource update device 500 also includes a generation unit, which is used to obtain multiple third configuration template information, and determine multiple CPU parameter information and multiple memory information corresponding to the multiple third configuration template information respectively; construct a first Voronoi diagram according to the multiple CPU parameter information and the multiple memory parameter information; generate the multiple configuration template information based on the first Voronoi diagram; the number of the multiple configuration template information is greater than the number of the multiple third configuration template information.
[0119] Optionally, the generating unit is further used to obtain multiple centroid information corresponding to multiple first shapes in the first Voronoi diagram; each of the multiple first shapes contains a sample point information; the sample point information is generated according to the CPU parameter information and memory parameter information of each third configuration template information; respectively determine the distance information between the centroid information in each first shape and the sample point information; and generate the multiple configuration template information based on the distance information, the multiple centroid information and the multiple sample point information.
[0120] Optionally, the search unit 503 is also used to determine multiple offset information based on the resource consumption information and the multiple resource usage configuration information; search for first offset information within a preset range from the multiple offset information; and search for the second configuration template information corresponding to the first offset information from the multiple configuration template information.
[0121] Optionally, the search unit 503 is also used to respectively obtain multiple angle information between the multiple offset information and the preset information; search for multiple first angle information that meets the preset requirements from the multiple angle information; and search for the first offset information from the multiple offset information based on the multiple first angle information.
[0122] Optionally, the search unit 503 is also used to search for multiple second offset information corresponding to the multiple first angle information from the multiple offset information; determine multiple numerical information corresponding to the multiple second offset information; search for the first numerical information with the smallest value from the multiple numerical information; and use the offset information corresponding to the first numerical information as the first offset information.
[0123] Optionally, the update unit 504 is also used to obtain first configuration information corresponding to the first configuration template information and second configuration information corresponding to the second configuration template information, respectively; when the first configuration information and the second configuration information are different, the first resource is updated according to the second configuration template information.
[0124] The embodiment of the present application also provides a resource updating device, Figure 6A schematic diagram of a resource updating device provided in an embodiment of the present application; Figure 6 As shown, the resource updating device 600 includes: a processor 601 and a memory 603 . Optionally, the resource updating device 600 may also include a communication bus 602 .
[0125] In the process of a specific embodiment, the processor 601 may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing image processing device (DSPD), a programmable logic image processing device (PLD), a field programmable gate array (FPGA), a CPU, a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic device used to implement the function of the processor may also be other, which is not specifically limited in this embodiment.
[0126] In the embodiment of the present application, the communication bus 602 is used to realize the connection and communication between the processor 601 and the memory 603; when the processor 601 executes the running program stored in the memory 603, the following resource update method is implemented:
[0127] Obtain resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information; obtain multiple resource usage configuration information corresponding to the multiple configuration template information; search for second configuration template information from the multiple configuration template information based on the resource consumption information and the multiple resource usage configuration information; update the first resource according to the first configuration template information and the second configuration template information.
[0128] Furthermore, the above-mentioned processor 601 is also used to obtain multiple third configuration template information, and determine multiple CPU parameter information and multiple memory information corresponding to the multiple third configuration template information respectively; construct a first Voronoi diagram according to the multiple CPU parameter information and the multiple memory parameter information; generate the multiple configuration template information based on the first Voronoi diagram; the number of the multiple configuration template information is greater than the number of the multiple third configuration template information.
[0129] Furthermore, the processor 601 is further configured to obtain multiple centroid information corresponding to multiple first shapes in the first Voronoi diagram; each of the multiple first shapes contains a sample point information; the sample point information is generated according to the CPU parameter information and the memory parameter information of each third configuration template information; respectively determine the distance information between the centroid information in each first shape and the sample point information; and generate the multiple configuration template information based on the distance information, the multiple centroid information and the multiple sample point information.
[0130] Furthermore, the above-mentioned processor 601 is also used to determine multiple offset information based on the resource consumption information and the multiple resource usage configuration information; search for the first offset information within a preset range from the multiple offset information; and search for the second configuration template information corresponding to the first offset information from the multiple configuration template information.
[0131] Furthermore, the above-mentioned processor 601 is also used to respectively obtain multiple angle information between the multiple offset information and the preset information; search for multiple first angle information that meets the preset requirements from the multiple angle information; and search for the first offset information from the multiple offset information based on the multiple first angle information.
[0132] Furthermore, the above-mentioned processor 601 is also used to search for multiple second offset information corresponding to the multiple first angle information from the multiple offset information; determine multiple numerical information corresponding to the multiple second offset information; search for the first numerical information with the smallest value from the multiple numerical information; and use the offset information corresponding to the first numerical information as the first offset information.
[0133] Furthermore, the above-mentioned processor 601 is also used to respectively obtain first configuration information corresponding to the first configuration template information and second configuration information corresponding to the second configuration template information; when the first configuration information and the second configuration information are different, the first resource is updated according to the second configuration template information.
[0134] An embodiment of the present application provides a storage medium having a computer program stored thereon. The computer-readable storage medium stores one or more programs. The one or more programs can be executed by one or more processors. The computer program implements the resource update method as described above.
[0135] Based on the above embodiments, an embodiment of the present application provides a computer program product, including a computer program, which can be executed by one or more processors, and the computer program implements the resource update method as described above.
[0136] It should be noted that, in this article, the terms "include", "comprises" or any other variations 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, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0137] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for enabling an image display device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0138] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A resource updating method, characterized in that: Applied to a container group POD, the method includes: Obtain resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information; Acquire multiple resource usage configuration information corresponding to the multiple configuration template information; searching for second configuration template information from the plurality of configuration template information based on the resource consumption information and the plurality of resource usage configuration information; The first resource is updated according to the first configuration template information and the second configuration template information.
2. The method according to claim 1, characterized in that The method further comprises: Acquire multiple third configuration template information, and determine multiple central processing unit CPU parameter information and multiple memory information corresponding to the multiple third configuration template information respectively; Constructing a first Voronoi diagram according to the plurality of CPU parameter information and the plurality of memory parameter information; The plurality of configuration template information is generated based on the first Voronoi diagram; the number of the plurality of configuration template information is greater than the number of the plurality of third configuration template information.
3. The method according to claim 2, characterized in that The generating the plurality of configuration template information based on the first Voronoi diagram comprises: Acquire multiple centroid information corresponding to multiple first shapes in the first Voronoi diagram; each of the multiple first shapes contains a sample point information; the sample point information is generated according to the CPU parameter information and the memory parameter information of each third configuration template information; Respectively determining distance information between centroid information within each first shape and the sample point information; The plurality of configuration template information is generated based on the distance information, the plurality of centroid information and the plurality of sample point information.
4. The method according to claim 1, characterized in that: The searching for second configuration template information from the multiple configuration template information based on the resource consumption information and the multiple resource usage configuration information includes: Determine a plurality of offset information according to the resource consumption information and the plurality of resource usage configuration information; Searching for first offset information within a preset range from the plurality of offset information; The second configuration template information corresponding to the first offset information is searched from the multiple configuration template information.
5. The method according to claim 4, characterized in that The searching for the first offset information within a preset range from the plurality of offset information includes: Respectively obtaining a plurality of angle information between the plurality of offset information and the preset information; Searching for a plurality of first angle information meeting preset requirements from the plurality of angle information; The first offset information is searched from the plurality of offset information based on the plurality of first angle information.
6. The method according to claim 5, characterized in that The searching the first offset information from the plurality of offset information based on the plurality of first angle information includes: Searching for a plurality of second offset information corresponding to the plurality of first angle information from the plurality of offset information; Determine a plurality of numerical value information corresponding to the plurality of second offset information; Find the first numerical information with the smallest value from the multiple numerical information; The offset information corresponding to the first numerical information is used as the first offset information.
7. The method according to claim 1, characterized in that The updating of the first resource according to the first configuration template information and the second configuration template information includes: Respectively acquiring first configuration information corresponding to the first configuration template information and second configuration information corresponding to the second configuration template information; When the first configuration information and the second configuration information are different, the first resource is updated according to the second configuration template information.
8. A resource updating device, characterized in that: Applied to POD, the device comprises: A first acquisition unit is used to acquire resource consumption information of the POD for a first resource within a preset time; the first resource is created by the POD according to first configuration template information; the first configuration template information is one of multiple configuration template information; A second acquisition unit, configured to acquire a plurality of resource usage configuration information corresponding to the plurality of configuration template information; A searching unit, configured to search for second configuration template information from the plurality of configuration template information based on the resource consumption information and the plurality of resource usage configuration information; An updating unit, configured to update the first resource according to the first configuration template information and the second configuration template information.
9. A resource updating device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the steps of the method according to any one of claims 1 to 7 are implemented when the processor executes the program.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.