Container resource configuration method and device

By dynamically updating container configuration parameters and cgroup parameters, real-time synchronization and adjustment of container resources are achieved, solving the problems of business interruptions and low resource utilization caused by container resource adjustment in the prior art.

CN119883490APending Publication Date: 2025-04-25BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311385871.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-24
Publication Date
2025-04-25

Smart Images

  • Figure CN119883490A_ABST
    Figure CN119883490A_ABST
Patent Text Reader

Abstract

The invention discloses a container resource configuration method and device, and relates to the technical field of cloud computing. A specific embodiment of the method comprises the following steps: in response to monitored system resource change, collecting system resource data, and aggregating the system resource data to obtain aggregated index data; calculating a target configuration parameter of the container according to the aggregation index data and a set capacity expansion and contraction rule, and performing first configuration parameter updating on the container according to the target configuration parameter; and in response to the detected change of the first configuration parameter, modifying a second configuration parameter of the container in the container process according to the first configuration parameter, and updating the container according to the modified second configuration parameter to complete container resource configuration. According to the embodiment, the configuration parameters of the container and the cgroup parameters in the container process are dynamically adjusted, resource synchronization can be carried out in real time, the resource utilization rate is increased, Pod does not need to be destroyed for re-creation, service interruption is avoided, and service monitoring is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a method and device for container resource configuration. Background Art

[0002] With the continuous development of cloud-native technology, cloud services have occupied a very important position in the Internet market, and more and more developers and companies are beginning to deploy applications on the cloud. Kubernetes in the field of cloud computing is becoming more and more mature in terms of technological advancement and implementation solutions, and more and more companies and enterprises are choosing to use Kubernetes technology for resource orchestration. By using Kubernetes, enterprises can ensure that applications have sufficient resources to maintain good performance by dynamically adjusting container resources. Currently, most community projects use VPA (Vertical Pod Autoscaler) to automatically expand or reduce container resources, or directly use cgroup (cgroup refers to a function of the Linux kernel that is used to limit, control and separate the resources of a process group) to expand and shrink container resources.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] When using VPA to adjust container resources, the Pod must be destroyed and recreated, which will cause business interruption and the newly created Pod will be allocated to other nodes, which is not conducive to business monitoring. When using cgroup to adjust container resources, the Kubernetes scheduling service cannot perceive it, making it impossible to synchronize resources and fundamentally improve resource utilization. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for container resource configuration, which can dynamically adjust the configuration parameters of the container and the cgroup parameters in the container process, and can synchronize resources in real time, thereby improving resource utilization. There is no need to destroy the Pod and recreate it, which will not cause business interruption and facilitate business monitoring.

