Server-free computing container cold start optimization method based on Zygote mechanism

Through the combination of time series prediction and Zygote mechanism, serverless computing containers are created and preloaded in advance, which solves the problem of container cold start delay, improves function calling efficiency and reduces memory usage.

CN118779061APending Publication Date: 2024-10-15TIANJIN UNIV
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410760367.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

The cold start delay problem of containers in serverless computing affects function running efficiency. Existing methods cannot effectively reduce cold start time and the generated Zygote container is not used and takes up memory.

Method used

Obtain the number of future function calls through time series prediction, combine it with the Zygote mechanism to create private containers and Zygote containers in advance, preload dependencies, reduce cold start delays, and ensure that containers created in advance are used with a high probability.

Benefits of technology

It significantly reduces the cold start delay of serverless computing containers, improves function calling efficiency, and avoids the problem of memory occupied by unused Zygote containers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779061A_ABST
    Figure CN118779061A_ABST
Patent Text Reader

Abstract

The invention discloses a server-free computing container cold start optimization method based on a Zygote mechanism, and the method comprises the steps: predicting the number of times of function call in a next time period according to the historical record of function call, and preparing the dependence of a function in advance through a prediction result according to an algorithm, so as to reduce the cold start delay of a container. The method mainly comprises the step of accurately obtaining the function calling condition of the next time period through time sequence prediction. Whether the function starts a private container or not is determined according to the prediction result, all dependency sets which do not meet the conditions are obtained, scores of all the dependency sets are obtained according to the number of times of calling of the function corresponding to the dependency sets, TF values of all dependencies in the dependency sets and installation and import time, Zygote containers are iteratively created according to the scores from large to small, and a Zygote container is obtained; most function call requirements in the future can still be met under the condition that the Zygote containers are few, and finally, a proper container execution request is selected for each function call. According to the invention, the cold start delay of the container is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of serverless computing, and in particular to a method for reducing cold start delay of a serverless computing container based on a Zygote mechanism. Background Art

[0002] The rapid development of Internet technology has given rise to the pursuit of more efficient and convenient development models. In such an environment, serverless computing has become a new solution with its excellent maintainability, agile scalability and fine-grained billing methods. In serverless computing, developers split applications into several functions, which are executed in containers or virtual machines provided by the serverless platform. The introduction of this method brings the following significant benefits: First, it can adaptively adjust processing power, freeing developers from worrying about the number and configuration of servers, greatly simplifying the management process. Second, developers' fees are calculated only based on actual usage time, which not only reduces costs but also helps improve performance.

[0003] Despite the huge advantages of serverless computing, there are still some problems, and container cold start delay is one of them. Cold start delay will significantly affect the overall operating efficiency of serverless functions. This is mainly due to two reasons: one is that cold starts occur frequently; the other is that the proportion of delay time occupied by cold starts is too high. Usually, the life cycle of serverless functions is short, and most serverless functions only take tens of milliseconds to execute. In comparison, tens or hundreds of cold start delays appear. Someone calculated the ratio of execution delay of 14 serverless functions to total response delay and found that the execution delay of 12 serverless functions was even less than 30%. Therefore, fast cold start is crucial for developers.

[0004] Time series prediction refers to the analysis of historical time series data and the prediction of future trends. It has demonstrated its unique value in many fields such as transportation, meteorology, and stock markets. This technology captures the law of data changes over time through in-depth analysis of past data, and combines factors such as seasonal adjustments and cyclical fluctuations to accurately predict future data trends. Most existing methods directly obtain the next call time of the function through prediction, but due to a certain error rate in the prediction, the wrong function instance is started, which leads to a waste of resources and does not effectively reduce the cold start time. The present invention uses time series prediction technology to obtain the number of future function calls, and combines it with the Zygote mechanism to start the container in advance or prepare some dependencies in a targeted manner to reduce the cold start time.

[0005] The Zygotes mechanism originally originated from the Android system and is an optimization technology for improving the speed and efficiency of application startup. When a new application needs to be started, the Zygote process will create a new child process through the fork() system call, and this child process already includes some preloaded runtime environments and class libraries, thereby avoiding the time consumption of loading runtime environments and class libraries from scratch, effectively simplifying the application startup process. In the present invention, the basic container containing the public dependency package of the function is regarded as the Zygote container, which can serve as the "parent container" of multiple functions, which downloads, installs, and imports some dependencies in advance in the public domain, and downloads some dependencies in advance in the private domain, and because the main reason for causing the cold start of the container is the installation and download of the required dependency of the function, the startup time can be significantly reduced by directly forking a new container from the Zygote container.

