Lifecycle Management of Containers, Function Computing Method, Device and Storage Medium
By monitoring and sorting the popularity of containers in real time, the probability of hot start is extended, and the problem of container startup delay in the prior art is solved, and the function execution efficiency and user experience are improved.
Patent Information
- Application Number
- CN202210096155.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-26
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-01-26
AI Technical Summary
The existing container lifecycle management solution is rigid, resulting in the execution of function logic that needs to wait for the container to start, resulting in startup delays and affecting execution efficiency, especially in high concurrency situations.
By monitoring the startup containers on the target host, calculating their heat in real time, and maintaining containers in real time based on the heat in use, selecting target containers that meet preset requirements for residency management to extend the probability of hot start and reduce cold start.
It effectively improves the execution efficiency of the function, reduces the delay of cold start, and improves the user experience in high concurrency situations.
Smart Images

Figure CN114489947B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and particularly to the life cycle management of containers, function computing methods, devices, and storage media. Background Art
[0002] FaaS (Function-as-a-Service) provides developers with a convenient way to execute the function logic they write. In this way, developers only need to focus on the implementation of their logic, and other tasks such as cluster management, resource configuration, and virtualization technology are all the responsibility of the cloud provider.
[0003] Although FaaS can provide a convenient way for users, since the execution of function logic depends on container support, and the current container life cycle management solution is relatively inflexible, therefore, the execution of function logic often needs to wait for the container to start. In this way, the startup latency of the container will damage the execution efficiency of the function logic, especially in the case of high concurrency, seriously affecting the user experience. Summary of the Invention
[0004] Multiple aspects of this application provide a container life cycle management, function computing method, device, and storage medium to improve the execution efficiency of functions that rely on containers.
[0005] An embodiment of this application provides a container life cycle management method, including:
[0006] Monitoring the started containers on the target host;
[0007] Sorting the started containers on the target host according to the usage heat corresponding to each of the started containers on the target host;
[0008] Selecting a target container from the started containers according to the sorting result, where the sorting position of the target container meets a preset requirement;
[0009] Controlling the target container and the function logic data associated with the target container to remain resident.
[0010] An embodiment of this application also provides a function computing method, including:
[0011] Receiving a function trigger request for a target function;
[0012] If the target function is scheduled to a specified container that has been started on the target host, moving forward the sorting position of the specified container among all the containers that have been started on the target host to extend the residence time of the specified container;
[0013] Based on the function logic data corresponding to the target function, execute the target function by using the specified container, and the function logic data corresponding to the target function is pre-retained on the target host. An embodiment of the present application further provides a routing device, including a memory, a processor, and a communication component;
[0014] The memory is used to store one or more computer instructions;
[0015] The processor is coupled to the memory and the communication component, and is used to execute the one or more computer instructions for:
[0016] Monitor the started containers on the target host through the communication component;
[0017] Sort the started containers on the target host according to the usage heat corresponding to each of the started containers on the target host;
[0018] Select a target container from the started containers according to the sorting result, and the sorting position of the target container meets the preset requirements;
[0019] Control the target container and the function logic data associated with the target container to remain resident.
[0020] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, and when the computer instructions are executed by one or more processors, the one or more processors are caused to execute the foregoing method for managing the life cycle of a container.
[0021] In the embodiment of the present application, the started containers on the target host can be monitored; the usage heat of each started container can be calculated in real time; and according to the usage heat, the sorting among the started containers on the target host can be maintained in real time; based on the sorting among the started containers, control the target container whose sorting position meets the preset requirements to remain resident until the target container no longer meets the preset requirements due to the change of the sorting position. In this way, the life cycle of the container no longer rigidly follows a fixed threshold duration, but can, according to the idea of caching, control the containers that are more likely to be used and their associated function logic data to remain resident for a longer time, thereby effectively increasing the probability of executing functions by using the warm start method and reducing or even avoiding cold start; the delay of warm start is much lower than that of cold start. Therefore, overall, the execution efficiency of the function can be effectively improved. Description of the Drawings
[0022] The drawings described herein are used to provide a further understanding of the present application, form a part of the present application, and the schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0023] Figure 1A flowchart of a method for managing the life cycle of a container provided by an exemplary embodiment of the present application;
[0024] Figure 2 A logical diagram of a container life cycle management solution provided by an exemplary embodiment of the present application;
[0025] Figure 3 A schematic diagram of an exemplary container queue provided by an embodiment of the present application;
[0026] Figure 4 A logical diagram of a prefetching scheme provided by an exemplary embodiment of the present application;
[0027] Figure 5 A flowchart of a function calculation method provided by another exemplary embodiment of the present application;
[0028] Figure 6 A schematic diagram of the structure of a routing device provided by still another exemplary embodiment of the present application. Detailed implementation manners
[0029] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. Apparently, the described embodiments are only a part rather than all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0030] Currently, the container life cycle management solution is relatively inflexible. Therefore, the execution of function logic often needs to wait for the container to start, resulting in a large amount of cold start delay, which seriously damages the execution efficiency of the function logic. To improve these technical problems, in some embodiments of the present application: the started containers on the target host can be monitored; the usage heat of each started container can be calculated in real time; and the sorting among the started containers on the target host can be maintained in real time according to the usage heat; based on the sorting among the started containers, the target container whose sorting position meets the preset requirements is controlled to stay resident until the target container no longer meets the preset requirements due to the change of the sorting position. In this way, the life cycle of the container no longer rigidly follows a fixed threshold duration, but can, according to the idea of caching, control the more likely to be used containers and their associated function logic data to stay resident for a longer time, thereby effectively increasing the probability of executing the function in the way of warm start and reducing or even avoiding cold start; the delay of warm start is much lower than that of cold start. Therefore, overall, the execution efficiency of the function can be effectively improved.
[0031] The following details the technical solutions provided by each embodiment of the present application in conjunction with the drawings.
[0032] Figure 1 The flowchart shows a method for managing the life cycle of a container provided by an exemplary embodiment of the present application. The method for managing the life cycle of the container provided in this embodiment can be executed by a management and control device, which can be implemented as software or a combination of software and hardware, and the management and control device can be integrally provided in a routing device. As Figure 1 shown, the method for managing the life cycle of the container may include:
[0033] Step 100: Monitor the started containers on the target host;
[0034] Step 101: Sort the started containers on the target host according to the usage popularity corresponding to each of the started containers on the target host;
[0035] Step 102: Select a target container from the started containers according to the sorting result, and the sorting position of the target container meets a preset requirement;
[0036] Step 103: Control the target container and the function logic data associated with the target container to remain resident.
[0037] The method for managing the life cycle of the container provided in this embodiment can be applied to the FaaS scenario to more reasonably manage and control the containers in the FaaS scenario for more efficient function calculation. FaaS is an abbreviation for Functions as a Service, which can be generally understood as functional serviceification or can be interpreted as function calculation serviceification. When using FaaS, only the function code logic needs to be concerned, and there is no need to concern about server resources. It can be said that FaaS provides a more refined and abstract serviceification ability. The execution subject of the method provided in this embodiment can be a routing device in the FaaS architecture. Of course, the execution subject in this embodiment is not limited to this. For example, the execution subject can also be other devices, management and control nodes, or newly added nodes in the FaaS architecture, etc.
[0038] Figure 2 The logical diagram shows a solution for managing the life cycle of a container provided by an exemplary embodiment of the present application. Referring to Figure 2 it can be seen that the routing device can communicate with multiple hosts (hosts) and manage and control the containers on the multiple hosts. It should be understood that the solution for managing the life cycle of the container provided in this embodiment mainly involves Figure 2 the routing device and the multiple hosts in Figure 2 Therefore, other components, nodes, and other members in the FaaS architecture are not shown in Figure 2The routing device in it can also be replaced by other control devices, and any device that can be used to manage the containers on each associated host is acceptable.
[0039] For ease of description, in this embodiment, the routing device will be used as an exemplary execution entity, and taking the target host among the multiple hosts it communicates with as an example, the technical solution will be described. It should be understood that the target host can be any one of the multiple hosts that the routing device communicates with. In addition, in this embodiment, the implementation form of the host can be a cloud server, a virtual machine, etc., and this embodiment does not limit this. The function logic data written by the user can be executed by the container, and the container will be associated with the function logic data it has executed. In this embodiment, the container and the function logic data it has executed can be bound together, resident synchronously, and released synchronously. Among them, the function logic data can be provided by the user. For example, it can be function code. For example, an enterprise user can instruct its developers to write function code for querying the weather and store the function code in an external storage component such as a cloud disk. The container can run the function code to execute the "query weather" function.
[0040] Based on this, refer to Figure 1 and Figure 2 , in step 100, the started containers on the target host can be monitored. Among them, the started container refers to a container that has been mapped to actual physical resources. However, it should be understood that the started container may already be loaded with a function, or may not be loaded with any function, that is, the started container may be in a working state or in an idle state, and this embodiment places no restrictions on the state of the started container. There may be one or more started containers on the target host.
[0041] In step 101, the started containers on the target host can be sorted according to the usage heat corresponding to each of the started containers. In this embodiment, the usage heat of each started container can be determined respectively: the usage heat can be calculated according to the request frequency of each started container, and the usage heat is proportional to the request frequency. For this purpose, in this embodiment, the historical request times of each started container can be recorded to count its request frequency. Among them, as time changes, the started containers on the target host will change, and the usage heat of the started containers will also change. In this embodiment, the usage heat of the started containers on the target host can be determined periodically or triggered by a function mentioned later to maintain the real-time nature of the usage heat. Based on this, the started containers on the target host can be sorted according to the usage heat. It should be noted that in this embodiment, the usage heat is only one of the bases for sorting the started containers on the target host. Without considering other sorting bases, in this embodiment, it is considered that the higher the usage heat of a started container, the more likely it will be used again later. Therefore, by sorting the started containers on the target host, it can be reflected which started containers are more likely to be used again later.
[0042] On this basis, in step 102, the target container can be selected from the started containers according to the sorting result, and the sorting position of the target container meets the preset requirements. Among them, as time changes, the started containers on the target host will change, and the sorting among the started containers will also change. In this embodiment, the sorting among the started containers can be continuously updated over time. An exemplary sorting scheme can be: the higher the possibility of being used again later, the more forward the sorting position. Of course, this is only exemplary, and this embodiment is not limited to this.
[0043] Based on the sorting results among the started containers, in step 102, it is possible to determine which started containers need to be kept resident and which started containers need to be released according to preset requirements. And in step 103, control the target container and the function logic data associated with the target container to be kept resident until the target container no longer meets the preset requirements due to changes in the sorting position. Among them, the preset requirements can be set according to actual needs, and the set preset requirements can enable the containers that are more likely to be reused to stay resident for a longer time. With the iterative update of the started containers and the iterative update of the sorting among the started containers, the started containers that are more likely to be reused subsequently will be continuously kept resident. That is to say, the resident time of such started containers will be longer, and the functions associated with such started containers are usually those with high request frequencies. This forms a virtuous cycle. After receiving a function trigger request, there is a higher probability that the target container resident on the target host can be used to execute the corresponding function, and there is no need to start a new container. Moreover, the function logic data associated with the resident target container is also synchronously retained. Therefore, there is no need to remotely download the function logic data either. This makes the execution of the function have almost no delay and the efficiency is very high.
[0044] In this embodiment, the start types of containers can be divided into at least three types:
[0045] One is hot start. If there is a container on the host that can load the target function and the relevant function logic data has been retained, then only need to allocate the function trigger request to the corresponding container. This method is called hot start, and the delay of the hot start method is very small.
[0046] One is cold start. If there is no container on the host that can load the target function and no relevant function logic data has been retained, then it is necessary to download the relevant function logic data and start a new container. This method is called cold start, and the delay of the cold start method is very large, which can reach the second level or even the minute level. A complete cold start process can include but is not limited to the function logic data preparation time, the running environment initialization time, and the container start time, etc.
[0047] There is also a semi-cold start. If there is no container on the host that can load the target function, but the relevant function logic data has been retained, then only need to start a new container for the target function. Compared with cold start, it can save the time for downloading the relevant function logic. This method is called semi-cold start, and the delay of the semi-cold start method is smaller than that of the cold start method, but still larger than that of the hot start method.
[0048] In this embodiment, it is also possible to control the release of the containers whose sorting positions in the started containers do not meet the preset requirements; it is also possible to delete the function logic data associated with the released containers to save the computing resources and storage resources on the target host.
[0049] In this way, in this embodiment, the started containers on the target host can be monitored; the usage heat of each started container can be calculated in real time; and based on the usage heat, the sorting among the started containers on the target host can be maintained in real time. Based on the sorting among the started containers, the target container whose sorting position meets the preset requirements is controlled to remain resident until the target container no longer meets the preset requirements due to the change of the sorting position. In this way, the life cycle of the container no longer rigidly follows a fixed threshold duration, but can, in accordance with the idea of caching, control the containers that are more likely to be used and their associated function logic data to remain resident for a longer time, thereby effectively increasing the probability of executing functions using the warm start method and reducing or even avoiding cold starts. The latency of warm start is much lower than that of cold start. Therefore, overall, the execution efficiency of the function can be effectively improved.
[0050] In the above or following embodiments, the basis for sorting the started containers on the target host may include, but is not limited to, startup latency, the specification of the occupied memory, or historical residence time, etc. These bases jointly affect the sorting among the started containers. For this reason, in this embodiment, the startup latency, the specification of the occupied memory, and / or the historical residence time can also be determined for each started container respectively. Among them, the startup latency may refer to the duration required for a started container to start. The specification of the occupied memory may refer to the size of the memory space configured for the started container. The sizes of the memory spaces configured for different started containers may be different, which can be determined by the user. For example, the user can specify the required memory space size in the function creation instruction, and the container for this function will be configured according to the specified memory space size when created. The historical residence time may refer to the duration for which the container has been resident.
[0051] Based on this, in this embodiment, the started containers on the target host can be sorted based on these sorting bases.
[0052] In this embodiment, multiple implementation methods can be adopted to perform the sorting operation.
[0053] In one implementation method, the respective priorities corresponding to the started containers on the target host can be calculated; and the started containers on the target host can be sorted according to the priorities. Among them, the priority is directly proportional to the usage heat; the priority is directly proportional to the startup latency; the priority is inversely proportional to the specification of the occupied memory; the priority is directly proportional to the historical residence time.
[0054] Considering the above multiple sorting bases, in this embodiment, the calculation process of the priority of the started container can be characterized as:
[0055]
[0056] Among them, Priority represents the priority, Freq represents the usage heat (Frequency), Cost represents the startup latency (StartUpLatency), Size represents the memory size specification (MemorySize), and TTL represents the historical residence time (Time-To-Live).
[0057] In this way, the started containers on the target host will obtain a dynamically changing priority, and based on the dynamically changing priority, the sorting among the started containers will also change dynamically. An exemplary sorting method can be that the higher the priority of a started container, the more forward its sorting position.
[0058] It should be understood that in the above implementation method, the priority is used to characterize the possibility of a started container being reused later. However, this embodiment is not limited to this, and other implementation methods can also be used to perform the sorting operation. For example, according to the aforementioned multiple sorting bases, a machine learning model is used to predict the probability of a started container being reused again, and the sorting is performed according to this probability, etc.
[0059] Accordingly, in this embodiment, the sorting among the started containers on the target host can be dynamically maintained according to various sorting bases, so that the possibility of a started container being reused later can be accurately perceived, and thus a reliable basis can be provided for the life cycle management of the container.
[0060] In the above or following embodiments, multiple implementation methods can be used to determine the target containers that can be kept resident among the started containers.
[0061] In one implementation method, a container portrait can be constructed for each started container respectively; a container queue is maintained for the target host; according to the sorting result of sorting the started containers on the target host, the sorting position of the container portrait of each started container in the container queue is determined; from the container queue, the started containers corresponding to the container portraits whose sorting positions meet the preset requirements are selected as the target containers.
[0062] Among them, the container portrait can be used to abstractly represent a container. The container portrait can include but is not limited to metadata information such as the ID of the container, the memory size specification it occupies, the file size of the function logic data it executes, the execution time and creation time of the executed function, etc.
[0063] Figure 3 This is a schematic diagram of an exemplary container queue provided for the embodiments of the present application. Refer to Figure 3 , the routing device can be associated with multiple hosts EE-1 to EE-5, and a container queue is maintained for each host respectively. The specification of the container queue in this embodiment is not limited, and moreover, different hosts can correspond to different container queue specifications. The sorting position of the container portraits in the container queue can change dynamically.
[0064] Continuing with the method described in the above embodiments for characterizing the likelihood of a container being reused later by means of priority, in combination with Figure 3 , the container images of the containers that have been started on the target host can be sequentially placed into the container queue corresponding to the target host in descending order of priority.
[0065] In this implementation, the aforementioned preset requirements related to the sorting position can be set based on the specifications of the container queue. An exemplary preset requirement can be that the container image is within the container queue. Based on this, in this implementation, the started container corresponding to the container image within the container queue can be determined as the target container; control the target container to remain resident until the target container is squeezed out of the container queue due to a change in the sorting position. Referring to Figure 3 , if the container queue of host EE-1 is full and a started container is squeezed out of the container queue due to too low a priority, then the redundant started container will be released, while the other started containers within the container queue will be retained. And if a new container is started on host EE-1 and the priority of the new started container is higher than the priority of the started container at the end of the current container queue, then the started container at the end of the current container queue will be squeezed out of the container queue and released.
[0066] Of course, in this implementation, other preset requirements can also be adopted. For example, the preset requirement can be that the container image is in the first half of the container queue, or the container image is in the first 60% position of the container queue, etc. The preset requirements are not limited to this.
[0067] In addition, in this embodiment, other implementation methods can also be adopted to determine the target containers that can be kept resident among the started containers, and are not limited to the above container queue method. For example, a table or other dynamically recordable carriers can be used to maintain the sorting among the started containers, etc.
[0068] Accordingly, in this embodiment, methods such as container queues can be used to dynamically maintain the sorting among the started containers on the target host, and the preset requirements can be conveniently set as needed to determine which started containers can be kept resident and which started containers can be released, making the life cycle management of containers more reasonable.
[0069] In the above or following embodiments, a function trigger instruction for the target function can also be received; if the target function is scheduled to a specified container in the target container on the target host, then move the sorting position of the specified container forward; based on the retained function logic data associated with the target container, use the specified container to execute the target function. The function trigger instruction is used to indicate the start of the execution of the target function.
[0070] In this embodiment, the routing device can be used to schedule function trigger instructions. For example, the routing device can schedule function trigger instructions from the perspective of containers: the routing device can configure the location information of a specified container into the function trigger instruction, so as to schedule the function trigger instruction to the specified container, where the location information may include but is not limited to the address of the host where the container is located, etc. Of course, this is the scheduling scheme when there is a container that can load the target function; in the case where there is no container that can load the target function, the routing device can schedule the function trigger instruction to a specified host, and the specified host can create a new container for the target function. An exemplary scheduling principle for the target function can be: give priority to scheduling to the resident container; give priority to scheduling to the container that loaded the target function last time.
[0071] In this embodiment, if the target function is scheduled to a specified container in the target container on the target host, the function logic data corresponding to the target function can be run by the specified container to execute the target function. Among them, according to the above-mentioned exemplary scheduling principle, the function logic data corresponding to the target function has probably been retained on the target host. Therefore, the target host can use the specified container to execute the target function based on the retained function logic data corresponding to the target function.
[0072] Since the number of requests for the specified container has increased, the sorting position of the specified container can be moved forward. Of course, if the number of requests for other started containers also changes, it is still necessary to overall consider all the started containers on the target host to determine their sorting.
[0073] In this embodiment, in addition to initiating function trigger instructions, users may also initiate create / update instructions. Among them, the create instruction is used to indicate creating a function, and the update instruction is used to indicate updating a function. Currently, both of these instructions are for preparing for function execution, and only when the user subsequently initiates a function trigger instruction, will the corresponding function be actually executed.
[0074] In this embodiment, the create / update instruction is innovatively used. Specifically: in the case of a create / update instruction for a target function initiated by a target user, if the create / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the target user meets the specified conditions, control the target host to pre-obtain the function logic data corresponding to the target function and retain it on the target host. That is, in the case where the target user initiates an innovation / update instruction for the target function and the target user meets the specified conditions, it can be considered that there will be an execution requirement for the target function, and through prefetch technology, the function logic data corresponding to the target function can be downloaded to the target host in advance for standby.
[0075] Here, the prefetch operation is restricted by specifying conditions. For example, the specified condition can be that the possibility of the user initiating a function trigger instruction subsequently meets the specified standard. For this purpose, in an exemplary solution, the time difference between the target user initiating a create / update instruction for the same function and initiating a function trigger instruction can be statistically calculated based on the historical behavior record of the target user to characterize the possibility of the user initiating a function trigger instruction subsequently. In this way, only when the time difference is less than the specified standard is it determined that the target user meets the specified condition. In this case, the operation of prefetching the function logic data corresponding to the target function is performed.
[0076] Figure 4 It is a logical schematic diagram of a prefetch solution provided by an exemplary embodiment of the present application. Refer to Figure 4 , the create / update instruction initiated by the target user for the target function can first reach the API server in the FaaS corresponding cluster. The API server can respond to the create / update instruction according to the conventional solution, and this part of the existing solution will not be elaborated further. The innovation in this embodiment lies in controlling the API server to notify the create / update instruction to the routing device. In this way, the routing device can learn that the target user has initiated a create / update instruction for the target function and can select the host to which the target function is scheduled, such as the target host. If there is no container on the target host that can load the target function and the target user meets the specified condition, the target host can be controlled to perform a prefetch operation for the target function and retain the function logic data corresponding to the target function. Of course, the routing device can also learn the create / update instruction initiated by the target user for the target function from other channels, and this embodiment is not limited to this. In this way, when it is obtained that the target user has initiated a create / update instruction for the target function and the target user meets the specified condition, the function logic data corresponding to the target function can be prepared in advance.
[0077] Based on this, in this embodiment, when a function trigger instruction for the target function is received, the target host can be controlled to create a container for the target function; based on the function logic data corresponding to the target function pre-obtained on the target host, the target function can be executed using the container created for the target function. That is, after the above prefetch operation is completed, once a function trigger instruction for the target function is received subsequently, only a new container needs to be started, and there is no need to remotely download the corresponding function logic data. Thus, the target function can be executed in the semi-cold start manner described above, which can save a large amount of latency compared to the cold start manner.
[0078] Refer to Figure 4, in an exemplary prefetching scheme: the target host and other hosts in the cluster can be in a peer-to-peer network. Based on this, the target host can be controlled to preferentially obtain the function logic data corresponding to the target function from other hosts in the peer-to-peer network. That is, in a P2P manner, the target host can be controlled to preferentially prefetch the function logic data corresponding to the target function from other hosts in the peer-to-peer network. Of course, if the function logic data corresponding to the target function does not exist in the peer-to-peer network, the target host can prefetch the function logic data corresponding to the target function from the source (external storage components such as a cloud disk).
[0079] Accordingly, in this embodiment, the function logic data corresponding to the functions that may be executed recently can be pre-obtained by prefetching. In this way, once these functions are triggered subsequently, the functions can be executed in a semi-cold start manner, thereby avoiding the cold start manner with a longer delay. Combining with the scheme described in the foregoing embodiment, the probability of using the hot start manner to execute the function can be increased. And even if the hot start manner cannot be used to execute the function, the probability of using the semi-cold start manner to execute the function can also be increased, while minimizing or even avoiding using the cold start manner to execute the function. Therefore, the execution efficiency of the function can be effectively improved.
[0080] It should be noted that the execution subject of each step of the method provided in the foregoing embodiment can be the same device, or the method can also be executed by different devices as the execution subject. In addition, in some processes described in the foregoing embodiment and the accompanying drawings, a plurality of operations appear in a specific order. However, it should be clearly understood that these operations can be executed not in the order in which they appear in this article or in parallel. The operation numbers such as 100, 101, etc. are only used to distinguish different operations, and the numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and these operations can be executed in sequence or in parallel.
[0081] Figure 5 is a schematic flowchart of a function computing method provided in another exemplary embodiment of the present application. Refer to Figure 5 , the method may include:
[0082] Step 500, receiving a function trigger request for a target function;
[0083] Step 501, if the target function is scheduled to a specified container that has been started on the target host, move forward the sorting position of the specified container among all the containers that have been started on the target host to extend the residence time of the specified container;
[0084] Step 502, based on the function logic data corresponding to the target function, use the specified container to execute the target function, and the function logic data corresponding to the target function is pre-retained on the target host.
[0085] The function calculation method provided in this embodiment can be applied to the FaaS scenario to improve the function execution efficiency in the FaaS scenario.
[0086] In this embodiment, the routing device can be used to schedule function trigger instructions. For example, the routing device can schedule function trigger instructions from the perspective of containers: the routing device can configure the location information of a specified container into the function trigger instruction, so as to schedule the function trigger instruction to the specified container, where the location information may include but is not limited to the address of the host where the container is located, etc. Of course, this is the scheduling scheme in the case where there is a container that can load the target function; in the case where there is no container that can load the target function, the routing device can schedule the function trigger instruction to a specified host, and the specified host can create a new container for the target function. An exemplary scheduling principle for the target function can be: give priority to scheduling to the started container; give priority to scheduling to the container that loaded the target function last time.
[0087] In this embodiment, the started containers on the host can be bound to the function logic data corresponding to the target function that has been created / updated. Based on this, if the target function is scheduled to a specified container on the target host, the specified container can run the function logic data corresponding to the target function to execute the target function; moreover, according to the above-mentioned exemplary scheduling principle, the function logic data corresponding to the target function has probably been retained on the target host. Therefore, the target host can use the specified container to execute the target function based on the retained function logic data corresponding to the target function.
[0088] Since the number of requests for the specified container has increased, the sorting position of the specified container can be moved forward. Of course, if the number of requests for other started containers also changes, it is still necessary to overall consider all the started containers on the target host to determine their sorting. In this embodiment, the residence time of the specified container can be determined according to the sorting position of the specified container. That is, the sorting result among the started containers can be used as the basis for determining the residence time that each started container can obtain. The started container with a higher sorting position will obtain more residence time.
[0089] In an optional implementation solution, the solution provided in the embodiment of the foregoing container lifecycle management method can be used to determine the sorting position and residence time of the specified container. To avoid repetition, the technical details will not be elaborated here.
[0090] In this embodiment, other implementation solutions can also be used to determine the sorting position and residence time of the specified container. Each time it is accessed, the sorting position is incremented by 1, and the residence time is synchronously delayed by 1 minute, etc.
[0091] In this embodiment, in addition to initiating a function trigger instruction, the user may also initiate a creation / update instruction. Among them, the creation instruction is used to indicate the creation of a function, and the update instruction is used to indicate the update of a function. Currently, both of these instructions are for preparing for function execution. Only when the user subsequently initiates a function trigger instruction will the corresponding function be actually executed.
[0092] In this embodiment, the creation / update instruction is innovatively used. Specifically: when receiving a creation / update instruction for a target function, if the creation / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the originator of the creation / update instruction meets the specified conditions, control the target host to pre-obtain the function logic data corresponding to the target function and store it on the target host. That is, when the user initiates a creation / update instruction for a target function and the user meets the specified conditions, it can be considered that the target function will have an execution requirement soon, and through the prefetch technology, the function logic data corresponding to the target function can be downloaded to the target host in advance for backup.
[0093] Here, the prefetch work is restricted by specified conditions. For example, the specified conditions can be that the possibility of the user subsequently initiating a function trigger instruction meets a specified standard. For this reason, in an exemplary solution, the time difference between the originator of the creation / update instruction initiating the creation / update instruction and the function trigger instruction for the same function can be statistically analyzed according to the historical behavior record of the originator of the creation / update instruction to characterize the possibility of the originator subsequently initiating a function trigger instruction. In this way, when the time difference is less than the specified standard, it is determined that the originator meets the specified conditions, and in this case, the operation of prefetching the function logic data corresponding to the target function is performed.
[0094] Among them, the prefetch solution can refer to the description in the embodiment of the life cycle management solution of the foregoing container and will not be elaborated here.
[0095] Based on this, after completing the above prefetch work, once a function trigger instruction for the target function is received subsequently, only a new container needs to be started, and there is no need to remotely download the corresponding function logic data. Thus, the target function can be executed in the semi-cold start mode as described above, which can save a large amount of latency compared with the cold start mode.
[0096] Accordingly, in this embodiment, the function logic data corresponding to the functions that may be executed recently can be pre-acquired in a prefetching manner. In this way, once these functions are triggered subsequently, the functions can be executed in a semi-cold start manner, thereby avoiding the cold start manner with a longer delay. Generally speaking, the probability of using the warm start manner to execute functions can be increased. Even if the warm start manner fails to be used to execute functions, the probability of using the semi-cold start manner to execute functions can also be increased, while minimizing or even avoiding the use of the cold start manner to execute functions. Therefore, the execution efficiency of functions can be effectively improved.
[0097] Figure 6 FIG. is a schematic structural diagram of a routing device provided in another exemplary embodiment of the present application. As Figure 6 shown, the routing device includes a memory 60, a processor 61, and a communication component 62;
[0098] The memory 60 is used to store one or more computer instructions;
[0099] The processor 61 is coupled to the memory 60 and the communication component 62 and is used to execute one or more computer instructions for:
[0100] Monitoring the started containers on the target host through the communication component 62;
[0101] Sorting the started containers on the target host according to the usage heat corresponding to each of the started containers on the target host;
[0102] Selecting a target container from the started containers according to the sorting result, where the sorting position of the container meets the preset requirements;
[0103] Controlling the target container and the function logic data associated with the target container to remain resident.
[0104] In an optional embodiment, the processor 61 is further used for:
[0105] Respectively determining the start-up delay, the memory specification occupied, and / or the historical residence time of each of the started containers;
[0106] Among them, in addition to the usage heat, the basis for sorting the started containers on the target host is that the processor 61 is also used for the start-up delay, the memory specification occupied, and / or the historical residence time.
[0107] In an optional embodiment, when sorting the started containers on the target host, the processor 61 is used for:
[0108] Calculating the priority corresponding to each of the started containers on the target host;
[0109] Sorting the started containers on the target host according to the priority;
[0110] Among them, the priority is directly proportional to the usage heat; the priority is directly proportional to the startup delay; the priority is inversely proportional to the specification of the occupied memory; the priority is directly proportional to the historical residence time.
[0111] In an optional embodiment, when the processor 61 selects a target container from the started containers, it is used for:
[0112] Construct a container portrait for each started container respectively;
[0113] Maintain a container queue for the target host;
[0114] According to the sorting result, determine the sorting position of the container portrait of each started container in the container queue;
[0115] Select the started container corresponding to the container portrait whose sorting position meets the preset requirements from the container queue as the target container.
[0116] In an optional embodiment, when the processor 61 selects the started container corresponding to the container portrait whose sorting position meets the preset requirements as the target container, it is used for:
[0117] Determine the started container corresponding to the container portrait within the container queue as the target container.
[0118] In an optional embodiment, the processor 61 is further used for:
[0119] Receive a function trigger instruction for the target function;
[0120] If the target function is scheduled to a specified container in the target container on the target host, move the sorting position of the specified container forward;
[0121] Based on the retained function logic data corresponding to the target function, use the specified container to execute the target function.
[0122] In an optional embodiment, the processor 61 is further used for:
[0123] In the case of a creation / update instruction for the target function initiated by the target user, if the creation / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the target user meets the specified conditions, control the target host to pre-obtain the function logic data corresponding to the target function and retain it on the target host.
[0124] In an optional embodiment, the processor 61 is further used for:
[0125] When receiving a function trigger instruction for the target function, control the target host to create a container for the target function;
[0126] Execute the target function by using the container created for the target function based on the function logic data corresponding to the target function pre-acquired on the target host.
[0127] In an alternative embodiment, the target host is in a peer network with other hosts in the cluster. When the processor 61 controls the target host to pre-acquire the function logic data corresponding to the target function, it is used for:
[0128] Control the target host to preferentially acquire the function logic data corresponding to the target function from other hosts in the peer network.
[0129] In an alternative embodiment, the processor 61 is further used for:
[0130] Control the containers whose sorting positions in the started containers do not meet the preset requirements to be released;
[0131] Delete the function logic data associated with the released containers.
[0132] In another possible design, it is also possible to execute an optimized function calculation scheme based on Figure 6 the routing device shown. In this regard, the processor 61 can be used for:
[0133] Receive a function trigger request for the target function through the communication component 62;
[0134] If the target function is scheduled to a specified container that has been started on the target host, move forward the sorting position of the specified container among all the containers that have been started on the target host to extend the residence time of the specified container;
[0135] Based on the function logic data corresponding to the target function, use the specified container to execute the target function, and the function logic data corresponding to the target function is pre-retained on the target host.
[0136] The processor 61 can also be used for:
[0137] Receive a creation / update instruction for the target function;
[0138] If the creation / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the originator of the creation / update instruction meets the specified conditions, control the target host to pre-acquire the function logic data corresponding to the target function and retain it on the target host.
[0139] It should be noted that for the technical details in the above embodiments regarding the routing device, reference can be made to the relevant descriptions in the foregoing method embodiments. To save space, they will not be elaborated here, but this should not cause a loss to the protection scope of this application.
[0140] Further, as Figure 6As shown, the routing device further includes other components such as a power supply component 63. Figure 6 Only some components are schematically shown, which does not mean that the routing device only includes Figure 6 the components shown.
[0141] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed, it can implement the steps executable by the routing device in the above method embodiment.
[0142] Among them, Figure 6 the memory is used to store computer programs and can be configured to store various other data to support operations on the computing platform. Examples of these data include instructions for any application or method for operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc. The 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 memory, flash memory, magnetic disk or optical disk.
[0143] Among them, Figure 6 the communication component is configured to facilitate communication between the device where the communication component is located and other devices in a wired or wireless manner. The device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0144] Among them, Figure 6 the power supply component provides power for various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device where the power supply component is located.
[0145] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0146] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0147] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implement the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0149] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0150] The memory may include non-permanent memory in the computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0151] A computer-readable medium includes permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The 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 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, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0152] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising the element.
[0153] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A method for lifecycle management of a container, comprising: monitoring the started containers on a target host; sorting the started containers on the target host according to the usage heat corresponding to each of the started containers on the target host; selecting a target container from the started containers according to the sorting result, where the sorting position of the target container meets a preset requirement; controlling the target container and the function logic data associated with the target container to remain resident until the target container no longer meets the preset requirement due to a change in the sorting position.
2. The method according to claim 1, further comprising: respectively determining the start delay, the occupied memory specification, and / or the historical residence time of each started container; wherein, in addition to the usage heat, the basis for sorting the started containers on the target host further includes the start delay, the occupied memory specification, and / or the historical residence time.
3. The method according to claim 2, wherein sorting the started containers on the target host comprises: calculating the priority corresponding to each of the started containers on the target host; sorting the started containers on the target host according to the priority; wherein the priority is directly proportional to the usage heat; the priority is directly proportional to the start delay; the priority is inversely proportional to the occupied memory specification; the priority is directly proportional to the historical residence time.
4. The method according to claim 1, wherein selecting a target container from the started containers according to the sorting result comprises: respectively constructing a container portrait for each started container; maintaining a container queue for the target host; determining the sorting position of the container portrait of each started container in the container queue according to the sorting result; selecting, from the container queue, the started container corresponding to the container portrait whose sorting position meets the preset requirement as the target container.
5. The method according to claim 4, wherein selecting the started container corresponding to the container portrait whose sorting position meets the preset requirement as the target container comprises: determining the started container corresponding to the container portrait within the container queue as the target container.
6. The method according to claim 1, further comprising: receiving a function trigger instruction for a target function; if the target function is scheduled to a specified container in the target container on the target host, moving the sorting position of the specified container forward; executing the target function using the specified container based on the retained function logic data corresponding to the target function.
7. The method according to claim 1, comprising: in the case of a create / update instruction for a target function initiated by a target user, if the create / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the target user meets the specified conditions, controlling the target host to pre-acquire the function logic data corresponding to the target function and retain it on the target host.
8. The method according to claim 7, further comprising: When receiving a function trigger instruction for the target function, control the target host to create a container for the target function; Based on the function logic data corresponding to the target function pre-acquired on the target host, execute the target function by using the container created for the target function.
9. The method according to claim 7, wherein the target host and other hosts in the cluster are in a peer-to-peer network, and the control for the target host to pre-acquire the function logic data corresponding to the target function, comprises: Control the target host to preferentially obtain the function logic data corresponding to the target function from other hosts in the peer-to-peer network.
10. The method according to claim 1, further comprises: Control the containers whose sorting positions in the started containers do not meet the preset requirements to be released; Delete the function logic data associated with the released containers.
11. A function computing method, comprises: Receive a function trigger request for a target function; If the target function is scheduled to a specified container that has been started on the target host, move forward the sorting position of the specified container among all the containers that have been started on the target host to extend the residence time of the specified container; Based on the function logic data corresponding to the target function, execute the target function by using the specified container, and the function logic data corresponding to the target function is pre-retained on the target host.
12. The method according to claim 11, further comprises: Receive a create / update instruction for the target function; If the create / update instruction is scheduled to the target host and there is no container on the target host that can load the target function, when the originator of the create / update instruction meets the specified conditions, control the target host to pre-acquire the function logic data corresponding to the target function and retain it on the target host.
13. A routing device, comprising a memory, a processor, and a communication component; The memory is used to store one or more computer instructions; The processor is coupled to the memory and the communication component and is used to execute the one or more computer instructions for: Monitor the started containers on the target host through the communication component; Sort the started containers on the target host according to the usage heat corresponding to each of the started containers on the target host; Select a target container from the started containers according to the sorting result, and the sorting position of the target container meets the preset requirements; Control the target container and the function logic data associated with the target container to remain resident until the target container no longer meets the preset requirements due to a change in the sorting position.
14. A computer-readable storage medium storing computer instructions, when the computer instructions are executed by one or more processors, causing the one or more processors to execute the container life cycle management method according to any one of claims 1-10 or the function computing method according to claim 11 or 12.
Citation Information
Patent Citations
Faas warm startup and scheduling
WO2020226659A1