[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for configuring container resources is provided, including:

[0007] In response to monitoring a system resource change, collecting system resource data, and aggregating the system resource data to obtain aggregated indicator data;

[0008] Calculating target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, and performing first configuration parameter updates on the container according to the target configuration parameters;

[0009] In response to detecting that the first configuration parameter has changed, a second configuration parameter of the container in the container process is modified according to the first configuration parameter, and the container is updated according to the modified second configuration parameter to complete the container resource configuration.

[0010] Optionally, in response to monitoring changes in system resources, system resource data is collected, and the system resource data is aggregated to obtain aggregate indicator data, including: in response to monitoring changes in system resources, system resource data is collected, and the system resource data in the current collection cycle is aggregated according to the collection time of the system resource data to obtain aggregate indicator data.

[0011] Optionally, the scaling rules include indicator data thresholds and target configuration parameter calculation rules; calculating the target configuration parameters of the container based on the aggregated indicator data and the set scaling rules includes: judging whether scaling is required based on the aggregated indicator data and the indicator data thresholds; and if it is determined that scaling is required, calculating the target configuration parameters of the container based on the target configuration parameter calculation rules.

[0012] Optionally, when it is determined that scaling is required, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule, including: when it is determined that scaling is required, obtaining an application identifier according to the system resource data, and obtaining a scaling method corresponding to the application according to the application identifier, the scaling method including horizontal scaling and vertical scaling; when the scaling method is horizontal scaling, calculating the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the horizontal scaling; when the scaling method is vertical scaling, calculating the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the vertical scaling.

[0013] Optionally, when the scaling method is horizontal scaling, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rules corresponding to the horizontal scaling, including: calculating the target number of containers according to the aggregated indicator data, the indicator data threshold and the current number of containers, and using the target number of containers as the target configuration parameters of the container.

[0014] Optionally, when the scaling method is vertical scaling, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rules corresponding to the vertical scaling, including: calculating the target container specification parameters according to the aggregated indicator data, the indicator data threshold and the current container specification parameters, and using the target container specification parameters as the target configuration parameters of the container.

[0015] Optionally, when the scaling mode is vertical scaling, the target configuration parameters of the container are calculated according to a target configuration parameter calculation rule corresponding to the vertical scaling, including: when the scaling mode is vertical scaling, obtaining an application identifier according to the system resource data, and obtaining a list of containers on which the application is deployed according to the application identifier; and for each container in the container list, calculating the target configuration parameters of the container according to the target configuration parameter calculation rule.

[0016] According to another aspect of an embodiment of the present invention, a device for configuring container resources is provided, including:

[0017] An indicator data processing module, configured to collect system resource data in response to monitoring changes in system resources, and aggregate the system resource data to obtain aggregate indicator data;

[0018] A configuration parameter calculation module, used to calculate the target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, and update the first configuration parameters of the container according to the target configuration parameters;

[0019] A configuration parameter modification module is used to modify a second configuration parameter of the container in the container process according to the first configuration parameter in response to detecting a change in the first configuration parameter, and update the container according to the modified second configuration parameter to complete container resource configuration.

[0020] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for container resource configuration provided by an embodiment of the present invention.

[0021] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for configuring container resources provided by an embodiment of the present invention is implemented.

[0022] An embodiment of the above invention has the following advantages or beneficial effects: in response to monitoring system resource changes, system resource data is collected, and the system resource data is aggregated to obtain aggregated indicator data; the target configuration parameters of the container are calculated according to the aggregated indicator data and the set expansion and contraction rules, and the first configuration parameters of the container are updated according to the target configuration parameters; in response to detecting a change in the first configuration parameter, the second configuration parameter of the container in the container process is modified according to the first configuration parameter, and the container is updated according to the modified second configuration parameter to complete the technical solution of container resource configuration, which realizes dynamic adjustment of the configuration parameters of the container and the cgroup parameters in the container process, can synchronize resources in real time, thereby improving resource utilization, without destroying the Pod and recreating it, and will not cause business interruption, which facilitates business monitoring.

[0023] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0025] Figure 1 is a schematic diagram of main steps of a method for configuring container resources according to an embodiment of the present invention;

[0026] Figure 2 It is a schematic diagram of the implementation process of container resource configuration according to an embodiment of the present invention;

[0027] Figure 3 is a schematic diagram of main modules of a device for configuring container resources according to an embodiment of the present invention;

[0028] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0029] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0031] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:

[0032] Kubernetes: is an open source platform for managing containerized applications on multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.

[0033] Pod: Pod is the basis of all business types and the smallest unit managed by Kubernetes. It is a combination of one or more containers. These containers share storage, network, and namespace, as well as specifications for how to run. In a Pod, all containers are arranged and scheduled in the same way and run in a shared context. For specific applications, Pod is their logical host, and Pod contains multiple application containers related to the business.

[0034] HPA: Horizontal Pod Autoscaler, which means horizontal Pod automatic expansion and contraction, is a resource object of Kubernetes. It can dynamically scale the number of Pods in sets such as statefulSet, replicaController, and replicaSet according to certain indicators, so that the services running on them have a certain degree of adaptability to changes in indicators.

[0035] VPA: Vertical Pod Autoscaler, which means vertical Pod automatic expansion and contraction, can automatically set the CPU and memory request values ​​according to the container resource usage, allowing appropriate scheduling on the node to provide appropriate resources for each Pod. It can both reduce the size of containers that request excessive resources and increase the capacity of insufficient resources at any time according to their usage.