[0006] The existing methods based on the Zygotes mechanism either cache the called Zygote trees and update the cache through the LRU algorithm; or merge the public packages of several containers based on similarity to create a Zygote container. However, these methods can easily cause the generated Zygote container to not be used, which makes it impossible for future function calls to use the Zygote container to reduce cold starts, and the useless Zygote containers take up a lot of memory. Summary of the invention

[0007] In view of the problems in existing work, the present invention provides a serverless computing container cold start optimization method based on the Zygote mechanism. The method first obtains the number of future function calls through time series prediction, and then determines which private containers or Zygote containers to start and which dependencies the Zygote containers have prepared in advance according to the number of function calls, so that the private containers and Zygote containers created in advance are used with a high probability, and then most function calls can directly use private containers or obtain function instances according to Zygote containers to reduce cold start delays.

[0008] In order to solve the above technical problems, the present invention proposes a cold start optimization method based on the Zygote mechanism, comprising the following steps:

[0009] Step 1: Obtain the number of function calls in the next time period through time series prediction

[0010] 1-1) Data preprocessing: The present invention uses a data set containing function ID and function call time, takes the number of calls in each time period of all the functions to be predicted as features, and measures the predictability of each function sequence by sequence length and permutation entropy. Only the sequences with a length greater than the threshold L1 and a permutation entropy less than the threshold L hIt ignores the sequences with very few records and poor prediction effect but requires certain resources;

[0011] 1-2) Construct and forecast a time series model: The present invention uses TimesNet as a forecast model and uses the Tweedie loss function as a loss function. The above data set is divided into a training set, a validation set, and a test set in a ratio of 7:1:2. The training set is used to train the model, the validation set is used to adjust the model hyperparameters, and the test set is used to evaluate the effect of the final experiment;

[0012] 1-3) Predict future function calls: Use the constructed neural network model in each time period to predict the number of calls of each function in the next time period;

[0013] Step 2: Determine the container type based on the function call situation

[0014] After obtaining the prediction results, you need to determine which container to create;

[0015] 2-1) Determine the type of private container: determine whether the number of function calls in the next time period is greater than or equal to the threshold L p If the conditions are met, a command to create a container instance is sent and step 3 is executed; otherwise, step 2-2 is executed;

[0016] 2-2) Determine the type of Zygote container: First, obtain all containers with a call count less than the threshold L. p Then get all the dependency sets of all functions and calculate the score s(i) of a dependency set i to measure the frequency of occurrence of dependency set i and the benefits of creating a Zygote container based on the dependency set. The score calculation formula is as follows:

[0017]

[0018] Where times(i) represents the sum of the number of calls of all functions containing dependency set i in the next time period. The present invention uses it to measure the possibility that the function called in the next time period needs to rely on set i. configuration (i) represents the average time to install and import dependency set i, which is used to measure how much cold start time can be saved by creating this Zygote container compared to other types of Zygote containers. α, β, and γ are all hyperparameters. TF(i) represents the "word frequency" of dependency set i.

[0019] After getting the scores of each set, sort them by score and iterate as follows: each time select the set with the highest score as the dependency set C of the public domain of the newly created Zygote container S , get all functions containing the dependency set, and get all functions except the dependency set CS Other dependencies of the function are used as the dependency set C of each function's private domain P , and update the dependent set C at the same time S The update method is: get all functions that contain the highest score dependency set, for each function j, get all its dependency sets, and subtract the number of calls of function j in the next time period from times(i) corresponding to the dependency set, and then update the score of the dependency set. The iteration ends when all functions can use a Zygote container to obtain function instances or the scores of the remaining dependency sets are lower than the threshold L. s .

[0020] Step 3: Create a container based on the controller command

[0021] After the host receives the creation command, it needs to create the corresponding container in advance according to the command. The following is the specific creation method;

[0022] 3-1) Create a private container: directly start the image of the corresponding function, the function dependencies in the container have been downloaded, installed, imported, and the code is running;

[0023] 3-2) Create a Zygote container: There are shared domains and private domains corresponding to each function in the container. Functions that can use this container can only access the shared domain and the private domain corresponding to the function. The shared domain installs and imports the dependencies required by all functions; the private domain downloads the dependencies and code corresponding to each function in advance;

[0024] Step 4: Execute the function call request

[0025] When a function call request arrives, the request is sent to the corresponding container. For each function call, one of the following situations occurs:

[0026] 4-1) Use a private container to execute the request: Send the request directly to the private container of the corresponding function.

