Method for optimizing cold start of container in service-free computing environment
By mining the correlation of function in a serverless computing environment and optimizing cold start with histogram and LSTM algorithm, the delay and resource waste caused by cold start problems are solved, and a lower cold start rate and delay are achieved, and memory usage is optimized.
Patent Information
- Application Number
- CN202411703268.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In serverless computing environments, cold start problems lead to delays and waste of resources, and the existing technology is difficult to effectively optimize.
By mining the correlation between functions, and using a hybrid histogram strategy and long-term short-term memory network algorithm, the cold start process is optimized and the preheating and keep-alive time is dynamically adjusted.
It effectively reduces the cold start rate and the total cold start delay of the system, optimizes memory consumption, and improves resource utilization and user experience.
Smart Images

Figure CN119645520A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of serverless computing, and in particular to a cold start optimization method in a serverless computing environment. Background Art
[0002] Function as a Service (FaaS) is an emerging programming model in cloud computing. Compared with traditional cloud services, FaaS has significant advantages for both cloud service providers and users. For cloud service providers, FaaS can maximize the utilization of infrastructure and improve resource efficiency by allocating computing resources on demand rather than waiting for them to be used. For users, FaaS enables them to focus on application logic and only need to develop serverless functions. Other management tasks are handled by cloud service providers, which not only reduces the complexity of development and maintenance, but also reduces expenses because users only pay for the resources actually used.
[0003] However, providing FaaS services also brings new challenges. Customers expect their serverless functions to be "ready at any time" for execution, but memory resources are usually very limited in data centers. In order to balance the readiness and memory consumption of serverless functions, FaaS platforms put functions into containers for execution. When a serverless function is called, if the relevant container is already in memory, the function can be executed quickly. But if the container is not loaded, the initialization process will cause high latency, which is the so-called cold start problem. Cold starts not only waste precious memory, but also lead to additional costs, because unexecuted functions do not incur resource consumption costs, but idle functions occupy memory resources, increasing the expenses of cloud service providers. The current mainstream cold start optimization methods can be regarded as two categories. The first category is system-level optimization. These methods focus on shortening the cold start time, but still cannot completely eliminate the delay caused by cold start, affecting user experience. The second category of methods is to schedule according to the call history of the function, aiming to reduce the number of cold starts. The method for optimizing serverless computing cold starts proposed in this patent is to predict the cold start time based on the call history of the function.
[0004] Previous experiments have shown that the arrival interval of requests is generally distributed in seconds, minutes or even hours. The mainstream static keep-alive strategy based on time-to-live will lead to a large waste of resources. There are also cold start optimization algorithms based on application level scheduling, which have large scheduling granularity, lack flexibility and pertinence, and may be accompanied by waste of system resources. The cold start optimization algorithm based on function level can achieve more flexible and fine-grained scheduling, but due to the difficulty of predicting function-level calls, the feasibility is poor.
[0005] Considering that there are often dependencies and scheduling orders between functions, some functions may be often called together, and some functions may be called by other functions. Imagine mining the relationship between functions and scheduling the associated functions as a whole. On the one hand, compared with application-level scheduling, the call granularity based on the associated function set is finer and the scalability is better. On the other hand, scheduling based on the associated function set can effectively reduce the cold start rate and the total cold start delay of the system, such as the cold start delay caused by the cascade cold start triggered by the order of function calls. In addition, the cold start optimization algorithm based on the associated function set can effectively reduce memory consumption. Summary of the invention
[0006] To solve the problems described in the background technology, the present invention proposes a cold start optimization method based on function correlation mining and hybrid histogram strategy in a serverless computing environment.
[0007] The technical solution of the present invention comprises the following steps:
[0008] S1. Count the calls of serverless computing functions in the past time period, and record the number of calls per minute for each serverless computing function N (N = {n1, ..., n t}), record the execution time E of the serverless computing function (E = {e1, ..., e n}), clean and process the collected data.
[0009] S2. Convert the function and the number of function calls into a two-dimensional matrix, and determine the size of the dynamic time window T and the moving step d according to the sparsity of the matrix.
[0010] S3. Map the functions in the window and the number of function calls to a completely undirected graph, calculate the correlation between the functions, and screen out function pairs or function combinations with local correlation through graph pruning.
[0011] S4. Map the distribution of the function pairs or function combinations in the time series into the form of a time series, and use a dynamic regularization algorithm to calculate the similarity of the function pairs in the time distribution.
[0012] S5. Adjacency list storage is used, and function nodes are sorted in descending order of relevance. The time similarity calculated based on the dynamic regularization algorithm is traversed and reorganized to obtain the final associated function combination and convert it into a function set.
[0013] S6. Use the function set as the basic unit of the histogram preheating and keep-alive strategy, record the arrival time of each function in the function set and draw an IT histogram. The scheduler analyzes the histogram to decide when to load the function into the memory for preheating and how long to keep it in the memory after calling.
[0014] S7. In addition, the coefficient of variation of the histogram is calculated. If the coefficient of variation is lower than the threshold, the histogram is considered representative and the preheating keep-alive percentage can be directly divided by the histogram. If the coefficient of variation is higher than the threshold, the long short-term memory network algorithm is combined to predict the function arrival time. The preheating time calculated based on the histogram distribution and the preheating time calculated based on the long short-term memory network algorithm are weighted, and the final prediction result is calculated by fully considering the historical call situation and long-term call trend.
[0015] Furthermore, the S1 comprises the following steps:
[0016] S1.1. It is necessary to calculate the calling time T (T = {t1, ..., t n}) is organized into the number of calls to the serverless computing function in each consecutive minute N (N = {n1,...,n t In practice, it is difficult to record the duration of each function call. You can record the number of calls i and the average execution time of these i calls every 30 seconds.
[0017] Furthermore, the S2 comprises the following steps:
[0018] S2.1. Convert the number of function calls into a two-dimensional matrix. The number of non-zero elements in the matrix / the total number of elements in the matrix is used to represent the sparsity.
[0019] S2.2, dynamically adjust the window size according to the sparsity, assuming that the range of window size W is [Win min ,Win max ], the formula is: W = Win min +(Win max -Win min )×h 稀疏度 .
[0020] Furthermore, the S3 comprises the following steps:
[0021] S3.1. By controlling the sliding window size and the moving step size, the clustering effect and cluster size can be indirectly affected. A completely undirected graph of functions and function call mappings within the sliding window, where nodes represent functions and edges represent the association between functions. Taking function A and function B as an example, the weight on the edge is: p (a,b) =I A +I B / Num T (I A ≠0,I B ≠0), p (a,b) =NULL(I A =0||I B =0).
[0022] Furthermore, the S4 comprises the following steps:
[0023] S4.1 The temporal distribution of the correlation function pairs or function combinations obtained in S3 is serialized, the sequence similarity is calculated using a dynamic regularization algorithm, the upper bound of the comparison window is set, and the temporally adjacent correlation function combinations are further screened out.
[0024] Furthermore, the S5 comprises the following steps:
[0025] S5.1. A cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 3 or 4, characterized in that: the linked list nodes are arranged in descending order of correlation to find out the associated function combinations.
[0026] Traverse the adjacency list. If the dtw value is less than the specified threshold, continue traversing. If the dtw value exceeds the threshold, disconnect the node. Start a new traversal from the disconnected node, update the dtw value on the node, and get the association function combination.
[0027] S5.2. Process the associated function combination and convert it into a function set.
[0028] Furthermore, the S6 comprises the following steps:
[0029] S6.1. Determine two windows by real-time statistics of the IT histogram of the functions under each associated function set. IT represents the idle time, that is, the time interval from the end of this call to the arrival of the next call.
[0030] S6.2. Determine the percentage for dividing the two windows based on the distribution of the histogram. The greater the probability that the function call hits the second window, the better the preheating effect.
[0031] Further, the S7 comprises the following steps:
[0032] S7.1. According to the long-term and short-term time series prediction model, the call time T (T = {t1, ..., t n}) to predict the calling time Y of the serverless computing function in the future (Y={y i , ..., y n})
[0033] S7.2. By calculating the coefficient of variation of the histogram, determine whether the histogram can be directly divided into two windows by percentage. When the coefficient of variation is greater than the threshold, for example, the application has just been deployed and there is not enough data to generate a histogram or the function IT is too discrete, you can use the long-term and short-term time series prediction algorithm to weight the long-term and short-term time series prediction results and the historical histogram distribution prediction results based on the coefficient of variation value to calculate the final pre_warm and keep_alive values. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0035] Figure 1 The present invention is a flowchart of a cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to an embodiment of the present invention.
[0036] Figure 2 Schematic diagram of the adjacency list traversal order when calculating the association function set for the example of the present invention.
[0037] FIG3 is a schematic diagram of the cumulative distribution histogram strategy of a function set, wherein (a) is a representative example of the cumulative histogram preheating and keeping alive strategy, and (b) is an unrepresentative example of the cumulative histogram. DETAILED DESCRIPTION
[0038] The following is a detailed description of the implementation of the present invention in conjunction with the accompanying drawings, but they do not constitute a limitation of the present invention, but are only examples. At the same time, through the description, the advantages of the present invention will be more clearly understood. Based on the examples in the present invention, all other examples obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present invention.
[0039] 1. Description of relevant parameters of cold start optimization method
[0040] (1) The number of serverless computing functions is denoted by n, which is the same as the meaning of n in this document. The duration of the serverless computing function statistics is denoted by t, which is the same as the meaning of t in this document, and the total duration is T.
[0041] (2) The number of function calls per minute N (N = {n1,...,n t}): Define an empty list N to store the number of calls to the serverless computing function per minute. After each function call, the number of calls and function name of the current serverless computing function are stored in list N.
[0042] (3) The average execution time of the function E(E={{e1,...,e n}}): Every 30 seconds, record the number of function calls i and the average execution time of these i calls. Suppose there are two time periods with averages of 10 and 12, and 5 and 3 calls respectively. The percentile is calculated based on the "weighted" distribution (10,10,10,10,12,12,12).
[0043] (4) Dynamic time window W: The frequency of serverless computing function calls of different applications varies greatly, so the division range of dynamic time windows is different. First, the sparsity of serverless computing function calls h under different applications is calculated. 稀疏度 = the number of non-zero elements in the matrix / the total number of elements in the matrix. The window size is dynamically adjusted according to the sparsity. Assume that the range of the window size W is [Win min ,Win max ], the formula is: W = Win min +(Win max -Win min )×h 稀疏度
[0044] (5) Score i x,y : Taking function A and function B as examples, the correlation value within a certain period of time can be expressed as:
[0045]
[0046] Among them I A ,I B Indicates the frequency of function A and function B occurring in the i-th time window, Num T Indicates the frequency and. The value of Score will be recorded in the corresponding list of the function group.
[0047] (6) Counter record: Each group of related functions has a counter to record the number of times the group of functions appears in the statistical time.
[0048] (7) Threshold P c :The function correlation degree is related to the threshold P c Compare. If it is less than P c , then prune; if it is greater than P c , counter record+1.
[0049] (8) DTW comparison upper bound: The purpose of setting the bound is to terminate unnecessary comparisons early during DTW comparisons to reduce computing time. If the bound is not set, DTW will compare all possible paths, which will result in exponential running time when the sequence length is large.
[0050] (9) Dtw: represents the distribution similarity of the dynamic regularization algorithm to calculate the function group in the time series
[0051] (10)Threshold D c : Compare the dtw value with the threshold D c Compare. If it is less than D c Then disconnect the current node and reconstruct the linked list with the function at the disconnection point as the vertex; if it is greater than D c , then continue traversing.
[0052] (11) Time Y t :The output of the time series prediction model is the arrival time Y of the subsequent serverless computing function of the predicted function set t =(Y t ={y1,...,y m}, that is, the arrival time of the serverless computing function in the subsequent period of time after the current time t, and indirectly calculate the IAT value (Inter-Arrival Time) predicted by the serverless computing function under this function set.
[0053] (12) Normalization i * : For LSTM input, the maximum and minimum value method is used to normalize the data required for training, thereby solving the problem of different dimensions between input features: i * =ii min / i max -i min .
[0054] (13) Loss function L: Use mean square error (MSE) as the loss function to calculate the sum of squares of the error between the model prediction value and the actual arrival time of the no-service calculation function: Where N is the number of training samples, is the model's predicted value, Be practical.
[0055] (14) Learning rate p: Adjusted in time according to the decrease in loss during training.
[0056] (15) Coefficient of variation CV: CV = standard square deviation / mean value. A CV value of 0 indicates that the IAT is fixed. The smaller the CV value, the higher the predictability of the histogram strategy. The larger the CV value, the lower the predictability of the histogram strategy.
[0057] (16) Pre-warm: The pre-warm window. After the function is executed, it will be released immediately. After the pre-warm window has passed, the function instance will be started again. The value of the pre-warm window can be 0, which means that the function will not be released immediately after the execution is completed, but will continue to run. Keep-alive: The keep-alive window is the time to wait for the instance to continue running after being pre-warmed.
[0058] 2. Specific process of cold start optimization method
[0059] The cold start optimization method based on function correlation mining and cumulative histogram strategy in the serverless computing environment proposed in this paper is a cold start optimization strategy that determines the function set by calculating the function correlation and uses the associated function set as the scheduling granularity. This strategy combines the cumulative histogram of historical serverless computing function calls and the time series prediction algorithm to predict the time range of cold start occurrence, and calculates the cold start optimization of the warm-up period and the keep-alive period. Its flow chart is as follows Figure 1 shown.
[0060] (1) First, count the number of calls per minute for each serverless computing function in the past time period N (N = {n1, ..., n t}), and the average execution time of the serverless computing function E(E={{e1,...,e n}}).
[0061] (2) Divide the time period of the recorded samples in (1) into non-overlapping small time windows, and count the number of calls of each function in the time window.
[0062] Specifically, step (2) is implemented by the following process:
[0063] (2.1) The sampled serverless computing functions and the number of calls per minute of the serverless computing functions N (N = {n1, ..., n t}) is converted into a matrix, and the size of the dynamic window is determined by calculating the sparsity of the matrix. The higher the sparsity, the larger the window; the lower the sparsity, the smaller the window. 稀疏度 =Number of non-zero elements in the matrix / total number of elements in the matrix.
[0064] (2.2) Assume that the length of the window size Win is L, and the range is [Win min ,Win max ], directly adjust the window size according to the sparsity value, the formula is W = Win min +(Win max -Win min )×β×h 稀疏度 , where β is the adjusted coefficient.
[0065] (3) Count the number of calls of each function in the time window, calculate the correlation between the serverless computing functions with non-zero call times, and store the correlation of the function combination in the current time window into list S. Take function A and function B as an example. Where i represents the i-th time window. Thus, a combination of serverless computing functions with a high probability of being called simultaneously in each time window is found.
[0066] (4) Since the size of the score can only represent the correlation of the serverless computing function in the current local time window, it is necessary to further determine the correlation of the locally associated function combination in the continuous time window. It is necessary to set a counter Record for each group of functions to record the number of times the correlation value is non-zero in the continuous time window. The S list is mapped into the form of a time series, and the time series dynamic regularization algorithm is used to calculate the similarity of different function combinations in the time dimension, and further aggregate different associated function groups.
[0067] Specifically, step (4) is implemented by the following process:
[0068] (4.1) When Score≠0, the counter is incremented by 1. The counter size represents the sum of the number of times the function group is judged to be associated in different time windows, thereby judging whether the associated function group is associated in continuous time windows.
[0069] (4.2) Map the S list to a time series consisting of 0 and 1, where 0 represents that the current function group is considered unrelated in the corresponding time window, and 1 represents that the current function group is considered related in the corresponding time window. The time series dynamic regularization algorithm is used to calculate the similarity of different function groups in the time series with time windows as units. The related function combinations are further merged.
[0070] (4.3) When the DTW algorithm calculates the similarity of time series, it sets the upper bound of comparison to terminate unnecessary comparisons to reduce the calculation time. In addition, by adjusting the upper bound, it ensures that all serverless computing functions in the associated function group belong to adjacent time domains.
[0071] (5) Use adjacency lists for storage, where vertices represent functions, neighbor nodes represent associated functions, and neighbor nodes store the associated degree values and dtw values. Neighbor nodes are sorted in descending order of associated degree. Traverse and build the adjacency list. If dtw is less than the specified threshold, continue traversing. If dtw exceeds the threshold, disconnect and rebuild the linked list from the disconnected nodes, and update the value of dtw, such as Figure 2 shown.
[0072] (6) Use the function set as the basic unit for drawing the cumulative histogram, record the arrival time of each serverless computing function under the function set, and draw the IT cumulative distribution histogram. The scheduler will decide when to preheat the container instance and how long to keep the serverless computing function in memory after execution by analyzing the distribution of the cumulative histogram.
[0073] (7) The distribution state of the cumulative histogram affects the prediction accuracy. When the distribution of the cumulative histogram converges as shown in Figure 3(a), the preheating time period and the keep-alive time period can be directly divided into percentages according to the distribution of the function arrival time interval. If the distribution of the cumulative histogram is discrete as shown in Figure 3(b), the function arrival time is predicted in combination with the time series prediction algorithm. The preheating time calculated based on the cumulative distribution graph and the preheating time calculated based on the long short-term memory network algorithm are weighted to fully consider the historical call situation and the long-term trend prediction results. Specifically, step (7) is implemented through the following process:
[0074] (7.1) Whether the cumulative histogram has a clear decision-making power is determined by calculating the coefficient of variation of the cumulative distribution of arrival time. The larger the CV value, the more decision-making power it has, and the smaller the CV value, the less direct decision-making power it has. It is necessary to comprehensively consider the long-term call trend.
[0075] (7.2) For functions whose prediction results cannot be directly obtained by historical cumulative distribution analysis, the predicted value of the function is calculated in combination with the time series prediction algorithm.
[0076] 3. Pseudocode of cold start optimization algorithm
[0077] (1) Define a list N that stores the number of calls per minute, a list E that stores the execution time, a list S that stores the function association within each time window, and a timeSeriesMap that stores the time series mapping.
[0078] (2) Define an adjacency list to store function nodes and function relationships.
[0079] (3) for serverless computing functions in the past time period
[0080] (4) Number of calls per minute for For[0,T]
[0081] (5) Generate time series correlation matrix.
[0082] (6) Calculate the sparse value and determine the size and step length of the dynamic time window
[0083] (7) Calculate the correlation between functions in each dynamic time window
[0084] (8) If the correlation is less than the threshold P c , then cut the branch and set the Score to 0
[0085] (9)else
[0086] (10) Record the associated values of this group of associated functions into the list, S.append(score), counter +1.
[0087] (11)end if
[0088] (12) end for
[0089] (13) Map the list S of record associations into a time series consisting of [0,1], where the score is not 0 and is mapped to 1.
[0090] (14) Calculate the DTW (Dynamic Time Warping) distance between two time series
[0091] (15) end for
[0092] (16) Construct an adjacency table, where the neighboring nodes are the association function, sort the nodes in the adjacency table in descending order, and traverse and prune the adjacency table based on the DTW threshold.
[0093] (17) if DTW < threshold
[0094] (18) Continue traversal
[0095] (19)else
[0096] (20) Disconnect the linked list, start a new traversal from the disconnected node, and update the dtw value on the node
[0097] (21)end if
[0098] (22) Optimize the combination of associated functions and convert them into function sets
[0099] (23) Taking the function set as the unit, record the arrival time of each function request under the function set and draw a cumulative histogram
[0100] (24) Calculate the coefficient of variation of the histogram.
[0101] (25) if CV is greater than the threshold, use the number of calls per minute N (N = {n1,...,n t}) and execution time (E={{e1,...,e n}}), train the LSTM model, train_LSTM.
[0102] (26) Use the LSTM model to predict the average arrival time and average execution time of function requests in the future.
[0103] (27) Calculate pre_warm from historical histogram h and keep_alive h The value of is combined with the prediction result of LSTM to calculate the final prediction result: pre_warm = α·CV·pre_warm h +(1-α·CV)·pre_warm lstm ;keep_alive=α·CV·keep_alive h +(1-α·CV)·keep_alive lstm .
[0104] (28)else
[0105] (29) Calculate pre_warm and keep_alive directly from the historical histogram.
[0106] (30)end if
[0107] (31) if function request hits warm start
[0108] (32) The current serverless computing function starts normally, start(f)
[0109] (33)else coldstart(f)
[0110] (34)end if
[0111] From the pseudo code description of the algorithm, we can see that lines 1 to 22 are mining related function sets. Lines 1 to 2 obtain historical data such as the number of calls and average execution time of serverless computing functions executed in the past time period.
[0112] . Lines 4 to 6 convert functions and the number of function calls per minute into matrices, and calculate the sparsity and size of the dynamic time window. Lines 7 to 12 calculate the correlation between functions in each dynamic time window and find the locally associated function group. Lines 13 to 15 calculate the correlation of candidate associated function groups in adjacent time domains. Lines 16 to 22 use the storage structure of the adjacency list to find the associated function set and perform data processing on the function set.
[0113] Lines 23 to 30 use the cumulative histogram to record the distribution of the function arrival time. Lines 24 to 30 use the coefficient of variation of the cumulative histogram to determine whether the IAT distribution of the function set is representative and adopt different prediction strategies. Lines 25 to 27 are cases where the distribution of the function set is not representative, that is, the warm-up time cannot be directly determined by the cumulative histogram. The LSTM model is used to predict the future function arrival time. The weighted combination of the distribution information of the cumulative histogram and the prediction result of LSTM is used to obtain the final warm-up keep-alive time. Lines 28 to 29 are cases where the distribution of the function set is representative, and the final warm-up keep-alive time is directly obtained from the cumulative histogram.
[0114] Lines 31 to 34, that is, if the function request hits the current keep-alive time period [pre_warm, keep_alive], it will directly warm start. If it does not hit, it will experience a cold start.
[0115] (35) The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings and specific embodiments. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all fall within the protection scope of the present invention.
[0116] (36) if CV is greater than the threshold, use the number of calls per minute N (N = {n1, ..., n t}) and execution time (E =
[0117] {{e1,...,e n}}), train the LSTM model, train_LSTM.
[0118] (37) Use the LSTM model to predict the average arrival time and average execution time of function requests in the future.
[0119] (38) Calculate pre_warm from historical histogram h and keep_alive h The value of is combined with the prediction result of LSTM to calculate the final prediction result: pre_warm = α·CV·pre_warm h +(1-α·CV)·pre_warm lstm ;keep_alive=α·CV·keep_alive h +(1-α·CV)·keep_alive lstm .
[0120] (39)else
[0121] (40) pre_warm and keep_alive are calculated directly from the historical histogram.
[0122] (41)end if
[0123] (42) if function request hits warm start
[0124] (43) The current serverless computing function starts normally, start(f)
[0125] (44)else coldstart(f)
[0126] (45)end if
[0127] From the pseudo code description of the algorithm, we can see that lines 1 to 22 are mining related function sets. Lines 1 to 2 obtain historical data such as the number of calls and average execution time of serverless computing functions executed in the past time period.
[0128] . Lines 4 to 6 convert functions and the number of function calls per minute into matrices, and calculate the sparsity and size of the dynamic time window. Lines 7 to 12 calculate the correlation between functions in each dynamic time window and find the locally associated function group. Lines 13 to 15 calculate the correlation of candidate associated function groups in adjacent time domains. Lines 16 to 22 use the storage structure of the adjacency list to find the associated function set and perform data processing on the function set.
[0129] Lines 23 to 30 use the cumulative histogram to record the distribution of the function arrival time. Lines 24 to 30 use the coefficient of variation of the cumulative histogram to determine whether the IAT distribution of the function set is representative and adopt different prediction strategies. Lines 25 to 27 are cases where the distribution of the function set is not representative, that is, the warm-up time cannot be directly determined by the cumulative histogram. The LSTM model is used to predict the future function arrival time. The weighted combination of the distribution information of the cumulative histogram and the prediction result of LSTM is used to obtain the final warm-up keep-alive time. Lines 28 to 29 are cases where the distribution of the function set is representative, and the final warm-up keep-alive time is directly obtained from the cumulative histogram.
[0130] Lines 31 to 34, that is, if the function request hits the current keep-alive time period [pre_warm, keep_alive], it will directly warm start. If it does not hit, it will experience a cold start.
[0131] (46) The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings and specific embodiments. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all fall within the protection scope of the present invention.
Claims
1. A cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment, characterized in that: The steps include: S1. Count the number of calls per minute for each serverless computing function in the past time period N (N = {n1,...,n t }), record the average execution time E (E = {e1, ..., en}) of the serverless computing function. S2. Convert the function and the number of function calls into a two-dimensional matrix, and determine the size of the dynamic time window T and the moving step d according to the sparsity of the matrix. S3. Map the functions in the window and the number of function calls to a completely undirected graph, calculate the correlation between the functions, and screen out function pairs or function combinations with local correlation through graph pruning. S4. Map the distribution of the local correlation function group in the time series into the form of a {0,1} time series, set a comparison threshold, and use the dynamic warping algorithm (DTW) to calculate the similarity dtw of different potential correlation function groups in adjacent times. S5. Use adjacency lists to store functions and function relationships. Sort functions in descending order according to relevance, reconstruct the adjacency list based on DTW traversal, obtain the final combination of associated functions and convert it into a function set. S6. Use the function set as the basic unit of the histogram preheating and keep-alive strategy, record the arrival time interval of each function in the function set, and draw an IAT (Inter-Arrival Time) histogram. The scheduler needs to analyze the distribution characteristics of the histogram to decide when to preheat in advance and how long to keep the instance alive after the function is executed. S7. In addition, the coefficient of variation of the cumulative histogram is calculated to determine whether the distribution of the cumulative histogram is directly representative. If the coefficient of variation is higher than the threshold, the histogram is considered representative, and the preheating and keeping alive percentage can be directly determined by the distribution of the cumulative histogram. If the coefficient of variation is lower than the threshold, the histogram is not directly representative, and it is necessary to combine the LSTM (long-term and short-term time series prediction algorithm to predict the preheating time and the keeping alive time, and fully consider the historical call situation and long-term call trend to calculate the final prediction result.
2. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 1, characterized in that: The S1 comprises the following steps: S1.
1. It is necessary to calculate the calling time T (T = {t1, ..., t n }) is organized into the number of calls to the serverless computing function in each consecutive minute N (N = {n1,...,n t }), S1.
2. When recording the average execution time E (E = {e1, ..., en}) of a serverless computing function, it is difficult to record the duration of each execution of the function in practice. You can record the number of calls every 30 seconds. i And these times i The minimum, maximum, and average execution time of each call.
3. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 1, characterized in that: The S2 comprises the following steps: S2.
1. Sparsity is represented by the number of non-zero elements in the matrix / the total number of elements in the matrix. S2.2, dynamically adjust the window size according to the sparsity, assuming that the range of window size W is [Win min ,Win max ], the formula is: W = Win min +(Win max -Win min )×h 稀疏度 .
4. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 1, characterized in that: The S3 comprises the following steps: S3.
1. A completely undirected graph of functions and function call mappings in the sliding window. Nodes represent functions, and edges represent the degree of association between functions. Taking function A and function B as an example, the weight on the edge is: p (a,b) =I A +I B / Num T (I A ≠0,I B ≠0), p (a,b) =NULL(I A =0||I B =0).
5. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 1, characterized in that: The S4 comprises the following steps: S4.
1. Traverse the adjacency list. If the dtw value is less than the specified threshold, continue traversing. If the dtw value exceeds the threshold, disconnect the node. Traverse the vertex, start a new traversal with the disconnection function as the new vertex, and build a new linked list. In addition, update the dtw value on the node.
6. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 1, characterized in that: The S5 comprises the following steps: S5.1 determines two windows by real-time statistics of the IAT histogram of the functions under each associated function set. IAT represents idle time, that is, the interval from the end of this call to the beginning of the next call. S5.2 determines the percentage of the preheating window and the keep-alive window based on the distribution of the histogram. The smaller the difference between the two windows, the better the preheating effect. Try to make the function call hit the second window.
7. The cold start optimization method based on function correlation mining and cumulative histogram strategy in a serverless computing environment according to claim 5, characterized in that: The S6 comprises the following steps: S6.1 According to the long-term and short-term time series prediction model, the call time T (T = {t1, ..., t n }) to predict the calling time Y of the serverless computing function in the future (Y={y i , ..., y n }) S6.2 determines whether the histogram can be directly divided into two windows by percentage by calculating the coefficient of variation of the histogram. When the coefficient of variation is greater than the threshold, for example, the application has just been deployed and there is not enough data to generate a histogram or the function IT is too discrete, the long-term and short-term time series prediction algorithm can be used. The coefficient of variation value is used as a coefficient to weight the long-term and short-term time series prediction results and the historical histogram distribution prediction results to calculate the final pre-warm value and keep-alive value.
Citation Information
Patent Citations
Cold start optimization method based on time domain convolutional network in server-free computing environment
CN114489940A
Container life cycle management method and device, container function calculation method and device and storage medium
CN114489947A
Function cold start optimization method of service perception-free computing system
CN119440666A