[0036] Node: A physical machine / cloud host / bare metal machine on which kubelet is deployed. It is used to actually use the CPU, memory, and disk on the current physical machine / cloud host / bare metal machine to create Docker containers.

[0037] Docker: It is an open source application container engine that allows developers to package their applications and dependent packages into a portable container and then publish it to any popular Linux machine or Windows machine. It can also achieve virtualization. The container is completely sandboxed. Developers can use Docker to eliminate the problem of "it works on my machine" when collaborating on coding. Operations and maintenance personnel can use Docker to run and manage applications in parallel in isolated containers to obtain better computing density. Enterprises can use Docker to build an agile software delivery pipeline to release new features for Linux and Windows Server applications at a faster speed, higher security and reliable reputation.

[0038] cgroup: Its name comes from the abbreviation of control groups. It is a function of the Linux kernel that is used to limit, control and separate the resources of a process group (such as CPU, memory, disk input and output, etc.).

[0039] Currently, when using VPA to adjust container resources, the container resource specifications of the Pod can be adjusted according to the monitoring indicators. Every time VPA updates the Pod resources, the Pod will be recreated, which will cause all running containers to be restarted, which will cause some business interruptions and even cause the newly created Pod to be assigned to other Node nodes and the IP to change, which will bring a very bad business experience and is not conducive to business monitoring. When using cgroup to adjust container resources, because containers and Pods are also processes, the parameter value of cgroup can be directly modified according to the process, but the Kubernetes scheduling service will not be aware of the modification, so that the freed or overused resources cannot be synchronized to the scheduling system, and thus the resource utilization rate cannot be fundamentally improved.

[0040] In order to solve the technical problems existing in the prior art, the present invention provides a method for container resource configuration, which can dynamically modify the Pod information and the cgroup parameter value of the container process without stopping the service, so that the top-down system is aware of the resource changes, thereby improving resource utilization.

[0041] Figure 1 FIG. 1 is a schematic diagram of the main steps of the method for configuring container resources according to an embodiment of the present invention. Figure 1 As shown, the method for configuring container resources in the embodiment of the present invention mainly includes the following steps S101 to S103.

[0042] Step S101: in response to monitoring a change in system resources, collecting system resource data, and aggregating the system resource data to obtain aggregated indicator data.

[0043] According to an embodiment of the present invention, in response to monitoring a change in system resources, collecting system resource data, and aggregating the system resource data to obtain aggregated index data, can specifically include: in response to monitoring a change in system resources, collecting system resource data, and aggregating the system resource data in the current collection period according to the collection time of the system resource data to obtain aggregated index data. In an embodiment of the present invention, through a monitoring agent or other monitoring mechanism, when a change in system resources is monitored, information related to system resources, such as CPU utilization, memory usage, disk space occupancy, etc., is collected and recorded, and the collected system resource data will be stored in a time series database, wherein the time series database is a database for storing time series data, mainly used to process data with time tags (changing in the order of time, i.e., time serialization), such as CPU usage per minute, etc. Subsequently, the system resource data of the collection period is aggregated for use in expansion and contraction calculation and processing. When performing aggregation processing, for example, the index values ​​(such as CPU utilization) of multiple containers at the same time point are summed and then divided by the number of containers to obtain the average value as the aggregated index data of the index at this time point.

[0044] Step S102: Calculate target configuration parameters of the container according to the aggregated indicator data and the set scaling rules, and update first configuration parameters of the container according to the target configuration parameters.

[0045] According to one embodiment of the present invention, the scaling rules include indicator data thresholds and target configuration parameter calculation rules. Calculating the target configuration parameters of the container based on the aggregated indicator data and the set scaling rules may specifically include: judging whether scaling is required based on the aggregated indicator data and the indicator data thresholds; and when it is determined that scaling is required, calculating the target configuration parameters of the container based on the target configuration parameter calculation rules. After receiving the aggregated indicator data, first judge whether scaling is required based on the pre-set indicator data thresholds corresponding to the scaling. The indicator data thresholds are, for example: the lower limit threshold of CPU utilization is 30%, and the upper limit threshold is 80%, which means that when the CPU utilization is less than 30%, scaling is performed, and when the CPU utilization is greater than 80%, scaling is performed.