[0027] 4-2) Use the Zygote container to execute the request: Get all Zygote containers whose private domains contain the function. If the time required to get the function instance from the Zygote container is shorter than the time required to start the image, fork the Zygote container, then install and import the private domain dependencies of the function, run the code, and finally send the request to the container. Otherwise, execute 4-3)

[0028] 4-3) Execute the request through the function image: start the image corresponding to the function, and then send the request to the corresponding container.

[0029] Compared with the prior art, the present invention has the following beneficial effects:

[0030] The present invention discloses a serverless computing container cold start optimization method based on the Zygote mechanism. The future function call situation is obtained more accurately through time series prediction. Then, according to the prediction result, the dependent TF value, and the dependent configuration time, the score of the dependency set is obtained, and the type of Zygote container to be created is determined based on it, so that when there are fewer Zygote containers, the future function call requirements can still be met with a high probability. Compared with the prior art, the present invention greatly reduces the container cold start delay. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a structural diagram of the serverless system in the present invention;

[0032] Figure 2 It is a flow chart for determining the type of Zygote in the present invention;

[0033] Figure 3 It is a flow chart of updating dependency set score in the present invention;

[0034] Figure 4 It is a flow chart of the response function call in the present invention. DETAILED DESCRIPTION

[0035] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0036] The serverless system structure proposed by the present invention is as follows Figure 1 As shown in the figure, the master node includes two parts: the predictor and the controller. The worker node includes the container pool manager and the cache manager. The container pool manager includes the private container pool and the Zygote container pool. The cache manager includes the image cache and the dependency cache.

[0037] The predictor is responsible for predicting the function calls in the next time period based on the function call history data. The controller is responsible for determining which function instances and Zygote containers are needed based on the prediction results given by the predictor, and sending the container creation command to the working host. After receiving the creation command from the controller, the working host creates and manages the container through the container pool manager and the cache manager. The container pool manager is responsible for creating and destroying private containers and Zygote containers, and the cache manager is responsible for storing the images corresponding to the functions and the dependencies required by the functions. This invention combines time series prediction with the Zygote mechanism for the first time. By predicting future function calls, it starts function instances or creates Zygote functions based on the dependencies required by multiple functions, so that it is very likely to meet the next function request. The specific contents of each step are described in detail below:

[0038] Step 1: Obtain the number of function calls in the next time period through time series prediction

[0039] 1-1) Data preprocessing: The data set used in this embodiment is: Azure data set. The present invention uses the function call status on the Azure platform for 2 weeks from 2021-01-31. The data includes application ID, function ID, end timestamp, and function execution time. The present invention first obtains the time when the function is called according to the end timestamp and the function execution time, and then counts the number of calls of each function in each time period. The present invention uses the number of calls in each time period of all functions to be predicted as a feature, so that it can not only capture the calling rules of the function that change over time, but also obtain the calling relationship between functions for more accurate prediction. However, due to the large number of functions and the extremely low calling frequency of most functions, the present invention measures the predictability of each function sequence by sequence length and permutation entropy. Permutation entropy is an indicator to measure the complexity of the time series. The more regular the time series, the smaller the corresponding permutation entropy. The calculation method is: for a permutation X of length n = {x1, x2,…, x n}, specify an embedding dimension m and a time delay t, perform phase space reconstruction, and obtain k subsequences X1 = {x1, x 1+t ,…,x 1+(m-1)t},X2={x2,x 2+t ,…,x 2+(m-1)t},…,X k ={x k ,x k+t ,…,x k+(m-1)t}, where k = n-(m-1)t, corresponding to each subsequence X j , sort them by size, and calculate the value of j The probability P of the same sorting method j , and then the permutation entropy can be obtained according to the following formula. The information entropy calculation formula is as follows:

[0040]

[0041] The present invention only processes sequences with lengths greater than the threshold L. l And the permutation entropy is lower than the threshold L h Other sequences are ignored because they are very few in number and have poor prediction effects but require certain resources.

[0042] 1-2) Construct and predict the time series model: This paper uses TimesNet, which has achieved SOTA performance in multiple tasks, as the prediction model. Since the data has zero-point clustering (i.e., a large number of samples are clustered at 0), it is more in line with the composite Poisson-Gamma distribution, so the Tweedie loss function is used as the loss function. The calculation formula of the Tweedie loss function is as follows:

[0043]

[0044] where x i is the i-th element of the time series, N is the number of elements, μ is the expectation and ρ is the shape parameter. In this embodiment, the Azure dataset is divided into a training set, a validation set, and a test set in a ratio of 7:1:2. The training set is used to train the model, the validation set is used to adjust the model hyperparameters, and the test set is used to evaluate the effect of the final experiment.

