Container pool capacity expanding and shrinking method, system and equipment, storage medium and program product
By adopting an elastic resource instance-based and declarative scaling approach in the container pool, the number of containers can be dynamically adjusted, solving the problem of insufficient elastic scaling capability of the container pool, achieving more flexible container pool management, reducing resource waste, and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA CLOUD COMPUTING CO LTD
- Filing Date
- 2024-11-06
- Publication Date
- 2026-05-08
AI Technical Summary
Existing container pools have insufficient elastic scaling capabilities and poor flexibility, which can easily lead to a situation where there are too many or too few idle containers, resulting in resource waste or a decline in user experience.
It adopts a container pool construction approach based on elastic resource instances and a declarative elastic scaling approach. By monitoring the status and number of containers in the container pool and combining pre-configured scaling conditions and step parameters, it dynamically adjusts the number of containers in the container pool, avoiding reliance on predictions of future task volume and achieving flexible scaling operations.
It improves the elastic scaling capability of the container pool, reduces the situation of too many or too few idle containers, reduces resource waste, and enhances the user experience.
Smart Images

Figure CN121996346A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and in particular to a method, system, device, storage medium, and program product for scaling up and down a container pool. Background Technology
[0002] In a cloud computing environment, different tasks can provide different services to users by executing different code logic. For example, in pipeline products that help enterprises from code development to deployment, tasks such as compilation, code scanning, and automated testing can provide users with editing services, code scanning services, and automated testing services by executing different code logic.
[0003] To achieve secure isolation between different tasks, a container can be created on a node in the Kubernetes (K8s, container automation platform) cluster to host the task when the user submits it, allowing different tasks to be deployed and run in different containers. However, the container creation process involves allocating virtual machines (VMs), requesting IP addresses, and loading image files, which is time-consuming and results in long task startup times and a poor user experience.
[0004] To address this, existing technologies have proposed the concept of container pools. This involves pre-creating container pools on nodes within a Kubernetes cluster and dynamically adjusting the number of containers in the pool based on predictions of future task load. When a user submits a task, an idle container can be directly retrieved from the pool. After downloading the relevant toolkit from the idle container, the task can be deployed to that container. This saves time during container creation, accelerates task startup, and improves the user experience.
[0005] However, existing container pools have insufficient elastic scaling capabilities and poor flexibility, which can easily lead to a situation where there are too many or too few idle containers, resulting in wasted resources or a decline in user experience. Summary of the Invention
[0006] This application provides a method, system, device, storage medium, and program product for scaling up and down a container pool, which can improve the elastic scaling up and down capability of the container pool, minimize the situation of too many or too few idle containers, reduce resource waste, and improve user experience.
[0007] This application provides a method for scaling up or down a container pool. The container pool is hosted on an elastic resource instance, which is obtained by virtualizing resource nodes in a container cluster. The container pool is configured with scaling up / down conditions and scaling up / down step parameters. The method includes: during the operation of the container pool, monitoring the status and number of containers in the container pool, wherein the status and number of containers are dynamically changing; if the container pool meets the scaling up conditions based on the status and number of containers, determining the scaling up step size based on the scaling up step parameters, and scaling up the container pool according to the scaling up step size; if the container pool meets the scaling down conditions based on the status and number of containers, determining the scaling down step size based on the scaling down step parameters, and scaling down the container pool according to the scaling down step size.
[0008] This application embodiment also provides a container pool system, including: a container pool hosted on an elastic resource instance, a server node, and a control node; wherein, the elastic resource instance is obtained by virtualizing resource nodes in a container cluster; the control node is used to monitor the status and number of containers in the container pool during the operation of the container pool, and report to the server node, the status and number of containers being dynamically changed; the server node is used to configure the scaling conditions and scaling step parameters of the container pool, and to receive the status and number of containers reported by the control node, if the container pool meets the scaling conditions based on the status and number of containers, determine the scaling step size based on the scaling step parameters, and scale the container pool according to the scaling step size; if the container pool meets the shrinking conditions based on the status and number of containers, determine the shrinking step size based on the shrinking step parameters, and shrink the container pool according to the shrinking step size.
[0009] This application also provides an electronic device, including: a memory and a processor; the memory is used to store a computer program, and the processor is coupled to the memory and used to execute the computer program to implement the steps in the expansion and contraction method of the container pool.
[0010] This application also provides a computer-readable storage medium including a computer program / instructions that, when executed by a processor, enable the processor to implement the steps in the method for scaling up or down the container pool.
[0011] This application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, enable the processor to implement the steps in the scaling method of the container pool.
[0012] In this embodiment, a container pool construction approach based on elastic resource instances and a declarative elastic scaling approach are integrated. Leveraging the elasticity and flexibility of elastic resource instances, the elastic scaling capability of container pools is addressed by addressing the limitation imposed by the number of resource nodes. Declarative elastic scaling refers to the process of scaling the container pool based on its state and quantity, along with pre-configured scaling conditions and scaling step parameters. This eliminates reliance on predictions of future task loads, freeing the container pool's elastic scaling capability from the limitations of prediction algorithm accuracy. This allows for more flexible scaling operations, resulting in a stronger and more flexible scaling capability, reducing the likelihood of too many or too few idle containers, minimizing resource waste, and improving user experience. Attached Figure Description
[0013] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0014] Figure 1 A schematic flowchart of a method for expanding and shrinking a container pool provided as an exemplary embodiment of this application;
[0015] Figure 2 A schematic diagram of a container pool system provided in an exemplary embodiment of this application;
[0016] Figure 3 A schematic diagram of a container pool system in a real-world application scenario provided as an exemplary embodiment of this application;
[0017] Figure 4 A schematic flowchart illustrating the container pool expansion process provided for an exemplary embodiment of this application;
[0018] Figure 5 A schematic flowchart illustrating the container pool scaling-down process provided for an exemplary embodiment of this application;
[0019] Figure 6 A schematic diagram of a user task scheduling process provided for an exemplary embodiment of this application;
[0020] Figure 7 A schematic diagram of the structure of a container pool expansion / contraction device provided for an exemplary embodiment of this application;
[0021] Figure 8 A schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] It should be noted that, in the cases involving user information in the embodiments of this application, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) comply with relevant laws and standards.
[0024] Currently, container pools created based on Kubernetes clusters face problems such as insufficient elastic scaling capabilities and poor flexibility. The inventors of this case observed and studied the current usage of container pools and tracked the failure of elastic scaling during use. If there are too many idle containers, it will lead to serious resource waste; if there are not enough idle containers, user tasks will not be able to start in time, resulting in a degraded user experience.
[0025] To address the resource waste and user experience degradation caused by insufficient elastic scaling capabilities of container pools, the inventors of this case conducted in-depth technical research into the causes of this problem and ultimately discovered that: First, existing container pools are based on nodes in a Kubernetes cluster, and their elastic scaling capabilities are limited by the number of nodes purchased by the user. Each node can only support a limited number of containers. If the number of nodes is insufficient, the number of containers cannot be further expanded, leading to scaling failure and a shortage of idle containers. Second, the elastic scaling capabilities of existing container pools require a high degree of accuracy in predicting future task loads. If the prediction results are inaccurate, unreasonable container scaling can easily occur, resulting in either too many or too few idle containers. For example, if the predicted workload is heavy, the containers will be expanded in advance (i.e., the number of containers will be increased). However, if the actual workload does not reach the predicted workload, there will be a lot of idle containers, resulting in wasted resources. If the predicted workload is light, the containers will be shrunk in advance (i.e., the number of containers will be reduced). However, if the actual workload is much greater than the predicted workload, there will be a shortage of idle containers, which will prevent user tasks from being deployed and run in a timely manner, resulting in a poor user experience.
[0026] Regarding the first reason mentioned above, the inventor's initial solution was to elastically scale the number of nodes in the cluster to address the limitation of the container pool's elastic scaling capability by the number of nodes. However, nodes in a cluster are generally physical machines. While reducing the number of active physical machines is relatively easy given the existing number, if the number of existing physical machines is insufficient, this involves purchasing physical machines, as well as deploying and maintaining them, resulting in relatively high costs and a longer implementation period. Therefore, achieving elastic scaling of the number of nodes in the cluster is costly and lacks flexibility.
[0027] Regarding the second reason mentioned above, the inventor's initial solution was to improve the prediction algorithm used for predicting future task loads, thereby increasing its accuracy. However, the improvement in prediction algorithm accuracy is limited and cannot guarantee 100% accuracy. Inaccurate predictions can still lead to unreasonable container expansion and contraction, resulting in either too many or too few idle containers. Furthermore, once the prediction algorithm reaches a certain level of accuracy, further improvements become quite difficult.
[0028] Based on the above findings, research and analysis, the inventors of this case have provided a new solution by changing the innovative approach: In this solution, the container pool construction approach based on elastic resource instances and the declarative elastic scaling approach are integrated. The combination of the two solves the problems of insufficient elasticity and poor flexibility of the container pool, improves the elastic scaling capability of the container pool, greatly reduces the situation of too many or too few idle containers, reduces resource waste, and improves user experience.
[0029] Among them, the construction of container pools based on elastic resource instances refers to virtualizing resource nodes in a container cluster to obtain elastic resource instances, and then building container pools on elastic resource instances. By leveraging the elasticity and flexibility of elastic resource instances, the problem of the elastic scaling capability of container pools being limited by the number of resource nodes can be solved. Based on this, the container pool can be flexibly scaled up as needed.
[0030] Among them, declarative elastic scaling refers to the process of scaling the container pool based on the state and number of containers in the pool, combined with pre-configured scaling conditions and scaling step parameters. The entire scaling process no longer relies on the prediction of future task volume, so the elastic scaling capability of the container pool is no longer limited by the accuracy of the prediction algorithm. In addition, the scaling conditions and scaling step parameters can be flexibly configured according to application needs. Based on the state and number of containers in the pool, combined with the flexibly configurable scaling conditions and scaling step parameters, the container pool can be scaled up and down more flexibly, making the scaling capability of the container pool stronger and more flexible.
[0031] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0032] Figure 1 This is a flowchart illustrating a method for scaling up or down a container pool, provided as an exemplary embodiment of this application. Figure 1 As shown, the method may include:
[0033] Step 11: During the operation of the container pool, monitor the status and number of containers in the container pool. The status and number of containers are dynamic.
[0034] Step 12: If the container pool meets the expansion conditions based on the status and quantity of the containers, determine the expansion step size based on the expansion step parameters, and expand the container pool according to the expansion step size.
[0035] Step 13: If the container pool meets the shrinkage conditions based on the state and quantity of the containers, determine the shrinkage step size based on the shrinkage step parameters, and shrink the container pool according to the shrinkage step size.
[0036] In this embodiment, a container pool refers to a collection of containers (also called container instances). The number of container pools can be one or more. The scaling up and down method is the same for any container pool; therefore, in subsequent embodiments, the scaling up and down process of any container pool will be used as an example. Each container pool has a maximum number of containers it can support, which can be called the upper limit of the number of containers. The upper limit of the number of containers corresponding to different container pools can be the same or different, and this is not limited. The number and status of containers in a container pool are dynamically changing. Furthermore, containers in the same container pool can share storage, computing, network, and other resources, but are independent and isolated from each other.
[0037] In this embodiment, the container pool is hosted on an Elastic Resource Instance (ERI), which is a resource management instance based on cloud-native technology. This ERI can dynamically adjust various infrastructure resources according to demand. Based on ERI, users can deploy and run containerized applications more efficiently without managing the underlying infrastructure. Because ERI can improve resource utilization and reduce costs through dynamic resource adjustment, and offers high reliability and flexibility, it is more suitable for application scenarios with large load changes or elastic scaling requirements. Deploying the container pool on an ERI allows for efficient scaling of the container pool.
[0038] Elastic resource instances are obtained by virtualizing resource nodes in a container cluster. A container cluster refers to various resource clusters containing resource nodes and possessing container orchestration and scheduling capabilities, such as Kubernetes container clusters, self-developed container clusters, or any other type of container cluster; this embodiment does not impose any limitations. Resource nodes in a container cluster are the basic units constituting the infrastructure resources of the container cluster, responsible for providing infrastructure resources such as processors (Central Processing Units, CPUs), memory, storage, and networks. The virtualization of resource nodes in a container cluster to obtain elastic resource instances can be achieved primarily through the following steps: First, the resource nodes in the container cluster are abstracted into virtual resources, such as virtual computing resources, virtual storage resources, and virtual network resources. Virtual computing resources may include VCPU (Virtual Central Processing Unit), VGPU (Virtual Graphics Processing Unit), etc.; virtual storage resources may include virtual memory, virtual disk space, virtual I / O (Input / Output), etc.; virtual network resources may include virtual network cards, virtual networks, etc. Next, a virtualization management layer can be created to manage these virtual resources and allocate them to different elastic resource instances as needed. The virtualization management layer can be hardware-assisted virtualization or operating system-level virtualization, or it can be a virtualization technology specifically designed for container clusters, such as node virtualization technology in Kubernetes; this embodiment is not limited to any particular type. The virtualization management layer includes: a creation component for creating elastic resource instances based on application requirements, an automated management component for allocating virtualization resources to elastic resource instances, and an auto-scaling component for elastically scaling the resource specifications of elastic resource instances, ultimately achieving the virtualization of resource nodes and the management of elastic resource instances.
[0039] Creating a container pool is done on top of an Elastic Resource Instance (Elastic Resource Instance). Specifically, container orchestration services or tools can be used to create container pools on Elastic Resource Instances. For example, a container coding service can provide a service page for Elastic Resource Instances. Container pool requesters can access this service page and submit a container pool creation request. Upon receiving the request, the container coding service names the container pool for easy management and identification. It then selects the image files required to create the containers in the pool. From the resources bound to the Elastic Resource Instance, it configures the resource specifications for the container pool, such as the number of VCPU cores, memory size, persistent storage type, and persistent storage space size. It also configures the network for the container pool, such as configuring a Virtual Private Network (VPC), subnets within the VPC, and ports. Finally, it creates containers within the container pool based on the image files, completing the container pool creation process.
[0040] After creating a container pool, if a user in the container cluster triggers a task, the task scheduler can first check if there are any idle containers in the pool. If an idle container exists and its resource specifications meet the requirements of the task to be deployed, the task can be directly deployed into the container without real-time container creation. This saves on the series of operations required for container creation, reduces the waiting time after the user triggers the task, and improves task startup efficiency and user experience. If there are no idle containers in the container pool, the container creation interface provided by the container cluster can be called to create a container in real time, and the task can be deployed into the newly created container, ensuring that the task can be successfully deployed and executed.
[0041] In this embodiment, it is desirable that the number of containers in the container pool can dynamically change according to user demand. For example, during peak task periods, sufficient containers can be prepared in the container pool in advance, so that when a user triggers a task, container binding can be performed directly, reducing the waiting time after the user triggers the task. During off-peak task periods, the number of containers in the container pool can be dynamically reduced, reducing the resources occupied by idle containers while ensuring a certain container hit rate. To address this issue, this embodiment adopts a declarative elastic scaling approach, that is, scaling rules are pre-configured for the container pool. These scaling rules include at least scaling conditions and scaling step parameters. The scaling conditions refer to the conditions used to trigger capacity adjustment during the scaling process. Further, the scaling conditions include scaling conditions and shrinking conditions. The scaling step parameters refer to the parameters used to control the capacity adjustment magnitude (or adjustment step size) during the scaling process. The scaling step parameters include scaling step parameters and shrinking step parameters. The specific implementation of the scaling conditions and scaling step parameters can be found in subsequent embodiments, and will not be detailed here. This includes providing an interface for operations and maintenance personnel to configure scaling rules. Through this interface, personnel can input scaling conditions and scaling step parameters. In this way, operations and maintenance personnel can quickly and flexibly configure scaling rules according to application needs and update the container pool's scaling rules in a timely manner.
[0042] Unlike command-based scaling, declarative elastic scaling allows operations personnel to describe how the container pool should operate by declaring the desired container pool state, eliminating reliance on predictions of future workloads. Here, the container pool state refers to the state constrained by scaling rules. In this embodiment, the number of containers in the pool can be automatically adjusted based on the current state and quantity of containers, combined with the scaling conditions and scaling step parameters in the scaling rules, to achieve the desired container pool state. In this embodiment, operations personnel only need to pre-configure scaling rules (mainly scaling conditions and scaling step parameters) to automatically and efficiently complete container pool scaling operations, without frequently issuing scaling commands or requiring frequent intervention from operations personnel. In contrast, the command-based scaling approach relies on predictions of future workloads. It requires operations personnel to issue a series of specific commands to describe how to scale up or down, depending not only on the accuracy of the predictions but also on manual intervention. For operations personnel, the logic of this command-based scaling approach is also more complex. In comparison, the declarative elastic scaling approach adopted in this embodiment can achieve elastic scaling of the container pool more efficiently and quickly.
[0043] In this embodiment, due to constantly changing user needs or the container's own operating rules, the state and number of containers in the container pool are dynamically changing. For example, when a user needs to create, delete, or close a container, the state and number of containers in the container pool will change; similarly, if the container's own operating rules specify start and stop time periods, the state and number of containers in the container pool will also change. Therefore, the state and number of containers in the container pool can be monitored during the container pool's operation. The container state includes, but is not limited to, usage state, idle state, and fault state, etc., and this embodiment does not impose any restrictions. Usage state indicates that the container is being used; idle state indicates that the container is not used and is idle; fault state indicates that the container is suspended due to a fault. When a new container is created, the number of containers increases; when an old container is deleted, the number of containers decreases.
[0044] This application does not limit the specific monitoring method. In one exemplary embodiment, the status and quantity of containers in the container pool can be monitored in real time. In another exemplary embodiment, the status and quantity of containers in the container pool can also be monitored periodically according to a preset monitoring cycle. This embodiment does not impose any limitations.
[0045] Next, it can be determined whether the status and quantity of containers in the container pool meet the scaling conditions. This embodiment does not limit the specific implementation of the scaling conditions; the scaling conditions can be configured as any condition according to the needs of the operations and maintenance personnel. For example, the scaling conditions can be conditions corresponding to the container status or the number of containers, conditions corresponding to both the container status and the number of containers, container occupancy conditions, or duration conditions, etc. This embodiment does not impose any restrictions.
[0046] Taking the expansion condition corresponding to the number of containers as an example, the expansion condition can be that the total number of containers in the container pool is less than the set first threshold of the total number of idle containers, such as 50. If the total number of containers in the container pool is 49, then it can be determined that the container pool meets the expansion condition.
[0047] Taking the reduction condition as an example, the reduction condition can be that the total number of containers in the container pool is greater than the set second threshold for the total number of containers, such as 80. If the total number of containers in the current container pool is 90, then it can be determined that the container pool meets the reduction condition.
[0048] Taking the expansion condition as an example where the number and status of containers are both corresponding, the expansion condition can be that the total number of containers in the container pool is less than a set first threshold for the total number of idle containers, such as 50, and the number of containers in the idle state is less than a first threshold for the number of idle containers, such as 20. If it is determined from the number and status of containers in the container pool that the total number of containers currently existing in the container pool is 40 and the number of containers in the idle state is 10, then it can be determined that the container pool meets the expansion condition.
[0049] Taking the reduction condition as an example where the number and status of containers are both corresponding, the reduction condition can be that the total number of containers in the container pool is greater than a set second total number threshold, such as 80, and the number of containers in the idle state is greater than a second idle container number threshold, such as 30. If it is determined from the number and status of containers in the container pool that the total number of containers currently existing in the container pool is 90 and the number of containers in the idle state is 40, then it can be determined that the container pool meets the reduction condition.
[0050] It should be noted that the methods listed above for determining whether a container pool meets the expansion / shrinkage conditions based on the current state and quantity of containers are merely examples and are not limited to these. In addition to the methods described in the foregoing embodiments for directly determining whether a container pool meets the expansion / shrinkage conditions based on the state and quantity of containers, in some optional embodiments, the container occupancy rate of the container pool can be determined based on the state and quantity of containers, and then the container occupancy rate can be used to indirectly determine whether the container pool meets the expansion / shrinkage conditions.
[0051] Specifically, the expansion conditions in the aforementioned embodiments may include a first container occupancy rate threshold, and the reduction conditions may include a second container occupancy rate threshold and a preset duration. The first container occupancy rate threshold, the second container occupancy rate threshold, and the preset duration can be set to any value according to application requirements, as long as the second container occupancy rate threshold is less than the first container occupancy rate threshold. This implementation does not impose any restrictions on this. For example, the first container occupancy rate threshold can be 80%, and the second container occupancy rate threshold can be 40%; or, the first container occupancy rate threshold can be 90%, and the second container occupancy rate threshold can be 50%, and so on. Based on this, the container occupancy rate of the container pool can be determined according to the status and quantity of the containers; the container occupancy rate refers to the ratio of the number of containers currently in use to the total number of containers in the container pool. For example, if the total number of containers in the container pool is currently 100, and 40 containers are in use, then the container occupancy rate is 40 ÷ 100 × 100% = 40%.
[0052] Considering that scaling up and scaling down have different requirements, scaling up often needs to be faster and more timely to ensure timely deployment and startup of user tasks, avoiding a degraded user experience due to long waiting periods before task deployment. Scaling down, on the other hand, requires greater stability to prevent delays in deploying and starting new user tasks. Therefore, different criteria can be used for scaling up and scaling down: If the container utilization rate is greater than or equal to the first container utilization rate threshold, it indicates a high container utilization rate in the container pool, and new idle containers should be added promptly to ensure timely deployment of tasks triggered by users. Therefore, the container pool meets the scaling up criteria. If the container utilization rate is less than or equal to the second container utilization rate threshold and this state persists for a preset duration, it indicates a low container utilization rate in the container pool, and the number of idle containers should be reduced to conserve resources while ensuring timely deployment of tasks to idle containers after user-triggered tasks. Therefore, the container pool meets the scaling down criteria. In this optional embodiment, when determining whether the container pool meets the scaling-down conditions, the container occupancy rate must remain below or equal to a second container occupancy rate threshold for a preset duration. This preset duration serves as a buffer time for users to potentially trigger a large number of new tasks. Scaling down only occurs if no users trigger a large number of new tasks within the preset duration (i.e., the container occupancy rate remains below or equal to the second container occupancy threshold). This avoids the problem of being unable to deploy and start user-triggered new tasks in a timely manner due to excessively rapid scaling down, prioritizing user experience. The specific value of the preset duration can be flexibly set according to application requirements and the pattern of user task triggering, for example, it could be 3 minutes, 5 minutes, 1 hour, etc.
[0053] By employing the various methods described above, different criteria can be used for scaling up and down, enabling relatively rapid scaling up and relatively stable scaling down to meet users' needs for timely deployment and startup of tasks, thereby improving user experience.
[0054] Furthermore, regardless of the method used to determine whether the container pool meets the expansion / shrinkage conditions, if the container pool meets the expansion conditions based on the container's state and quantity, then the expansion step size can be determined according to the expansion step parameters, and the container pool can be expanded accordingly. For example, if the expansion step size determined by the expansion step parameters is 5, then each expansion operation can create 5 new containers in the container pool. Similarly, regardless of the method used to determine whether the container pool meets the expansion / shrinkage conditions, if the container pool meets the shrinkage conditions based on the container's state and quantity, then the shrinkage step size can be determined according to the shrinkage step parameters, and the container pool can be shrunk accordingly. For example, if the shrinkage step size determined by the shrinkage step parameters is 2, then each shrinkage operation can delete 2 idle containers in the container pool.
[0055] In this embodiment, the specific implementation of the expansion step parameters and the reduction step parameters is not limited, nor is the method of determining the expansion step size based on the expansion step parameters and the reduction step size based on the reduction step parameters limited. The expansion process and the reduction process will be described in detail below.
[0056] (1) Expansion process:
[0057] In an optional embodiment, the expansion step parameters may include: an expansion ratio value and a lower limit value for the expansion step size. The expansion ratio value refers to the proportion of newly added containers to the total number of containers in the container pool during each expansion, and the lower limit value for the expansion step size refers to the minimum number of containers that should be added during each expansion.
[0058] Based on the above, when determining the expansion step size according to the expansion step parameters, the first basic step size can be calculated based on the number of containers currently existing in the container pool and the expansion ratio. This application does not limit the specific calculation method of the first basic step size. In some exemplary embodiments, the first basic step size can be obtained by multiplying the number of containers currently existing in the container pool by the expansion ratio; alternatively, a candidate basic step size can be obtained by multiplying the number of containers currently existing in the container pool by the expansion ratio, and then corrected using a preset step size correction value to obtain the first basic step size; alternatively, the expansion ratio can be corrected using a preset ratio correction value, and then multiplied by the corrected expansion ratio value with the number of containers currently existing in the container pool to obtain the first basic step size. This embodiment does not impose any limitations. After calculating the first basic step size, the larger of the first basic step size and the lower limit of the expansion step size can be selected as the expansion step size.
[0059] This approach uses a combination of expansion ratio and expansion step size lower limit as expansion step parameters. The first base step size is determined based on the expansion ratio and the current number of containers, allowing expansion to proceed proportionally to the number of containers in the current container pool. Specifically, if the container pool has a large number of containers, expansion is needed, indicating a heavy workload. Expanding proportionally to the current number of containers allows for the creation of more new containers each time, facilitating rapid expansion to meet the deployment needs of heavy workloads. Conversely, if the container pool has a small number of containers, expansion is needed, indicating a relatively light workload. Expanding proportionally to the current number of containers allows for the creation of fewer new containers each time, achieving expansion to meet deployment needs while avoiding idle container resources due to rapid expansion. Furthermore, the lower limit of the expansion step size prevents situations where insufficient or sudden reduction in the number of containers makes rapid expansion based solely on container count insufficient, minimizing the probability of container resource shortages in the container pool. For example, if a large number of user tasks finish within a short period, resulting in the deletion of a large number of containers, or if the lifecycle of a large number of containers ends simultaneously, the number of remaining containers will be relatively small, leading to a smaller calculated base step size. This may result in problems with timely and rapid scaling. This embodiment, by setting a lower limit for the scaling step size, ensures that the number of new containers added during each scaling operation is not less than the lower limit, thus effectively preventing situations where timely and rapid scaling is impossible due to a sudden decrease in the number of containers.
[0060] In another optional embodiment, the expansion stepping parameters may include: a set initial step size, which can be directly used as the expansion step size; or, the initial step size can be modified based on the total number of containers in the current container pool and / or the number of containers in an idle state, and the modified step size can be used as the expansion step size. This application embodiment does not limit the method of modifying the initial step size. For example, if the total number of containers in the current container pool and / or the number of containers in an idle state is large, the initial step size can be decreased; if the total number of containers in the current container pool and / or the number of containers in an idle state is small, the initial step size can be increased.
[0061] The above implementation methods for expansion step parameters and for determining the expansion step size based on expansion step parameters are merely examples and are not limited to these.
[0062] Furthermore, after determining the expansion step size, the container pool can be expanded according to the expansion step size. There are no restrictions on the implementation method for expanding the container pool.
[0063] In one alternative implementation, an image file required for container creation can be obtained. A base container is then created in a container pool based on the image file, providing a basic container environment. A toolkit is installed within this base container environment to obtain a container capable of directly deploying tasks. This toolkit includes the necessary technology stack tools for deploying tasks within the container, such as programming tools for various programming languages like Java and Go, and container management components (like Docker). It should be noted that since the container is created pre-built in the container pool, this container creation process does not affect the task deployment and startup time after the user triggers the task.
[0064] In another alternative implementation, container snapshots can be used to facilitate rapid container creation. Based on container snapshots, the process of scaling the container pool according to the scaling step can be implemented based on the following steps R1-R2:
[0065] Step R1: Obtain a pre-created container snapshot. A container snapshot is a snapshot of the container's state recorded beforehand. This snapshot may include the base container environment and toolkits installed within that environment. The base container environment refers to the container's runtime environment, which may contain toolkits for task deployment. These toolkits may include the tools required to deploy tasks within the container. The tools needed to deploy tasks within the container can be used to simplify the deployment process, automate task execution, manage and monitor applications, and include, but are not limited to, configuration management tools, CI / CD (Continuous Integration / Continuous Delivery) tools, and scripting language interpreters.
[0066] Before using container snapshots, they can be created in advance. The creation process of a container snapshot includes: creating a base container based on the container's image file, where a base container environment can be provided. This can be done using the container creation service in the container cluster, or by calling the container creation interface exposed by the container cluster. This embodiment does not impose any limitations. The base container environment is relatively blank. Further, toolkits can be installed in the base container, and a snapshot can be created for the base container with the toolkits installed, serving as the container snapshot. This application embodiment does not limit the specific implementation method of snapshot creation. In some exemplary embodiments, the Velero plugin (a backup tool for Kubernetes clusters) can be used to save the current container state of the base container to obtain a container snapshot; a new base image can also be generated based on the current container state of the base container, serving as the container snapshot; or the API (Application Programming Interface) provided by the container cluster for snapshot creation can be called to create a snapshot. By creating container snapshots in advance, the necessary environment and tools for creating new containers are prepared in advance, which helps to reduce time consumption and improve container creation efficiency during the subsequent container creation process.
[0067] Step R2: Use container snapshots to create new containers of scaling step size in the container pool to scale the container pool. Since container snapshots already contain the basic container environment and corresponding toolkits, the new containers created in the container pool using container snapshots will also contain the basic container environment and corresponding toolkits, and can be directly used for task deployment.
[0068] Unlike schemes that synchronously configure the container environment and toolkits during the creation of a new container, this embodiment adopts an asynchronous configuration scheme. That is, a container snapshot is created in advance to complete the preliminary preparation of the container environment and toolkits. This ensures that the new container created using the container snapshot contains the container environment and toolkits, and only needs to wait for the container to enter the Ready state. There is no need to wait for the image file creation process or the toolkit download and installation process, which take approximately 5 to 30 seconds. Relatively speaking, creating a container based on a container snapshot can save 5 to 30 seconds of time, effectively improving the efficiency of container creation.
[0069] Alternatively, to avoid the continuous increase in the number of containers in the container pool, the pre-configured scaling rules may also include an upper limit for the number of containers. In this case, during the scaling up of the container pool, it is also necessary to determine whether the total number of containers in the container pool has reached the upper limit for the number of containers. When the upper limit for the number of containers is reached, the scaling up operation is stopped.
[0070] (2) Volume reduction process:
[0071] In an optional embodiment, the scaling-down step parameter may include: a scaling-down ratio value and a scaling-down step size upper limit value. The scaling-down ratio value refers to the proportion of the number of containers reduced each time the scale is reduced to the total number of containers in the container pool. The scaling-down step size upper limit value refers to the maximum number of containers that can be reduced each time the scale is reduced.
[0072] Based on the above, when determining the scaling-down step size according to the scaling-down step parameters, the second basic step size can be calculated based on the number of containers currently existing in the container pool and the scaling-down ratio. This application does not limit the specific calculation method of the second basic step size. In some exemplary embodiments, the second basic step size can be obtained by multiplying the number of containers currently existing in the container pool by the scaling-down ratio; alternatively, a candidate basic step size can be obtained by multiplying the number of containers currently existing in the container pool by the scaling-down ratio, and then corrected using a preset step size correction value to obtain the second basic step size; alternatively, the scaling-down ratio can be corrected using a preset ratio correction value, and then multiplied by the corrected scaling-down ratio value with the number of containers currently existing in the container pool to obtain the second basic step size. This embodiment does not impose any limitations on this. After calculating the second basic step size, the smaller of the second basic step size and the upper limit of the scaling-down step size can be selected as the scaling-down step size.
[0073] This approach uses a combination of a scaling-down ratio and a maximum scaling-down step size as the scaling-down step parameter. A second base step size can be determined based on the scaling-down ratio and the current number of containers, allowing scaling down proportionally to the number of containers in the current container pool. Specifically, if the container pool has a large number of containers, scaling down indicates a lighter workload. Scaling down proportionally to the current number of containers in the pool allows for the removal of more idle containers each time, facilitating rapid scaling and conserving resources while meeting the deployment needs of lighter tasks. Conversely, if the container pool has a small number of containers, scaling down indicates a very light workload. Scaling down proportionally to the current number of containers allows for the removal of relatively fewer idle containers each time, preventing overly rapid scaling that could overwhelm task deployment requirements. Furthermore, the maximum scaling-down step size prevents excessively rapid scaling from hindering the timely deployment and startup of new user tasks. For example, without an upper limit on the scaling-down step size, a large scaling-down step size might be used, resulting in the deletion of too many containers at once during subsequent scaling-downs. If new user tasks are received in this situation, they will be unable to be deployed and started due to insufficient container count. This embodiment, by setting an upper limit on the scaling-down step size, ensures that the number of containers reduced during each scaling-down will not exceed the upper limit, thus preventing excessively rapid scaling-down in subsequent steps.
[0074] In another optional embodiment, the scaling-down stepping parameter may include: a set initial step size, which can be directly used as the scaling-down step size; or, the initial step size can be modified based on the total number of containers in the current container pool and / or the number of containers in an idle state, and the modified step size can be used as the scaling-down step size. This application embodiment does not limit the method of modifying the initial step size. For example, if the total number of containers in the current container pool and / or the number of containers in an idle state is large, the initial step size can be increased; if the total number of containers in the current container pool and / or the number of containers in an idle state is small, the initial step size can be decreased.
[0075] The above implementation methods for the shrinkage step parameters and the implementation methods for determining the shrinkage step size based on the shrinkage step parameters are merely examples and are not limited thereto.
[0076] Furthermore, after determining the scaling-down step size, the container pool can be scaled down according to the scaling-down step size. This application does not limit the specific implementation of "scaling down the container pool according to the scaling-down step size." In one exemplary embodiment, based on the state of the containers in the container pool, a number of faulty containers can be selected from the container pool for scaling-down step size, and these faulty containers can be deleted from the container pool. In another exemplary embodiment, based on the state of the containers in the container pool, a number of containers undergoing restart can be selected from the container pool for scaling-down step size, and these restarted containers can be deleted from the container pool.
[0077] In yet another exemplary embodiment, based on the state of the containers in the container pool, a shrinkage step size of free containers can be selected from the container pool; the shrinkage step size of free containers can be deleted from the container pool to shrink the container pool.
[0078] Specifically, based on the container status and creation time of the containers in the container pool, the earliest created idle containers (with a scaling step size) can be selected from the pool. In other words, first determine which containers are idle based on their status and designate them as idle containers; then, combine this with other additional conditions to determine the number of idle containers for the scaling step size. For example, based on the container creation time, select the earliest created idle container from the idle containers as the number of idle containers for the scaling step size. This ensures that the remaining containers in the container pool have a longer remaining lifespan, avoiding task redeployment or migration due to container lifespan expiration. Alternatively, based on the container status of the containers in the pool, a number of idle containers (with a scaling step size) can be randomly selected. Random selection of idle containers is simpler and more efficient, suitable for scenarios where containers have no lifespan limit or where the container lifespan is long.
[0079] The above is merely an illustrative example, and the embodiments of this application do not limit the specific selection method of the number of idle containers for the scaling-down step size. For example, based on the historical failure rate of the containers, idle containers with a historical failure rate higher than a preset probability threshold can be selected as the number of idle containers for the scaling-down step size. Furthermore, based on the startup time of the containers, idle containers with a startup time higher than a preset time threshold can be selected as the number of idle containers for the scaling-down step size. This embodiment does not impose any limitations on these methods. In this way, based on a relatively rich selection method for idle containers, the number of idle containers for the scaling-down step size that meet the conditions can be selected more accurately from the container pool, thereby allowing the deletion of these idle containers to complete the scaling-down more efficiently.
[0080] Further, optionally, to avoid the continuous decrease in the number of containers in the container pool, the pre-configured scaling rules may also include a lower limit for the number of containers. In this case, during the scaling down of the container pool, it is also necessary to determine whether the total number of containers in the container pool has reached the lower limit for the number of containers. When the lower limit for the number of containers is reached, the scaling down operation is stopped.
[0081] In summary, this declarative scaling approach allows for flexible configuration of scaling conditions and scaling step parameters by operations personnel. This provides them with greater flexibility in scaling the container pool, resulting in stronger and more flexible scaling capabilities. Furthermore, integrating elastic resource instances into the container pool construction and elastic scaling process provides a resource foundation for elastic scaling. This combination addresses the issues of insufficient elasticity and poor flexibility in container pools, significantly improving their elastic scaling capabilities, greatly reducing the likelihood of having too many or too few idle containers, minimizing resource waste, and enhancing user experience.
[0082] Based on the aforementioned embodiments, user tasks can also be deployed in the container pool using the following steps K1-K3:
[0083] Step K1: Upon receiving a user task, query the container pool to see if there are any idle containers. This involves iterating through the states of each container in the pool and determining if there are any idle containers in the pool.
[0084] Step K2: If there are idle containers in the container pool, deploy the user task in the first container among the idle containers, and update the status of the first container from idle to used. The number of first containers can be one or more; this embodiment does not impose a limit. For example, if the user task is a distributed task, there can be multiple first containers.
[0085] This embodiment does not limit the specific method of "determining the first container from the idle containers". In one exemplary embodiment, any container can be randomly selected from the idle containers as the first container; in another exemplary embodiment, the container with the lowest historical failure rate can be selected from the idle containers as the first container; a container whose resource specifications match the task can also be selected from the idle containers as the first container; or the container with the closest network distance to the task can be selected from the idle containers as the first container. This embodiment does not impose any restrictions. In this way, the user task can be deployed in a more suitable first container to process the user task more efficiently.
[0086] Step K3: If no idle containers exist in the container pool, the container creation interface provided by the container cluster is invoked to create a second container on a resource node in the container cluster, and the user task is deployed in the second container. Specifically, the container creation interface provided by the container cluster can be invoked, and the required information can be input into the container creation interface. The required information includes at least the number of containers to be created, and may also include other container parameters, such as container version and container capacity, etc. This embodiment does not impose any restrictions on this. The container creation interface can create a second container on a resource node in the container cluster based on the input required information, and deploy the user task in the second container.
[0087] Through steps K1-K3 above, upon receiving a user task, a container can be selected from existing containers or a new container can be created based on the idle status of containers in the container pool to efficiently deploy the user task, reducing the waiting time after the user triggers the task and improving the efficiency of task startup. It should also be noted that the above task scheduling process is asynchronous with the container pool scaling process; that is, task scheduling is unaware of the container pool scaling process, which helps reduce the interference of container pool scaling on task scheduling and improves task scheduling efficiency.
[0088] It should be noted that the embodiments of this application do not limit the deployment and implementation methods of the container pool scaling method. It can be deployed on a single device or in a distributed manner, for example, by multiple logical nodes or functional nodes working together. The logical nodes or functional nodes are ultimately hosted on physical resource nodes. The form of the physical resource nodes is not limited; they can be various terminal devices such as computers and mobile phones, or various server devices such as conventional servers, cloud servers, and server clusters. The following provides an exemplary description of the distributed deployment method. Therefore, the embodiments of this application also provide a container pool system 20.
[0089] Figure 2 A schematic diagram of the structure of a container pool system 20 provided for an exemplary embodiment of this application is shown below. Figure 2As shown, the container pool system 20 may include: a container pool 201 hosted on elastic resource instances, a server node 202, and a control node 203. The elastic resource instance is obtained by virtualizing resource nodes in a container cluster.
[0090] In this embodiment, see Figure 2 In sections ③-④, control node 203 can be used to: monitor the status and number of containers in container pool 201 during the operation of container pool 201, and report to server node 202. The status and number of containers are dynamic.
[0091] See Figure 2 In section ②, server node 202 can be used to configure the scaling conditions and scaling step parameters of container pool 201. (See also...) Figure 2 In steps ④-⑦, server node 202 can be used to: receive the status and quantity of containers reported by control node 203; if it is determined that container pool 201 meets the expansion conditions based on the status and quantity of containers, determine the expansion step size based on the expansion step parameters, and expand container pool 201 according to the expansion step size; if it is determined that container pool 201 meets the shrinkage conditions based on the status and quantity of containers, determine the shrinkage step size based on the shrinkage step parameters, and shrink container pool 201 according to the shrinkage step size.
[0092] This approach integrates the container pool construction concept based on elastic resource instances and the declarative elastic scaling concept. The combination of the two solves the problems of insufficient elasticity and poor flexibility of container pools, improves the elastic scaling capability of container pools, greatly reduces the situation of too many or too few idle containers, reduces resource waste, and improves user experience.
[0093] In some alternative embodiments, see Figure 2 In step ⑥, when server node 202 expands container pool 201 according to the expansion step size, it can generate an expansion task based on the expansion step size and provide the expansion task to control node 203 for execution. The expansion task may include the expansion step size, which can be used to instruct the expansion of container pool 201 according to the expansion step size. Specifically, when server node 202 provides the expansion task to control node 203, it can directly issue the expansion task to control node 203; alternatively, it can add the expansion task to a task list, which control node 203 can periodically poll to retrieve and execute the expansion task. In this way, server node 202 and control node 203 can cooperate to generate and issue expansion tasks more accurately and promptly, enabling control node 203 to efficiently expand container pool 201 according to the expansion step size.
[0094] In some alternative embodiments, see Figure 2In step ⑥, when server node 202 scales down container pool 201 according to the scaling-down step size, it can generate a scaling-down task based on the scaling-down step size and provide the scaling-down task to control node 203 for execution. The scaling-down task may include the scaling-down step size, which indicates the scaling-down of container pool 201 according to the scaling-down step size. When server node 202 provides the scaling-down task to control node 203, it can directly issue the scaling-down task to control node 203; alternatively, it can add the scaling-down task to a task list, which control node 203 can periodically poll to retrieve and execute the scaling-down task. In this way, server node 202 and control node 203 can cooperate to generate and issue scaling-down tasks more accurately and promptly, enabling control node 203 to efficiently scale down container pool 201 according to the scaling-down step size.
[0095] In some alternative embodiments, such as Figure 2 As shown, the server node 202 may include: a creation module 2021, a configuration module 2022, a decision module 2023, and a task processing module 2024.
[0096] See Figure 2 In section ①, the creation module 2021 can be used to create a container pool 201 on an elastic resource instance. The aforementioned methods for scaling up and down the container pool have been described in detail in the related embodiments and will not be repeated here. See [link to documentation]. Figure 2 In section ②, configuration module 2022 can be used to configure the scaling conditions and scaling step parameters of container pool 201. Configuration module 2022 provides a scaling rule configuration interface for operations and maintenance personnel, who can input scaling conditions and scaling step parameters through this interface. In this way, operations and maintenance personnel can quickly and flexibly configure scaling conditions and scaling step parameters according to application needs, and update the scaling rules of container pool 201 in a timely manner. See also... Figure 2 In section ⑤, the decision module 2023 receives the container status and quantity reported by the control node 203, and determines whether the container pool 201 meets the expansion or reduction conditions based on the container status and quantity. See also... Figure 2 In step ⑥, the task processing module 2024 is used to determine the expansion step size according to the expansion step parameters when the decision module determines that the container pool 201 meets the expansion conditions, and to generate an expansion task and provide it to the control node 203 according to the expansion step size; or, when the decision module determines that the container pool 201 meets the shrinkage conditions, it determines the shrinkage step size according to the shrinkage step parameters, and to generate a shrinkage task and provide it to the control node 203 according to the shrinkage step size.
[0097] In some alternative embodiments, such as Figure 2As shown, the server node 202 also includes a task scheduling module 2025, which can be used to receive user tasks and, upon receiving a user task, query whether there are any idle containers in the container pool 201; if there are idle containers in the container pool 201, the user task is deployed in the first container in the idle container, and the status of the first container is updated from idle to used; if there are no idle containers in the container pool 201, the container creation interface provided by the container cluster 204 is called to create a second container on the resource node in the container cluster 204, and the user task is deployed in the second container.
[0098] In some alternative embodiments, such as Figure 2 As shown, control node 203 may include monitoring module 2031 and task execution module 2032. See also... Figure 2 In section ③, monitoring module 2031 can be used to monitor the status and number of containers in container pool 201 during its operation and report this information to server node 202. See also... Figure 2 In step ⑦, the task execution module 2032 can be used to obtain the expansion task provided by the server node 202, execute the expansion task to expand the container pool 201 according to the expansion step size; or, obtain the shrinking task provided by the server node 202, execute the shrinking task to shrink the container pool 201 according to the shrinking step size.
[0099] In some alternative embodiments, such as Figure 2 As shown, the container pool system 20 also includes a container cluster 204. The container cluster 204 exposes a container creation interface to the server node 202, allowing the server node 202 to call the container creation interface to create containers in the container pool 201. Furthermore, the container cluster 204 is also used to expose a container deletion interface and other container-related command interfaces to the server node 202, allowing the server node 202 to delete containers or issue other commands to containers.
[0100] In this embodiment, the detailed implementation methods and beneficial effects of each step performed by the container pool system have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0101] The following will combine Figure 3 This section explains the deployment methods for scaling up and down container pools in practical application scenarios. For example... Figure 3 As shown, the container pool system includes container pool 1 to container pool n. These container pools are built on elastic resource instances, such as ECI instances. ECI instances are built on Kubernetes clusters. In actual application scenarios, the container pool system also includes server nodes and control nodes.
[0102] The server-side node includes an elastic scaling unit and a task scheduling unit, which can provide the following metadata services: (1) The elastic scaling unit is responsible for persisting metadata such as cluster scaling rules and cluster water level indicators, and dynamically generating scaling or shrinking tasks based on the cluster scaling rules and cluster water level indicators. Among them, the cluster scaling rules may include the scaling conditions and scaling step parameters in the aforementioned embodiments, and the cluster water level indicators may include the upper limit value and lower limit value of the number of containers in the aforementioned embodiments. Further, the elastic scaling unit includes a creation module, a configuration module, a task processing module, and a decision module; (2) The task scheduling unit can be used to process the scheduling of user-triggered tasks, and prioritize matching available containers in the container pool for new user tasks. If the matching fails, it will be downgraded to creating a new container to execute the new user task.
[0103] Among them, the control node deploys a monitoring module and a task execution module for each container pool, which can provide the following services: (1) The monitoring module can collect the status and number of containers in the container pool and upload them to the server node. (2) The task execution module can poll the task processing module to create new containers or delete existing containers.
[0104] The configuration module in the server node can define cluster scaling rules, including scaling conditions, scaling step parameters, lower limit of scaling step size, and upper limit of scaling step size. Based on this, the container pool system can execute the following steps to complete the scaling task relatively efficiently.
[0105] Step 1: The monitoring module monitors the status changes of containers in the container pool. When a container is created, allocated, or released in the container pool, the status and quantity of containers in the container pool are updated synchronously and reported to the decision module in the server node.
[0106] Step 2: The decision module of the server node can calculate whether expansion or contraction is needed based on cache pool metrics, expansion / contraction conditions, and expansion / contraction step parameters. If so, it will trigger the task processing module to generate the corresponding expansion or contraction task.
[0107] Step 3: The task execution module of the control node can pull expansion or reduction tasks from the task processing module and execute them.
[0108] Step 3 can be divided into expansion and reduction scenarios, which will be explained in detail below.
[0109] For expansion details, please refer to [link / reference]. Figure 4As shown: The monitoring module updates the status and quantity of containers in the container pool and reports it to the server node; the server node determines whether expansion is needed; if so, it creates an expansion task; the task execution module can poll the server node to see if it has created a new expansion task, and if so, execute the expansion task, that is, call the container creation interface to create a new container. In this embodiment, calling the container creation interface to create a new container refers to the process of creating a new container based on a container snapshot. Further, it waits for the container to start and enter the ready state; if the container enters the ready state, it is determined that the new container has been successfully created and can directly enter the usage state. At this time, the container's mark can be updated, that is, the container is marked as ready; after all the containers in the same batch of expansion have reached the ready state, the status of the expansion task can be updated to the completed state. As new containers are created, the monitoring module can continue to update the status and quantity of containers and synchronize them to the server node.
[0110] For details on volume reduction, please refer to [link / reference]. Figure 5 As shown: The monitoring module updates the status and quantity of containers in the container pool and reports it to the server node; the server node determines whether scaling down is needed; if so, it creates a scaling down task; the task execution module can poll the server node to see if it has created a new scaling down task. If so, it can select the container with the oldest creation time and call the container creation interface to delete the container. Afterwards, the scaling down task status can be updated to "completed". As containers are deleted, the monitoring module can continue to update the container status and quantity and synchronize them to the server node.
[0111] Further, see Figure 6 As shown, the process also includes a task scheduling process running parallel to the scaling process described above. This process includes: when a user triggers a new task, the task scheduling module first checks if there are any available containers in the container pool. If there are available containers, the user task can be bound to one of them, meaning the user task is executed using that container. Specifically, the available container with the oldest creation time can be selected. If no available containers are available, a rollback can be performed, i.e., the container creation interface is called to create a new container. After obtaining a container, the user task can be deployed within that container, and the task logic can be executed. Furthermore, for containers carrying user tasks, after the user task is completed, the container's marker can be updated, i.e., the container is marked as complete, and it waits for the control node to release resources for that container.
[0112] The detailed implementation methods and beneficial effects of each step in this embodiment have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0113] By exploring the deployment methods of container pool scaling in real-world application scenarios, this paper integrates the container pool construction approach based on elastic resource instances and the declarative elastic scaling approach. The combination of these two approaches solves the problems of insufficient elasticity and poor flexibility of container pools, improves the elastic scaling capability of container pools, greatly reduces the occurrence of situations with too many or too few idle containers, reduces resource waste, and improves user experience.
[0114] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 11 to 13 can be device A; or the execution subject of steps 11 and 12 can be device A, and the execution subject of step 13 can be device B; and so on.
[0115] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 11, 12, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0116] Figure 7 This is a schematic diagram of a container pool scaling device provided as another exemplary embodiment of this application. The container pool is hosted on an elastic resource instance, which is obtained by virtualizing resource nodes in a container cluster. The container pool is configured with scaling conditions and scaling step parameters.
[0117] like Figure 7 As shown, the device includes a monitoring unit 701, an expansion unit 702, and a reduction unit 703. The monitoring unit 701 is used to monitor the state and quantity of containers in the container pool during operation; the state and quantity of containers are dynamically changing. The expansion unit 702 is used to: if the container pool meets the expansion conditions based on the state and quantity of containers, determine the expansion step size based on expansion step parameters, and expand the container pool according to the expansion step size. The reduction unit 703 is used to: if the container pool meets the reduction conditions based on the state and quantity of containers, determine the reduction step size based on reduction step parameters, and reduce the container pool according to the reduction step size.
[0118] Optionally, the expansion condition includes a first container occupancy rate threshold, and the reduction condition includes a second container occupancy rate threshold and a preset duration, wherein the second container occupancy rate threshold is less than the first container occupancy rate threshold; the expansion unit 702 is further configured to: determine the container occupancy rate of the container pool based on the status and quantity of the containers, wherein the container occupancy rate refers to the ratio of the number of containers in use to the total number of containers; if the container occupancy rate is greater than or equal to the first container occupancy rate threshold, determine that the container pool meets the expansion condition.
[0119] Optionally, the shrinkage unit 703 is further configured to: determine the container occupancy rate of the container pool based on the state and quantity of the containers, wherein the container occupancy rate refers to the ratio of the number of containers in use to the total number of containers; and if the container occupancy rate is less than or equal to the second container occupancy rate threshold and continues for the preset duration, determine that the container pool meets the shrinkage condition.
[0120] Optionally, the expansion step parameters include an expansion ratio value and a lower limit value for the expansion step size. When the expansion unit 702 determines the expansion step size based on the expansion step parameters, it is specifically used to: calculate a first basic step size based on the number of containers and the expansion ratio value; and select the larger of the first basic step size and the lower limit value for the expansion step size as the expansion step size.
[0121] Optionally, the shrinkage step parameters include a shrinkage ratio value and a shrinkage step size upper limit value. When the shrinkage unit 703 determines the shrinkage step size according to the shrinkage step parameters, it is specifically used to: calculate a second basic step size based on the number of containers and the shrinkage ratio value; and select the smaller of the second basic step size and the shrinkage step size upper limit value as the shrinkage step size.
[0122] Optionally, when the expansion unit 702 expands the container pool according to the expansion step size, it is specifically used to: obtain a pre-created container snapshot, the container snapshot including a basic container environment and a toolkit installed in the basic container environment, the toolkit including tools required to deploy tasks in the container; and use the container snapshot to create a new container in the container pool for the expansion step size to expand the container pool.
[0123] Optionally, when the expansion unit 702 pre-creates a container snapshot, it is specifically used to: create a base container based on the container's image file, the base container providing a base container environment; install a toolkit in the base container, and create a snapshot of the base container with the toolkit installed, as the container snapshot.
[0124] Optionally, when the shrinking unit 703 shrinks the container pool according to the shrinking step size, it is specifically used to: select the number of idle containers of the shrinking step size from the container pool according to the state of the containers in the container pool; and delete the number of idle containers of the shrinking step size from the container pool to shrink the container pool.
[0125] Optionally, when the shrinking unit 703 selects the shrinking step size of idle containers from the container pool based on the status of the containers in the container pool, it is specifically used to: select the shrinking step size of idle containers with the earliest creation time from the container pool based on the status and creation time of the containers in the container pool; or, randomly select the shrinking step size of idle containers from the container pool based on the status of the containers in the container pool.
[0126] Optionally, the scaling device for the container pool further includes a task scheduling unit 704. Specifically, the task scheduling unit 704 is used to query whether there are any idle containers in the container pool when a user task is received; if there are idle containers in the container pool, the user task is deployed in the first container in the idle container, and the status of the first container is updated from idle to used; if there are no idle containers in the container pool, the container creation interface provided by the container cluster is called to create a second container on the resource node in the container cluster, and the user task is deployed in the second container.
[0127] This approach integrates the container pool construction concept based on elastic resource instances and the declarative elastic scaling concept. The combination of the two solves the problems of insufficient elasticity and poor flexibility of container pools, improves the elastic scaling capability of container pools, greatly reduces the situation of too many or too few idle containers, reduces resource waste, and improves user experience.
[0128] The above describes the internal functions and structure of the expansion and contraction device for the container pool, such as... Figure 8 As shown, in practice, the expansion and contraction device of the container pool can be implemented as an electronic device, including: a memory 801, a processor 802, and a communication component 803.
[0129] Memory 801 is used to store computer programs and can be configured to store various other data to support operation on the computing platform. Examples of this data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc.
[0130] The memory 801 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0131] The processor 802, coupled to the memory 801, is configured to execute a computer program in the memory 801 for: monitoring the state and number of containers in the container pool during operation of the container pool, wherein the state and number of containers are dynamically changing; if the container pool is determined to meet the expansion conditions based on the state and number of containers, determining the expansion step size based on expansion step parameters, and expanding the container pool according to the expansion step size; if the container pool is determined to meet the shrinkage conditions based on the state and number of containers, determining the shrinkage step size based on shrinkage step parameters, and shrinking the container pool according to the shrinkage step size.
[0132] Optionally, the expansion condition includes a first container occupancy threshold, and the reduction condition includes a second container occupancy threshold and a preset duration, wherein the second container occupancy threshold is less than the first container occupancy threshold; the processor 802 is further configured to: determine the container occupancy rate of the container pool based on the state and quantity of the containers, wherein the container occupancy rate refers to the ratio of the number of containers in use to the total number of containers; if the container occupancy rate is greater than or equal to the first container occupancy threshold, determine that the container pool meets the expansion condition; if the container occupancy rate is less than or equal to the second container occupancy threshold and continues for the preset duration, determine that the container pool meets the reduction condition.
[0133] Optionally, the expansion step parameters include an expansion ratio value and a lower limit value for the expansion step size. When the processor 802 determines the expansion step size based on the expansion step parameters, it is specifically used to: calculate a first basic step size based on the number of containers and the expansion ratio value; and select the larger of the first basic step size and the lower limit value for the expansion step size as the expansion step size.
[0134] Optionally, the shrinkage stepping parameters include a shrinkage ratio value and a shrinkage step size upper limit value. When the processor 802 determines the shrinkage step size based on the shrinkage stepping parameters, it is specifically used to: calculate a second basic step size based on the number of containers and the shrinkage ratio value; and select the smaller of the second basic step size and the shrinkage step size upper limit value as the shrinkage step size.
[0135] Optionally, when the processor 802 expands the container pool according to the expansion step size, it is specifically used to: obtain a pre-created container snapshot, the container snapshot including a base container environment and a toolkit installed in the base container environment, the toolkit including tools required to deploy tasks in the container; and use the container snapshot to create a new container in the container pool for the expansion step size to expand the container pool.
[0136] Optionally, when the processor 802 pre-creates a container snapshot, it is specifically used to: create a base container based on the container's image file, the base container providing a base container environment; install a toolkit in the base container, and create a snapshot of the base container with the toolkit installed, as the container snapshot.
[0137] Optionally, when the processor 802 shrinks the container pool according to the shrinking step size, it is specifically used to: select the number of idle containers of the shrinking step size from the container pool according to the state of the containers in the container pool; and delete the number of idle containers of the shrinking step size from the container pool to shrink the container pool.
[0138] Optionally, when the processor 802 selects the number of idle containers for the shrinkage step size from the container pool based on the status of the containers in the container pool, it is specifically used to: select the number of idle containers for the shrinkage step size with the earliest creation time from the container pool based on the status and creation time of the containers in the container pool; or, randomly select the number of idle containers for the shrinkage step size from the container pool based on the status of the containers in the container pool.
[0139] Optionally, the processor 802 is further configured to, upon receiving a user task, query whether there is an idle container in the container pool; if there is an idle container in the container pool, deploy the user task in the first container in the idle container and update the status of the first container from idle to used; if there is no idle container in the container pool, call the container creation interface provided by the container cluster to create a second container on the resource node in the container cluster, and deploy the user task in the second container.
[0140] Furthermore, such as Figure 8 As shown, the electronic device also includes other components such as a display 804, a power supply component 805, and an audio component 806. Figure 8 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 8 The components shown. Additionally... Figure 8The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the work node. In this embodiment, the work node can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT device, or a server-side device such as a conventional server, cloud server, or server array. If the work node in this embodiment is implemented as a terminal device such as a desktop computer, laptop computer, or smartphone, it may include... Figure 8 The components within the dashed box; if the working node in this embodiment is implemented as a server-side device such as a conventional server, cloud server, or server array, it may be omitted. Figure 8 The component within the dashed box.
[0141] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be performed by an electronic device in the above method embodiments.
[0142] Accordingly, this application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, enables the processor to perform the steps that can be executed by an electronic device in the above method embodiments.
[0143] In the above embodiments of this application, the container pool construction idea based on elastic resource instances and the declarative elastic scaling idea are combined. The combination of the two solves the problems of insufficient elasticity and poor flexibility of the container pool, improves the elastic scaling capability of the container pool, greatly reduces the situation of too many or too few idle containers, reduces resource waste, and improves user experience.
[0144] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0145] The aforementioned communication components are configured to facilitate wired or wireless communication between the device containing the communication components and other devices. The device containing the communication components can access wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication components receive broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication components also include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.
[0146] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0147] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.
[0148] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0149] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) containing computer-usable program code.
[0150] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0151] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0152] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0153] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.
[0154] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0155] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0156] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0157] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for expanding or shrinking a container pool, characterized in that, The container pool is hosted on elastic resource instances, which are obtained by virtualizing resource nodes in a container cluster. The container pool is configured with scaling conditions and scaling step parameters. The method includes: During the operation of the container pool, the status and number of containers in the container pool are monitored, and the status and number of containers are dynamically changing; If the container pool meets the expansion conditions based on the state and quantity of the containers, the expansion step size is determined based on the expansion step parameters, and the container pool is expanded according to the expansion step size; If the container pool meets the reduction conditions based on the state and quantity of the containers, the reduction step size is determined according to the reduction step parameters, and the container pool is reduced according to the reduction step size.
2. The method according to claim 1, characterized in that, The expansion conditions include a first container occupancy threshold, and the reduction conditions include a second container occupancy threshold and a preset duration, wherein the second container occupancy threshold is less than the first container occupancy threshold; the method further includes: The container occupancy rate of the container pool is determined based on the status and quantity of the containers. The container occupancy rate is the ratio of the number of containers in use to the total number of containers. If the container occupancy rate is greater than or equal to the first container occupancy rate threshold, it is determined that the container pool meets the expansion condition. If the container occupancy rate is less than or equal to the second container occupancy rate threshold and continues for the preset duration, it is determined that the container pool meets the shrinkage condition.
3. The method according to claim 1, characterized in that, The expansion step parameters include: expansion ratio and expansion step size lower limit. The expansion step size is determined based on these parameters, including: Calculate the first base step size based on the number of containers and the expansion ratio; The larger of the first base step size and the lower limit of the expansion step size is selected as the expansion step size.
4. The method according to claim 1, characterized in that, The reduction step parameters include: a reduction ratio value and an upper limit value for the reduction step size. The reduction step size is then determined based on these parameters, including: Calculate the second base step size based on the number of containers and the reduction ratio; The smaller of the second base step size and the upper limit of the shrinkage step size shall be selected as the shrinkage step size.
5. The method according to any one of claims 1-4, characterized in that, Expanding the container pool according to the expansion step size includes: Obtain a pre-created container snapshot, which includes a base container environment and a toolkit installed in the base container environment, the toolkit including the tools required to deploy tasks in the container; The container pool is expanded by creating the expansion step of the new container using the container snapshot.
6. The method according to claim 5, characterized in that, Pre-create container snapshots, including: A base container is created from the container image file, and the base container provides a basic container environment; Install the toolkit in the base container and create a snapshot of the base container where the toolkit is installed, as the container snapshot.
7. The method according to any one of claims 1-4, characterized in that, The container pool is reduced in size according to the reduction step size, including: Based on the state of the containers in the container pool, select the number of idle containers with the shrinkage step size from the container pool; The number of empty containers with the shrinking step size is removed from the container pool to shrink the container pool.
8. The method according to claim 7, characterized in that, Based on the state of the containers in the container pool, select the number of idle containers for the shrinkage step from the container pool, including: Based on the status and creation time of the containers in the container pool, select the number of idle containers with the earliest creation time from the container pool, which is the number of shrinkage steps; or, based on the status of the containers in the container pool, randomly select the number of idle containers with the number of shrinkage steps from the container pool.
9. The method according to any one of claims 1-4, characterized in that, Also includes: Upon receiving a user task, query the container pool to see if there are any idle containers. If there are idle containers in the container pool, the user task is deployed in the first container in the idle container, and the status of the first container is updated from idle to used. If there are no idle containers in the container pool, the container creation interface provided by the container cluster is called to create a second container on the resource node in the container cluster, and the user task is deployed in the second container.
10. A container pool system, characterized in that, include: The container pool, server nodes, and control nodes are hosted on elastic resource instances; wherein, the elastic resource instance is obtained by virtualizing resource nodes in a container cluster. The control node is used to monitor the status and number of containers in the container pool during the operation of the container pool, and report to the server node. The status and number of containers are dynamically changing. The server node is used to configure the scaling conditions and scaling step parameters of the container pool, and to receive the status and quantity of the containers reported by the control node. If the container pool meets the scaling conditions based on the status and quantity of the containers, the server node determines the scaling step size based on the scaling step parameters and scales the container pool accordingly. If the container pool meets the scaling conditions based on the status and quantity of the containers, the server node determines the scaling step size based on the scaling step parameters and scales the container pool accordingly.
11. The system according to claim 10, characterized in that, The server node expands the container pool according to the expansion step size, including: generating an expansion task according to the expansion step size, providing the expansion task to the control node for the control node to execute the expansion task, wherein the expansion task indicates that the container pool is expanded according to the expansion step size; The server node shrinks the container pool according to the shrinking step size, including: generating a shrinking task according to the shrinking step size, providing the shrinking task to the control node for the control node to execute the shrinking task, wherein the shrinking task indicates to shrink the container pool according to the shrinking step size.
12. The system according to claim 11, characterized in that, The server-side nodes include: Create a module for creating the container pool on the elastic resource instance; The configuration module is used to configure the scaling conditions and scaling step parameters of the container pool; The decision module is used to receive the status and quantity of the containers reported by the control node, and determine whether the container pool meets the expansion or reduction conditions based on the status and quantity of the containers. The task processing module is used to determine the expansion step size according to the expansion step parameters when the decision module determines that the container pool meets the expansion conditions, and to generate an expansion task and provide it to the control node according to the expansion step size; or, when the decision module determines that the container pool meets the shrinkage conditions, to determine the shrinkage step size according to the shrinkage step parameters, and to generate a shrinkage task and provide it to the control node according to the shrinkage step size.
13. The system according to claim 12, characterized in that, The server node also includes: The task scheduling module is used to receive user tasks and, upon receiving a user task, query whether there are any idle containers in the container pool. If there are idle containers in the container pool, the user task is deployed in the first container among the idle containers, and the status of the first container is updated from idle to used. If there are no idle containers in the container pool, the container creation interface provided by the container cluster is called to create a second container on the resource node in the container cluster, and the user task is deployed in the second container.
14. The system according to claim 11, characterized in that, The control node includes: The monitoring module is used to monitor the status and number of containers in the container pool during the operation of the container pool, and report to the server node. The task execution module is used to obtain the expansion task provided by the server node, execute the expansion task to expand the container pool according to the expansion step size; or, obtain the shrinking task provided by the server node, execute the shrinking task to shrink the container pool according to the shrinking step size.
15. The system according to any one of claims 11-14, characterized in that, Also includes: The container cluster exposes a container creation interface to the server node, allowing the server node to call the container creation interface to create containers in the container pool.
16. An electronic device, characterized in that, include: Memory and processor; The memory is used to store a computer program, and the processor is coupled to the memory to execute the computer program for implementing the steps of the method according to any one of claims 1-9.
17. A computer-readable storage medium, characterized in that, Includes a computer program / instruction that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-9.
18. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-9.