[0046] According to another embodiment of the present invention, when it is determined that expansion and contraction processing is required, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule, including: when it is determined that expansion and contraction processing is required, the application identifier is obtained according to the system resource data, and the expansion and contraction mode corresponding to the application is obtained according to the application identifier, and the expansion and contraction mode includes horizontal expansion and contraction and vertical expansion and contraction; when the expansion and contraction mode is horizontal expansion and contraction, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the horizontal expansion and contraction; when the expansion and contraction mode is vertical expansion and contraction, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the vertical expansion and contraction. Among them, horizontal expansion and contraction refers to adjusting the number of containers, such as expanding the number of containers from 10 to 15, or shrinking from 10 to 5; vertical expansion and contraction refers to adjusting the rules of the container, such as expanding the CPU of the container from 4 cores to 8 cores or shrinking from 4 cores to 2 cores, and the number of containers remains unchanged. Different types of application containers have different ways of scaling up and down, which can be set according to business needs. For example, database-type application containers generally perform vertical scaling, interactive system-type reference containers generally perform horizontal scaling, etc. In the embodiment of the present invention, corresponding target configuration parameter calculation rules are set for both horizontal scaling and vertical scaling.

[0047] According to one embodiment of the present invention, when the expansion mode is horizontal expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rules corresponding to the horizontal expansion, which may specifically include: calculating the target number of containers according to the aggregated index data, the index data threshold and the current number of containers, and using the target number of containers as the target configuration parameters of the container. Specifically, for example, the target number of containers can be calculated by "target number of containers = aggregated index data * current number of containers / aggregated index threshold". For example, there are currently 500 containers, the upper threshold of the aggregated index threshold of CPU usage set by the user is 80%, and the aggregated index data of CPU usage is 90%, then by calculating 500*90% = target number of containers (x) * 80%, it can be obtained that x = 562.5 (563), where x is rounded up to get the target number of containers, that is, it is necessary to expand 63 containers on the basis of 500 containers.

[0048] According to another embodiment of the present invention, when the scaling mode is vertical scaling, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rules corresponding to the vertical scaling, which may specifically include: calculating the target container specification parameters according to the aggregated index data, the index data threshold and the current container specification parameters, and using the target container specification parameters as the target configuration parameters of the container. Specifically, for example, the target container specification parameters can be calculated by "target container specification parameters = current container specification parameters * (1.5 + aggregated index data - aggregated index threshold)". For example, the current container specification is 4core8G (indicates: CPU is 4 cores, memory is 8G, and the memory defaults to twice the number of CPU cores). The CPU value is taken for calculation. Assuming that the user sets the upper threshold of the aggregated index threshold of CPU usage to 40%, and the aggregated index data of CPU usage is 90%, then by calculating x = 4core*(1.5+0.9-0.4), x = 8core can be obtained, that is, the final container specification is 8core16G (the memory defaults to twice the number of CPU cores).

[0049] According to an embodiment of the present invention, when the scaling mode is vertical scaling, calculating the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the vertical scaling includes: when the scaling mode is vertical scaling, obtaining an application identifier according to the system resource data, and obtaining a list of containers in which the application is deployed according to the application identifier; and calculating the target configuration parameters of each container in the container list according to the target configuration parameter calculation rule.

[0050] Afterwards, the first configuration parameter of the container will be updated according to the target configuration parameter. Specifically, the API interface service of Kubernetes can be called to modify the number of containers in the Pod that needs to be horizontally scaled, or the corresponding request resource parameter request and limit resource parameter limit in the specification parameters of the container in the Pod that needs to be vertically scaled. Afterwards, Kubernetes will store the corresponding Pod data in etcd. etcd is an open source distributed unified key-value storage used for shared configuration, service discovery, and scheduling coordination of distributed systems or computer clusters.