[0045] 1-3) Predict future function calls: Use the constructed neural network model to predict the number of function calls in the next time period in each time period.

[0046] Step 2: Determine the container type based on the function call situation

[0047] Due to the noise in the data set and the actual call situation, the prediction results deviate from the actual situation. Therefore, the present invention not only starts private containers for containers with a high probability of being called, but also starts Zygote containers to enable a small number of containers to meet future function requirements with a high probability, while making the function running delay shorter than starting the image, thereby reducing the cold start delay.

[0048] Therefore, after the controller obtains the prediction result of the predictor, it determines what kind of container needs to be created and sends it to other hosts. The steps to determine the container type are as follows: Figure 2 As shown in the figure, after obtaining the number of future function calls through prediction, the specific steps are as follows;

[0049] 2-1) Determine the type of private container: determine whether the number of function calls in the next time period is greater than or equal to the threshold L p If the conditions are met, a command to create a container instance is sent to other hosts and step 3 is executed; otherwise, step 2-2 is executed;

[0050] 2-2) Determine the type of Zygote container: First, obtain all containers with a call count less than the threshold L. p The functions and their corresponding call times are obtained; then all dependency sets C of all functions are obtained, and the score s(i) of a dependency set i is calculated according to formula (3):

[0051]

[0052] Where times(i) represents the sum of the number of calls of all functions containing dependency set i in the next time period. The present invention uses it to measure the possibility that the function called in the next time period needs to rely on set i. configurationIt represents the average time to install and import dependency set i, which is used to measure how long the cold start time of the container can be saved by creating this Zygote container compared to other types of Zygote containers. α, β, and γ are all hyperparameters. TF(i) represents the "word frequency" of dependency set i. TF was originally used to evaluate the importance of a word to a document. In the present invention, it is used to measure the importance of dependency set i to the dependency library formed by the dependency sets of all functions. The TF calculation formula is:

[0053]

[0054] number has (i) represents the number of functions containing dependency set i, N F Indicates the total number of all functions.

[0055] After getting the scores of each set, sort them by score. Figure 3 The method iterates, each time selecting the set with the highest score as the dependent set C of the public domain of the new Zygote container S , get all functions containing the dependency set (the present invention refers to the functions in the dependency set containing the dependency set as the public domain of the new Zygote container as covered), and get all functions except the dependency set C S Other dependencies of the function are used as the dependency set C of each function's private domain P , and update the scores of other sets at the same time. The update process is as follows Figure 4 As shown in the figure, the specific update method is as follows: Get all functions that contain the dependency set with the highest current score. For each function j, get all its dependency sets, and subtract the number of calls of function j in the next time period from the times(i) corresponding to the dependency set, and then update the score of the dependency set. The iteration ends when all functions can use a Zygote container to obtain function instances or the scores of the remaining dependency sets are lower than the threshold L. s .

[0056] Step 3: Create a container based on the controller command

[0057] After receiving the controller's command, other hosts need to create corresponding containers in advance according to the command. The following is the specific creation method;

[0058] 3-1) Create a private container: directly start the image of the corresponding function, so that the function dependencies have been downloaded, installed, and imported, and the code is running and can receive call requests at any time;

[0059] 3-2) Create a Zygote container: There are shared domains and private domains corresponding to each function in the container. Functions that can use this container do not have root permissions, but can only access the shared domain and the private domain corresponding to the function. The shared domain contains the public dependencies required by all functions, and the public dependencies have been installed and imported; the private domain has downloaded the dependencies and codes corresponding to each function in advance, but the dependencies have not been installed and imported.

[0060] Step 4: Execute the function call request

[0061] When a function call request arrives, the controller needs to forward the request to other hosts. After receiving the request, other hosts need to send the request to the corresponding container for calling. The response function call process is as follows: Figure 4 shown.

[0062] 4-1) Determine whether a private container can be used to execute the request: If there is a private container corresponding to the function, send the request to the private container of the corresponding function;

[0063] 4-2) Determine whether the Zygote container can be used to execute the request: If there is no private container corresponding to the function, but there is a Zygote container covering the function, then obtain all Zygote containers with the function in the private domain, install and import the dependencies of the function corresponding to the private domain, and compare the total time of running the function code with the estimated execution time of executing the request through the function image. If the required time is shorter, fork the Zygote container, enable the permissions corresponding to the function, then install and import the dependencies of the function's private domain, run the code, and finally send the request to the container. Otherwise, execute 4-3);