[0051] Step S103: In response to detecting that the first configuration parameter has changed, modify the second configuration parameter of the container in the container process according to the first configuration parameter, and update the container according to the modified second configuration parameter to complete the container resource configuration. Taking vertical expansion and contraction as an example, a listening agent agent is deployed on the physical machine of each Node node. The agent will periodically go to the API interface service of Kubernetes to query the resource configuration information of each container under all Pods under the current Node node (i.e., the first configuration parameter, mainly including CPU and memory), and compare it with the resource configuration information of each container on the current physical machine (i.e., the second configuration parameter, CPU and memory). If there is inconsistent data, the first configuration parameter shall prevail. Afterwards, the resource configuration parameters in the Pod are taken out (i.e., the corresponding request and limit), the container update instruction Docker update instruction is executed to complete the hot update of the container specification, and the cgroup information of the container process is modified to modify the second configuration parameter. Specifically, the parameters that can be modified are, for example, cpu.cfs_quota_us of the CPU and memory.memsw.limit_in_bytes of the memory. Among them, cpu.cfs_quota_us and memory.memsw.limit_in_bytes are parameters related to CPU and memory resource limits in the Linux kernel, and are technical terms. The former is used to limit the time quota of CPU usage by a process or container, and the latter is used to limit the total amount of memory and swap space (swap) that a process or container can use. The principle of modifying the container CPU and memory specifications described here is essentially achieved by adjusting the above two parameters.

[0052] Figure 2 It is a schematic diagram of the implementation process of container resource configuration of an embodiment of the present invention. According to an embodiment of the present invention, taking vertical expansion and contraction as an example, the implementation process of container resource configuration mainly includes: collecting system resource data through monitoring services, and performing aggregation processing to obtain aggregated indicator data; judging whether expansion and contraction processing is required based on aggregated indicator data and indicator data thresholds through expansion and contraction services; if expansion and contraction processing is required, calculating the target container specification parameters according to the target configuration parameter calculation rules, and modifying the container specification parameters by calling the Kubernetes interface service, and saving the modified specification parameters to etcd; the physical machine polls all Pods under the current Node node through the listening agent agent to determine whether there is a container with changed specification parameters; if so, modifying the cgroup information of the container process, and completing the hot update of the container specification by executing the container update instruction Docker update instruction.

[0053] Figure 3FIG. 1 is a schematic diagram of the main modules of the device for configuring container resources according to an embodiment of the present invention. Figure 3 As shown, the container resource configuration device 300 of the embodiment of the present invention mainly includes an indicator data processing module 301, a configuration parameter calculation module 302 and a configuration parameter modification module 303.

[0054] The indicator data processing module 301 is used to collect system resource data in response to monitoring system resource changes, and aggregate the system resource data to obtain aggregate indicator data;

[0055] A configuration parameter calculation module 302 is used to calculate the target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, and update the first configuration parameters of the container according to the target configuration parameters;

[0056] The configuration parameter modification module 303 is used to modify the second configuration parameter of the container in the container process according to the first configuration parameter in response to detecting that the first configuration parameter has changed, and update the container according to the modified second configuration parameter to complete the container resource configuration.

[0057] According to one embodiment of the present invention, the indicator data processing module 301 can also be used to: in response to monitoring system resource changes, collect system resource data, and aggregate the system resource data in the current collection period according to the collection time of the system resource data to obtain aggregated indicator data.

[0058] According to another embodiment of the present invention, the scaling rules include indicator data thresholds and target configuration parameter calculation rules; the configuration parameter calculation module 302 can also be used to: determine whether scaling is required based on the aggregated indicator data and the indicator data thresholds; and when it is determined that scaling is required, calculate the target configuration parameters of the container based on the target configuration parameter calculation rules.

[0059] According to another embodiment of the present invention, when the configuration parameter calculation module 302 determines that scaling processing is required, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule. It can also be used to: when it is determined that scaling processing is required, obtain an application identifier according to the system resource data, and obtain a scaling method corresponding to the application according to the application identifier, the scaling method including horizontal scaling and vertical scaling; when the scaling method is horizontal scaling, calculate the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the horizontal scaling; when the scaling method is vertical scaling, calculate the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the vertical scaling.

[0060] According to another embodiment of the present invention, when the scaling mode is horizontal scaling, the configuration parameter calculation module 302 calculates the target configuration parameters of the container according to the target configuration parameter calculation rules corresponding to the horizontal scaling, and can also be used to: calculate the target number of containers according to the aggregated indicator data, the indicator data threshold and the current number of containers, and use the target number of containers as the target configuration parameters of the container.

[0061] According to another embodiment of the present invention, when the scaling mode is vertical scaling, the configuration parameter calculation module 302 calculates the target configuration parameters of the container according to the target configuration parameter calculation rules corresponding to the vertical scaling, and can also be used to: calculate the target container specification parameters according to the aggregated indicator data, the indicator data threshold and the current container specification parameters, and use the target container specification parameters as the target configuration parameters of the container.

[0062] According to another embodiment of the present invention, when the scaling mode is vertical scaling, the configuration parameter calculation module 302 calculates the target configuration parameters of the container according to the target configuration parameter calculation rule corresponding to the vertical scaling, and can also be used to: when the scaling mode is vertical scaling, obtain an application identifier according to the system resource data, and obtain a list of containers deployed with the application according to the application identifier; for each container in the container list, calculate the target configuration parameters of the container according to the target configuration parameter calculation rule.

[0063] According to the technical solution of the embodiment of the present invention, in response to monitoring system resource changes, system resource data is collected, and the system resource data is aggregated to obtain aggregated indicator data; the target configuration parameters of the container are calculated according to the aggregated indicator data and the set expansion and contraction rules, and the first configuration parameters of the container are updated according to the target configuration parameters; in response to detecting that the first configuration parameter has changed, the second configuration parameters of the container in the container process are modified according to the first configuration parameters, and the container is updated according to the modified second configuration parameters to complete the technical solution of container resource configuration, which realizes dynamic adjustment of the configuration parameters of the container and the cgroup parameters in the container process, can synchronize resources in real time, thereby improving resource utilization, without destroying the Pod and recreating it, without causing business interruption, and facilitating business monitoring.

[0064] Figure 4 An exemplary system architecture 400 is shown to which the method for configuring container resources or the apparatus for configuring container resources according to an embodiment of the present invention may be applied.

[0065] like Figure 4As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0066] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0067] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0068] Server 405 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using terminal devices 401, 402, and 403 (for example only). The background management server may respond to the received container resource configuration request and other data by monitoring the system resource changes, collecting system resource data, and aggregating the system resource data to obtain aggregated index data; calculate the target configuration parameters of the container according to the aggregated index data and the set expansion and contraction rules, and update the first configuration parameters of the container according to the target configuration parameters; in response to detecting that the first configuration parameter has changed, modify the second configuration parameters of the container in the container process according to the first configuration parameter, and update the container according to the modified second configuration parameter to complete the container resource configuration and other processing, and feed back the processing results (such as container resource configuration results - for example only) to the terminal device.

[0069] It should be noted that the method for configuring container resources provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the device for configuring container resources is generally disposed in the server 405 .

[0070] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0071] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0072] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0073] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0074] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0075] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0076] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0077] The units or modules involved in the embodiments of the present invention may be implemented by software or hardware. The units or modules described may also be provided in a processor, for example, may be described as: a processor including an indicator data processing module, a configuration parameter calculation module, and a configuration parameter modification module. Among them, the names of these units or modules do not constitute limitations on the units or modules themselves in certain circumstances, for example, the configuration parameter modification module may also be described as "a module for modifying the second configuration parameter of the container in the container process according to the first configuration parameter in response to detecting a change in the first configuration parameter, and updating the container according to the modified second configuration parameter to complete the container resource configuration".

[0078] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: in response to monitoring system resource changes, collecting system resource data, and aggregating the system resource data to obtain aggregated index data; calculating the target configuration parameters of the container according to the aggregated index data and the set expansion and contraction rules, and updating the first configuration parameters of the container according to the target configuration parameters; in response to detecting that the first configuration parameter has changed, modifying the second configuration parameters of the container in the container process according to the first configuration parameter to complete the container resource configuration.