[0064] 4-3) Execute the request through the function image: If no suitable Zygote container is found, start the image corresponding to the function (that is, the private container of the corresponding function), and then send the request to the corresponding container.

[0065] The present invention can be applied to container cold start optimization in the field of serverless computing.

[0066] Although the present invention has been described above in conjunction with the accompanying drawings, the present invention is not limited to the above-mentioned specific embodiments, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can make many modifications without departing from the purpose of the present invention, all of which are within the protection of the present invention.

Claims

1. A serverless computing container cold start optimization method based on Zygote mechanism, characterized in that: The following steps are involved: Step 1: Obtain the number of function calls in the next time period through time series prediction, including: 1-1) Data preprocessing: Use a data set containing function ID and function call time, and use the number of calls in each time period of all functions to be predicted as features. h The sequence is predicted; the permutation entropy calculation formula is as follows: Among them, P j is the probability that the sequence phase space is reconstructed in the same order as subsequence j, and k is the number of subsequences; 1-2) Build a time series prediction model: Use TimesNet as the prediction model and Tweedie loss function as the loss function. The Tweedie calculation formula is as follows: Among them, x i is the i-th element of the time series, N is the number of elements, μ is the expectation, and ρ is the shape parameter; Divide the data set into a training set, a validation set, and a test set in a ratio of 7:1:2; 1-3) Predict future function calls: Use the built time series prediction model to predict the number of calls of each function in the next time period based on the number of calls of each function in each time period; Step 2: Determine the container type based on the predicted function call conditions, including: 2-1) Determine the type of private container: determine whether the number of function calls in the next time period is greater than or equal to the threshold L p If the conditions are met, send a command to create a container instance and execute step 3; otherwise, execute step 2-2); 2-2) Determine the type of Zygote container: First, obtain all containers with a call count less than the threshold L. p The functions and their corresponding call times are obtained; then all dependency sets of all functions are obtained, and the score s(i) of dependency set i is calculated to measure the frequency of occurrence of dependency set i and the benefits of creating a Zygote container based on the dependency set. The calculation formula of the score s(i) of dependency set i is as follows: Among them, times(i) represents the sum of the number of calls of all functions in the next time period that contain dependency set i, and time configuration It represents the average time to install and import dependency set i, which is used to measure the time saved by creating this Zygote container compared with other types of Zygote containers. α, β, and γ are all hyperparameters. TF(i) represents the word frequency of dependency set i. After obtaining the scores of each set, sort them by score and iterate as follows: Each time, the dependency set with the highest score is selected as the public domain dependency set C of the newly created Zygote container. S , get all the dependencies containing this dependency set C S function, and get the dependent set C S Other dependencies of the function are used as the dependency set C of each function's private domain P , and update the dependent set C at the same time S Scores of other dependency sets; the update method is: obtain all functions containing the dependency set with the highest score, for each function j, obtain all its dependency sets, and subtract the number of calls of function j in the next time period from times(i) corresponding to all the obtained dependency sets, and then update the score of the dependency set; the iteration end condition is that all functions can use a Zygote container to obtain function instances or the scores of the remaining dependency sets in the current iteration are lower than the threshold L s ; Step 3: Create a container based on the controller command After receiving the creation command, the host creates the corresponding container in advance according to the command, including: 3-1) Create a private container: directly start the image of the corresponding function. The function dependencies in the container have been downloaded, installed, imported, and the code has been downloaded; 3-2) Create a Zygote container: There are a shared domain and a private domain corresponding to each function in the container. The functions of this container are used to access the shared domain and the private domain corresponding to the function; the shared domain installs and imports the dependencies required by all functions; the private domain downloads the dependencies and codes corresponding to each function in advance; Step 4: Execute the function call request When a function call request arrives, the request is sent to the corresponding container. For each function call, one of the following situations occurs: 4-1) Use private container to execute request: directly send the request to the private container of the corresponding function; 4-2) Use the Zygote container to execute the request: Get all Zygote containers whose private domains contain the function. If the time required for the Zygote container to obtain the function instance is shorter than the time required to start the image, fork the Zygote container, then install and import the dependencies of the function's private domain, run the code, and finally send the request to the newly forked Zygote container; otherwise, proceed as in 4-3); 4-3) Execute the request through the function image: start the image corresponding to the function, and then send the request to the corresponding container.

Citation Information

Cited By

  • Quick service starting method and system based on Zygote container in server-free edge cloud

    CN119917179A

  • Zygote container-based service fast start method and system in serverless edge cloud

    CN119917179B

  • Serverless cold start optimization method, device and system

    CN121411841A