[0079] According to the technical solution of the embodiment of the present invention, in response to monitoring system resource changes, system resource data is collected, and the system resource data is aggregated to obtain aggregated indicator data; the target configuration parameters of the container are calculated according to the aggregated indicator data and the set expansion and contraction rules, and the first configuration parameters of the container are updated according to the target configuration parameters; in response to detecting that the first configuration parameter has changed, the second configuration parameter of the container in the container process is modified according to the first configuration parameter, and the container is updated according to the modified second configuration parameter to complete the technical solution of container resource configuration, which realizes dynamic adjustment of the configuration parameters of the container and the cgroup parameters in the container process, can synchronize resources in real time, thereby improving resource utilization, without destroying the Pod and recreating it, will not cause business interruption, and is convenient for business monitoring.

[0080] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for configuring container resources, characterized in that: include: In response to monitoring a system resource change, collecting system resource data, and aggregating the system resource data to obtain aggregated indicator data; Calculating target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, and performing first configuration parameter updates on the container according to the target configuration parameters; In response to detecting that the first configuration parameter has changed, a second configuration parameter of the container in the container process is modified according to the first configuration parameter, and the container is updated according to the modified second configuration parameter to complete the container resource configuration.

2. The method according to claim 1, characterized in that In response to monitoring a system resource change, collecting system resource data, and aggregating the system resource data to obtain aggregated indicator data, including: In response to monitoring a system resource change, system resource data is collected, and the system resource data in a current collection period is aggregated according to the collection time of the system resource data to obtain aggregated indicator data.

3. The method according to claim 1, characterized in that The scaling rules include indicator data thresholds and target configuration parameter calculation rules; Calculating target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, including: Determining whether expansion or contraction processing is required according to the aggregated indicator data and the indicator data threshold; When it is determined that expansion and contraction processing is required, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule.

4. The method according to claim 3, characterized in that When it is determined that expansion and contraction processing is required, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule, including: When it is determined that scaling is required, obtaining an application identifier according to the system resource data, and obtaining a scaling method corresponding to the application according to the application identifier, wherein the scaling method includes horizontal scaling and vertical scaling; When the capacity expansion mode is horizontal capacity expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the horizontal capacity expansion; When the capacity expansion mode is vertical capacity expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the vertical capacity expansion.

5. The method according to claim 4, characterized in that When the capacity expansion mode is horizontal capacity expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the horizontal capacity expansion, including: The target number of containers is calculated according to the aggregated indicator data, the indicator data threshold and the current number of containers, and the target number of containers is used as a target configuration parameter of the container.

6. The method according to claim 4, characterized in that When the capacity expansion mode is vertical capacity expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the vertical capacity expansion, including: Calculate target container specification parameters according to the aggregated indicator data, the indicator data threshold, and current container specification parameters, and use the target container specification parameters as target configuration parameters of the container.

7. The method according to claim 4, characterized in that When the capacity expansion mode is vertical capacity expansion, the target configuration parameters of the container are calculated according to the target configuration parameter calculation rule corresponding to the vertical capacity expansion, including: When the scaling mode is vertical scaling, obtaining an application identifier according to the system resource data, and obtaining a list of containers in which the application is deployed according to the application identifier; For each container in the container list, a target configuration parameter of the container is calculated according to the target configuration parameter calculation rule.

8. A device for configuring container resources, characterized in that: include: An indicator data processing module, configured to collect system resource data in response to monitoring changes in system resources, and aggregate the system resource data to obtain aggregate indicator data; A configuration parameter calculation module, used to calculate the target configuration parameters of the container according to the aggregated indicator data and the set expansion and contraction rules, and update the first configuration parameters of the container according to the target configuration parameters; A configuration parameter modification module is used to modify a second configuration parameter of the container in the container process according to the first configuration parameter in response to detecting a change in the first configuration parameter, and update the container according to the modified second configuration parameter to complete container resource configuration.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.