Container caching method and device, equipment, storage medium and program product
By introducing the concept of container temperature to dynamically adjust the caching strategy, the problem of insufficient consideration of container activity in existing technologies is solved, thereby improving system response speed and resource utilization efficiency.
Patent Information
- Application Number
- CN202511190389.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-22
- Publication Date
- 2025-12-12
AI Technical Summary
Existing container caching solutions fail to adequately consider the actual activity level of containers when faced with complex request patterns, resulting in highly active containers being prematurely phased out or inactive containers consuming excessive resources, thus affecting system response speed and user experience.
The concept of container temperature is introduced to characterize cache priority. The container temperature is dynamically adjusted by obtaining the container's decay temperature and temperature rise, and the caching strategy is determined based on the container temperature to ensure that the container temperature accurately reflects the activity level.
It significantly reduces the frequency of cold starts, improves the overall response speed of applications and user experience, and optimizes the utilization efficiency of cache resources.
Smart Images

Figure CN121116596A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of containerization technology, and more particularly to container caching methods, devices, storage media, and program products. Background Technology
[0002] Containerization is a software development and deployment methodology that packages an application and its dependencies, or a function and its dependencies, into a self-contained, lightweight, and portable container, ensuring consistent operation across different environments. In some use cases, frequent container creation and destruction may be necessary. For example, in server-insensitive computing scenarios, the application is decomposed into multiple independent functions. To provide a consistent execution environment, functions are launched on demand using containers. For instance, upon receiving a user's service request, if the request requires a specific function, a container for that function can be created to implement its functionality. After use, the container can be destroyed to release resources. However, frequent container creation and destruction can lead to cold start problems—creating and initializing a new container can be time-consuming, impacting response time and user experience. To mitigate the impact of cold starts, recently used containers can be cached. However, current container caching solutions have limitations when facing complex request patterns, failing to fully consider the actual activity level of containers, potentially leading to premature obsolescence of highly active containers or excessive resource consumption by inactive containers. Summary of the Invention
[0003] In view of the above, this specification provides a container caching method, apparatus, device, storage medium, and program product through one or more embodiments.
[0004] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0005] According to a first aspect of one or more embodiments of this specification, a container caching method is proposed, comprising:
[0006] Upon receiving a call request for the target container, if the target container is not the first container to be called, the current decayed container temperature of the target container is obtained. The decayed container temperature is obtained by decaying the container temperature of the target container after the last call. The container temperature of the target container is positively correlated with the cache priority of the target container.
[0007] Based on the current container temperature influencing factors of the target container, the amount of temperature rise caused by this call is determined, wherein the container temperature influencing factors are factors that affect the cache priority of the target container;
[0008] The temperature of the decaying container is increased according to the stated heating amount to obtain the container temperature of the target container after this call.
[0009] The caching strategy for the target container is determined based on the container temperature of the target container after this call.
[0010] According to a second aspect of the embodiments of this specification, a container caching device is provided, comprising:
[0011] The acquisition module is used to, upon receiving a call request for the target container, if the target container is not the first container to be called, acquire the current decayed container temperature of the target container. The decayed container temperature is obtained by decaying the container temperature of the target container after the last call, wherein the container temperature of the target container is positively correlated with the cache priority of the target container.
[0012] The temperature rise determination module is used to determine the temperature rise caused by this call based on the current container temperature influencing factors of the target container, wherein the container temperature influencing factors are factors that affect the cache priority of the target container;
[0013] The heating module is used to heat the temperature of the decaying container according to the heating amount, so as to obtain the container temperature of the target container after this call;
[0014] The caching module is used to determine the caching strategy of the target container based on the container temperature of the target container after this call.
[0015] According to a third aspect of the embodiments of this specification, an electronic device is provided, comprising:
[0016] processor;
[0017] Memory used to store processor-executable instructions;
[0018] Wherein, when the processor executes the executable instructions, it is used to implement the method described in the first aspect.
[0019] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in the first aspect.
[0020] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.
[0021] As can be seen from the above embodiments, this specification introduces container temperature to characterize the container's cache priority, thereby quantifying the container cache priority. Upon receiving a call request for the target container, if it is determined that the target container is not being called for the first time, the attenuated container temperature obtained by attenuating the target container's temperature after the previous call can be determined first. Based on the factors affecting the target container's current container temperature, the amount of temperature increase caused by this call can be determined, and the attenuated container temperature can be increased according to this increase to obtain the target container's temperature after this call. Then, the caching strategy for the target container is determined based on the target container's temperature after this call. After a container is called, its temperature will rise, and during periods when it is not called, its temperature will gradually decrease, allowing the container temperature to more accurately reflect the actual activity of the container. Therefore, the container caching strategy determined based on this container temperature can significantly reduce the frequency of cold starts, improving the overall response speed of the application and the user experience. Attached Figure Description
[0022] Figure 1 This is an exemplary embodiment of an application scenario diagram.
[0023] Figure 2 This is a flowchart of a container caching method provided in an exemplary embodiment.
[0024] Figure 3 This is a schematic diagram illustrating a change in container temperature provided in an exemplary embodiment.
[0025] Figure 4 This is an exemplary embodiment of the process for caching a target container cache.
[0026] Figure 5 This is a schematic diagram of a container caching method provided in an exemplary embodiment.
[0027] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an exemplary embodiment.
[0028] Figure 7 This is a schematic diagram of the structure of a container caching device provided in an exemplary embodiment. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0030] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0031] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. Containerization technology is a lightweight virtualization technology that can package applications and their dependencies (such as libraries, configuration files, etc.), or functions and their dependencies, into an independent "container," enabling consistent operation of applications or functions in different environments. In some use cases, it may be necessary to frequently create and destroy containers.
[0032] For example, consider serverless computing, also known as serverless computing, a cloud computing execution model that allows developers to decompose applications into independent functions or microservices without worrying about the management, configuration, and maintenance of the underlying servers. In this model, cloud service providers are responsible for dynamically allocating and managing server resources, while developers only need to focus on writing code and responding to event triggers on demand, thus simplifying the backend development process. In this scenario, to provide a consistent execution environment, functions are typically started on demand using containers. For instance, after receiving a user's service request, if the request requires a certain function, a container for that function can be created to implement the function's functionality. After use, the container can be destroyed to release resources. Considering that creating a new container and initializing it (i.e., a cold start) is time-consuming, affecting response time and user experience, to reduce the impact of cold starts, recently used containers can be cached. When a request for the same container is received again, it can be directly retrieved from the cache and used to quickly restore the state and shorten response time.
[0033] Due to limited cache resources, only a portion of containers can be cached during system operation. Related technologies typically use caching strategies such as FIFO (First In, First Out), LRU (Least Recently Used), and TTL (Time To Live) to cache containers. These caching schemes have limitations when facing complex request patterns, failing to fully consider the actual activity level of containers. This may lead to highly active containers being prematurely evicted or inactive containers consuming excessive resources. Some technologies can determine container cache priority based on factors such as the number of calls and cold start duration. However, this caching approach has limitations in scenarios with sudden load spikes. Specifically, containers with high-frequency calls in short periods may continuously occupy the cache, while containers with long-interval, periodic calls may be incorrectly evicted and unable to re-enter the cache, resulting in ineffective use of cache resources.
[0034] For example, suppose there are containers A and B. Container A is a container that is called frequently in short intervals, while container B is a container that is called periodically in long intervals. Assuming we take 1 hour as the measurement dimension, container A is called 100 times in the first 5 minutes of that hour and is not called again after that. Container B, on the other hand, is called once every 5 minutes. Because container A is called a large number of times, its call count will be much higher than that of container B in the next hour. As a result, container A's cache priority will be higher than that of container B for a period of time. This causes container A to continuously occupy the cache, while container B cannot enter the cache. Consequently, container B needs to be repeatedly created and destroyed, resulting in a high frequency of cold starts and a long overall system response time, which seriously affects the user experience.
[0035] Based on this, the embodiments of this specification provide a container caching method. This method introduces the concept of container temperature to characterize the caching priority of the container, and the container temperature can be adaptively adjusted based on the container's call status. For example, after the container is called, its temperature will rise, and during the period when it is not called, its temperature will gradually decrease, so that the container temperature can more accurately reflect the actual activity of the container. As a result, the container caching strategy determined based on the container temperature can also significantly reduce the frequency of cold starts, improve the overall response speed of the application and the user experience.
[0036] In the embodiments of this specification, "container" refers to an actual running container instance that can be used to process user requests or perform tasks. This container instance can run functions, microservices, or applications, etc., and can be specifically configured based on actual needs.
[0037] like Figure 1 The diagram illustrates an application scenario for one or more embodiments of this specification. For example, a developer creates an online image processing application. This application relies on cloud computing resources provided by a cloud service provider to perform image processing functions. The developer can decompose the application into multiple independent functions, such as cropping, compressing, and adding watermarks to images. Users can send image processing requests to the cloud server via a client. Upon receiving the request, the cloud server can determine that function A needs to be called to crop the image. The cloud server can then check if container A corresponding to function A exists in its cache list. If it does, container A can be used for image cropping; otherwise, container A needs to be recreated and initialized to complete the cropping. Since the cloud server may contain many applications, involving a large number of containers, and the cloud server's caching resources are limited, it is necessary to determine which containers should be cached first based on their activity level and cold start overhead.
[0038] The container caching method described in this specification can be executed by cloud servers, server clusters, etc.
[0039] like Figure 2 As shown, the container caching method may include the following steps:
[0040] S202. After receiving the call request for the target container, if the target container is not the first container to be called, the current decayed container temperature of the target container is obtained. The decayed container temperature is obtained by decaying the container temperature of the target container after the last call. The container temperature of the target container is positively correlated with the cache priority of the target container.
[0041] In step S202, after receiving the call request for the target container, it can be determined whether the target container is the first container to be called. The target container can be a container required for a specific function that needs to be implemented. For example, if the target container runs function A that implements a certain function, upon receiving a user's service request and determining that the service request requires function A, the call request for the target container can be triggered.
[0042] If the target container is determined to be a previously invoked container (i.e., it has been called before), then the decaying container temperature at the current moment can be obtained. In some scenarios, to quickly determine whether a container has been called, a historical call record table can be maintained. This table records information about called containers. Upon receiving a call request for the target container, the historical call record table can be queried to determine if the container has been called before. For example, each function's corresponding container can carry a container ID. The historical call record table can record the IDs of already called containers, and then the presence of that container ID in the historical call record table can be checked to determine if the container has been called before.
[0043] This specification introduces the concept of container temperature to characterize the cache priority of a container in its embodiments. The cache priority of a container is affected by factors such as container activity and cold start overhead. For example, higher container activity and longer cold start times result in higher cache priority. To quantify container cache priority, container temperature can be used to characterize it; a higher container temperature indicates a higher cache priority.
[0044] Considering that without temperature decay, a container's temperature would remain at the value since the last call, failing to reflect its recent activity—for example, a container frequently called an hour ago but hasn't been called since, yet its temperature remains high—this leads to ineffective use of cached resources, preventing containers that truly need caching from entering the cache. To allow container temperature to more accurately reflect a container's actual activity, its temperature can be decayed during periods when the container is not called. Therefore, if the target container is determined to be a container that has been called before, its temperature can be decayed from the time of its last call to the current call, yielding the decayed container temperature at the current moment, i.e., the container temperature before this call.
[0045] The timing of container temperature decay can be flexibly set based on actual needs. For example, in some scenarios, to quickly determine the decayed container temperature of the target container at the current moment and improve caching efficiency, the container temperature of the target container can be decayed at certain time intervals to obtain the decayed container temperature of the target container at different time points. After receiving a call request from the target container, the decayed container temperature corresponding to the time point closest to the call request time can be used as the decayed container temperature of the target container at the current moment. In some scenarios, considering that frequently calculating the decayed container temperature of the target container is computationally expensive, in order to save computational resources, the decayed container temperature of the target container at the current moment can also be calculated temporarily after receiving a call request from the target container.
[0046] S204. Based on the container temperature influencing factors of the target container, determine the amount of temperature rise caused by this call, wherein the container temperature influencing factors are factors that affect the cache priority of the target container;
[0047] In step S204, considering that the container has been invoked, it indicates that its recent activity level is relatively high. Therefore, after each invocation of the container, a temperature increase process can be performed. Specifically, the amount of temperature increase caused by different invocations can be dynamically adjusted based on the container's current state, so that the determined container temperature can more accurately reflect its recent activity level. Therefore, the amount of temperature increase caused by this invocation can be determined based on the factors influencing the target container's current container temperature. These factors can be various factors that affect the container cache priority, such as factors characterizing container activity (e.g., invocation frequency, number of invocations, resource utilization), or factors characterizing the container's cold start overhead (e.g., cold start duration, amount of resources consumed during cold start).
[0048] S206. The temperature of the decay container is increased according to the stated heating amount to obtain the container temperature of the target container after this call.
[0049] In step S206, the temperature of the decaying container can be increased according to the heating amount to obtain the container temperature of the target container after this call. That is, the decaying container temperature is added to the heating amount to obtain the container temperature of the target container after this call.
[0050] S208. Determine the caching strategy of the target container based on the container temperature of the target container after this call.
[0051] In step S208, after obtaining the container temperature of the target container after this call, the caching strategy for the target container can be determined based on this container temperature. This caching strategy includes whether to continue caching the target container if it is already stored in the cache, and whether to cache it if it is not stored in the cache, etc.
[0052] In some embodiments, the container caching method can be applied to server-insensitive computing scenarios, where the target container is a container for functions in an application.
[0053] In some instances, if the target container is the first container to be called, the container temperature after this call can be directly set to a preset temperature. The preset temperature can be an initial temperature assigned to the container, which can be increased based on the initial temperature when the container is called again.
[0054] To track the historical calls of containers, a historical call record table can be maintained to record the call information of containers that have been invoked. This call information can include various details describing the container's historical calls, such as the last call time, the container temperature after the last call, the total number of calls, the average call interval, and so on.
[0055] For example, in some embodiments, the historical call record table can record call information for all called containers. In some embodiments, considering that the call information of containers stored in the cache is also stored in the cache, to avoid duplicate storage and resource waste, the historical call record table can be used only to record call information for containers that have been called but not cached. In this case, when determining whether the target container is the first container called, it can be checked whether the target container is stored in the cache and whether the call information of the target container is recorded in the historical call record table. If the target container is not found in the cache and the call information of the target container is not found in the historical call record table, then the target container is determined to be the first container called.
[0056] In some embodiments, to reduce the problem of containers frequently invoked in short periods occupying the cache for extended periods, while periodically invoked containers are mistakenly evicted and unable to re-enter the cache for a long time, the call count of containers that are frequently invoked in a short period but not subsequently invoked for a long time can be reset to 1 (i.e., the container is treated as a first-time invoked container). For example, after each container is invoked, its call count can be updated. When updating the call count, it can be determined whether the interval between the current call time and the previous call time is greater than a target duration. If it is greater than the target duration, the call count is reset to 1; if it is less than the target duration, the call count is incremented by 1. The target duration can be determined based on the average call interval of the target container. If the target duration is much greater than the average call interval, it indicates that the container is a frequently invoked container in short periods. For example, the target duration can be set to twice the average call interval of the target container.
[0057] When determining whether a target container is being called for the first time, the system checks whether the target container is stored in the cache. If it is not stored, the system further checks whether the target container's call information is recorded in the historical call record table. If the target container's call information is found in the historical call record table, the system determines whether the interval between the current call time and the previous call time is greater than the target duration. If so, the target container is determined to be the first container to be called; otherwise, the target container is determined to be a container that is not being called for the first time.
[0058] By comparing the time interval between the current call and the previous call with the target duration set based on the average call interval, containers that have been idle for a long time after being called frequently in a short period of time can be accurately identified, and the call count of such containers can be reset. This can prevent such containers from occupying cache resources for a long time due to the "residual heat" of historical high-frequency calls, which would lead to the invalid occupation of cache space. This can improve the utilization efficiency of cache resources, tilt cache resources toward containers that really need them (such as containers that are called periodically), and optimize the overall response speed and performance of the system.
[0059] In some embodiments, when decaying the container temperature of the target container after the last call to obtain the decayed temperature of the target container at the current moment, the container temperature of the target container after the last call can be obtained, and then the interval between the current call time and the previous call time can be determined. Based on this interval, the temperature decay amount of the target container can be determined. Then, the container temperature after the last call is decayed according to this temperature decay amount to obtain the decayed container temperature. For example, generally speaking, the longer the interval, the greater the temperature decay amount.
[0060] In some embodiments, considering that a container may receive multiple call requests consecutively within a short period, immediately reducing its temperature after each call request and heating the container could require repeated heating and cooling calculations, resulting in a large and cumbersome computational load. Therefore, to reduce the computational load, a holding period can be set. After the container is called and heated, its temperature remains at the increased temperature for the holding period without any reduction. Temperature reduction only begins after the holding period has elapsed. Therefore, when determining the temperature reduction of a target container based on the interval between the current and previous call times, it can be first determined whether the interval is greater than a preset holding period. If the interval is less than or equal to the preset holding period, the temperature reduction is 0, meaning the container temperature will not decrease during the holding period. For example, as... Figure 3 As shown, the container temperature after the last call is T0. During the heat preservation time, its temperature remains at T0. After the heat preservation time, its temperature begins to decay until the current call occurs. Assuming that the container temperature decays by △T1 during this process, its current decay temperature is T0-△T1. The temperature rise caused by this call is △T2. Therefore, the container temperature after this call is T0-△T1+△T2.
[0061] If the interval is longer than the preset heat preservation time, the temperature of the target container can be attenuated. The specific attenuation method can be varied; for example, the temperature can be attenuated according to a certain attenuation coefficient, which can be fixed or dynamically changed. For instance, the container temperature can be attenuated at a uniform rate or at a variable rate.
[0062] In some embodiments, the actual cooling scenario of the liquid can be simulated to decay the container temperature of the target container after the last call. For example, the temperature decay amount is directly related to the actual decay time and the difference between the container temperature of the target container after the last call and the preset ambient temperature. The actual decay time is the difference between the interval time and the holding time; generally, the longer the actual decay time, the greater the temperature decay. Considering that the closer the container temperature of the target container is to the ambient temperature, the slower its cooling rate tends to be, and the greater the difference between the container temperature of the target container and the ambient temperature, the faster its cooling rate, the temperature decay amount can be determined based on the difference between the container temperature of the target container after the last call and the preset ambient temperature. The larger the difference, the greater the temperature decay amount, and vice versa.
[0063] For example, in some embodiments, the container temperature of the target container can be decayed with reference to Newton's law of cooling. When the target container is heated, its container temperature will remain constant during the heat preservation period, and then begin to decrease. The rate of temperature decrease decreases as it approaches the ambient temperature. For example, the decay temperature of the target container at the current moment can be determined based on the following formula (1):
[0064] Tt=(T0-Tenv)×e^(-kt)+Tenv formula (1)
[0065] Where Tt is the current decaying container temperature of the target container, T0 is the container temperature of the target container after the last call, Tenv is the ambient temperature, which is a preset constant, t is the decay duration, and k is the cooling coefficient, which is a preset constant.
[0066] In some embodiments, when decaying the container temperature, the amount of temperature decay can be determined based on factors affecting the container temperature at the current time. For example, the more active the container is, the smaller its decay amount, and vice versa. Therefore, when determining the temperature decay amount of the target container based on the interval between the current call time and the previous call time, the temperature decay amount can also be determined by combining the factors affecting the target container temperature at the current moment with the interval.
[0067] In some embodiments, factors affecting container temperature include one or more of the following: factors related to container activity and factors related to container cold start. Factors related to container activity include various factors characterizing container activity, such as the number of calls, call frequency, average call interval, resource utilization, etc. Factors related to container cold start include various factors characterizing cold start overhead, such as cold start duration and cold start resource overhead.
[0068] In some embodiments, factors related to container activity include one or more of the following: the call frequency of the target container, the resource utilization of the target container, and the factors related to container cold start include the cold start duration of the target container.
[0069] The call frequency reflects the activity level of the calls received by the container. Generally, a higher call frequency indicates a more active container, making it more worthy of caching; in other words, the container temperature should be higher. The call frequency can be calculated as the reciprocal of the target container's average call interval.
[0070] The cold start time of a target container refers to the time it takes for the target container to be created and complete initialization. The cold start time reflects the startup overhead of the container. Caching containers with longer cold start times can reduce the cold start time in the future, improve the overall system response speed and user experience. Therefore, the longer the cold start time of a target container, the more it should be cached, and consequently, its container temperature should be higher.
[0071] The resource utilization of a target container refers to how well it utilizes resources such as CPU and memory. Containers with higher resource utilization usually mean they are performing more complex tasks or processing more requests, and are therefore more likely to be invoked again in the near future. Caching containers with high resource utilization can reduce the number of future cold starts, improve system responsiveness and user experience. Therefore, containers with higher resource utilization should be cached, and their container temperature should be higher.
[0072] In some embodiments, resource utilization includes CPU utilization and memory utilization. CPU utilization can be taken as the ratio of the container's CPU usage in the previous frame to the amount of CPU resources allocated by the system to a single task. The CPU usage in the previous frame refers to the amount of CPU resources actually used by the container in the most recent measurement period. This measurement period can be several seconds, minutes, or longer, and can be flexibly set based on actual needs. The amount of CPU resources allocated by the system to a single task refers to the upper limit of CPU resources allocated by the system to each task (i.e., container). This upper limit can be fixed or dynamically adjusted according to the task's needs and the system load.
[0073] Memory utilization can be calculated as the ratio of the container's memory usage in the previous frame to its basic resource allocation. The previous frame's memory usage refers to the actual amount of memory resources used by the container in the most recent measurement period. This measurement period can be several seconds, minutes, or longer, and can be flexibly set based on actual needs. The container's basic resource allocation refers to the initial amount of memory resources allocated to the container when it starts. This amount is typically pre-allocated by a container orchestration system (such as Kubernetes) or container runtime (such as Docker) based on the container's configuration and requirements. It represents the minimum amount of memory resources required for the container to operate normally.
[0074] In related technologies, determining container activity typically relies on common static metrics (such as call timestamps, call frequency, cold start duration, and container memory usage). During peak traffic periods, these metrics tend to prioritize short-term, high-frequency call containers, leading to the erroneous removal of periodic containers. This specification, in addition to incorporating these static metrics into the factors affecting container temperature, also considers container resource utilization. Containers with high resource utilization are likely executing more processing requests or more complex tasks, and are more likely to be called in the future. Conversely, containers with low resource utilization may be redundant or idle and should be removed as early as possible. By combining resource utilization with container temperature determination, the final determined container temperature more accurately reflects the actual activity of the container.
[0075] In some embodiments, the temperature increase is directly related to the call frequency of the target container, the resource utilization of the target container, and the cold start duration of the target container. A higher call frequency, higher resource utilization, and longer cold start duration indicate that the target container is currently more active or has higher caching value, making it more worthy of caching. Therefore, the temperature increase can be set higher, resulting in a higher container temperature after the temperature increase and a higher caching priority.
[0076] In some embodiments, the temperature rise caused by this call can be calculated based on formula (2):
[0077] δT=f×mem×cpu×c×cold_start_time
[0078] Where δT is the temperature rise, f is the call frequency, mem is the memory utilization, cpu is the CPU utilization, cold_start_time is the cold start duration, and c is the unit temperature, i.e., the value corresponding to one temperature, which can be customized by the user, for example, it can be set to 1.
[0079] In some embodiments, the temperature decay amount is negatively correlated with the call frequency of the target container, the resource utilization of the target container, and the cold start duration of the target container. A higher call frequency, higher resource utilization, and longer cold start duration indicate that the target container is currently more active or has higher caching value, making it more worthy of caching. Therefore, the temperature decay amount can be set smaller so that the container temperature remains high after decay, resulting in a higher caching priority.
[0080] In some embodiments, such as Figure 4As shown, when determining the caching strategy for a target container based on the container temperature after the current call, we can first check if the target container is currently stored in the cache. If the target container is found in the cache, we update the call information of the target container recorded in the cache. For example, we can update the target container's last call time, container temperature after the last call, call frequency, average call interval, etc.
[0081] If the target container is not found in the cache, it is determined whether the container temperature of the target container after this call is greater than or equal to a preset lower limit temperature, where the lower limit temperature is the lowest temperature at which a cached container is allowed. If the container temperature of the target container after this call is less than the lower limit temperature, the target container is cold-started, and after the corresponding task is completed using the target container, it is destroyed. If the container temperature of the target container after this call is greater than the lower limit temperature, it is further determined whether to cache the target container based on the current available storage space in the cache, the current container temperature of each container already stored in the cache, and the container temperature of the target container after this call. For any container in the cache, its current container temperature is the temperature obtained after attenuating the container temperature after the last call.
[0082] In some embodiments, if the target container's temperature after the current call is greater than or equal to a preset lower limit temperature, and if the current available storage space in the cache is greater than the storage space required to store the target container, the target container can be directly stored in the cache. In some embodiments, if the current available storage space in the cache is less than the storage space required to store the target container, it can be determined whether the target container's temperature after the current call is higher than the temperature of a specified container in the cache, where the specified container is the container with the lowest temperature in the cache. If yes, the specified container in the cache is replaced with the target container; otherwise, the target container is destroyed after performing the corresponding task using the target container.
[0083] In some embodiments, for containers that have been invoked but are not stored in the cache, their invocation information can be recorded through a historical invocation record table. This facilitates the differentiation between containers that are being invoked for the first time and those that are not, and allows for the calculation of the container's temperature after the invocation using different temperature calculation models. Therefore, after destroying the target container, the invocation information of the target container in the historical invocation record table can be updated. The invocation information can be one or more of the following: the last invocation time, the temperature after the last invocation, the total number of invocations, and the average invocation time interval.
[0084] In some embodiments, if the target container is not found in the cache and the call information of the target container is not found in the historical call record table, it means that the target container has only been called once. In order to avoid the container being called only once polluting the cache, the container that has only been called once can not be cached first. Instead, a new record can be added to the historical call record table to record the call information of the target container.
[0085] The container caching method described in this specification is illustrated below with a specific example. Figure 5 The diagram shown is a schematic representation of a container caching method according to an embodiment of this specification. The processing flow of a worker node in a cloud server is specifically illustrated as an example, including the following steps:
[0086] ① When a function request arrives at a worker node, it first accesses the cache to check if the corresponding target container exists. If the corresponding container already exists in the cache, the relevant information is updated, including: the timestamp of the last call, the temperature since the last call, the total number of calls, and the average call interval. Simultaneously, based on the success or failure of the lookup, the number of cache hits and misses is recorded for use in calculating the node's cache hit rate at the end.
[0087] ② If the target container corresponding to the function does not exist in the current cache, the historical call record table is accessed to determine if the target container has a historical call history, and the corresponding data is recorded. Specifically, if the historical call record table contains a record for the container, the time interval between the current call and the last call is calculated based on the record. If it exceeds twice the average call interval for the container, the current call is considered the first call. Based on this, the container temperature of the target container can be calculated: if it is the first call, the container temperature is the preset temperature and recorded in the historical call record table, and then a cold start is performed directly; if it is not the first call, the container temperature after this call is calculated based on the relevant information in the historical call record table. Finally, the relevant information in the historical call record table is updated, including: the last call time, the container temperature after the last call, the total number of calls, and the average call interval.
[0088] ③ If there is no record of the target container in the historical call record table, it means that the target container has only been called once. In order to avoid the container being called only once from polluting the cache, we can ignore caching the container for now, directly add a call record of the target container in the historical call record table, and then cold start the target container.
[0089] ④ If the cache is not full, and the target container has not been called only once (the container has a record in the historical call record table or the container exists in the cache), then the target container is directly added to the cache and its relevant information is recorded.
[0090] ⑤ If the cache is full, calculate the temperature of all containers in the cache after decay over time, and compare the temperature of the target container after this call with the lowest temperature of all containers in the cache after decay.
[0091] ⑥ If the former is higher than the latter, remove the container with the lowest current temperature from the cache and cache the target container.
[0092] ⑦ If the former is lower than the latter, only the record of the target container in the historical call record table is updated, and the cache queue does not need to be changed.
[0093] ⑧ If the cache is full, but the target container still needs to be cached, remove the container with the lowest current temperature from the cache. Record the information of the removed container in the cache to the historical call record table, remove the target container information record from the historical call record table, and update the cache with this record as the information of the newly added target container.
[0094] ⑨ If a container is not in the cache (when the container is removed from the cache or when the current container temperature is lower than the lowest temperature in the cache), its data is recorded in the historical call record table.
[0095] ⑩ If the corresponding container already exists in the cache, update the relevant information recorded, which mainly includes: the last call time (that is, the current time), the temperature after the last call, the total number of calls, and the average call interval, which are used for container temperature calculation.
[0096] The embodiments in this specification introduce a container temperature and its decay model, which can more accurately reflect the active state of the container and adjust the container retention time in the cache accordingly, significantly reducing cold start latency and improving the system's cost-effectiveness.
[0097] The various technical features in the above embodiments can be combined arbitrarily, as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, the arbitrary combination of various technical features in the above embodiments is also within the scope of this specification.
[0098] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0099] Figure 6 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 6As shown, device 600 mainly consists of a communication interface 602, a user interface 606, a processor 606, and a data storage 608. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 610. The communication interface 602 enables device 600 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 602 may include a chipset and antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 602 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 602 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 602 may also include multiple physical communication interfaces, such as Wi-Fi, Bluetooth, and wide-area wireless interfaces.
[0100] User interface 606 includes receiving user input and providing output to the user. Therefore, user interface 606 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 606 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 606 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 600 may support remote access from other devices via communication interface 602 or another physical interface (not shown). User interface 606 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 606 may also be configured as a display device for rendering or displaying text fragments.
[0101] Processor 606 may contain one or more general-purpose processors and / or special-purpose processors.
[0102] Data storage 608 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 606. Data storage 608 may include removable and non-removable components.
[0103] Processor 606 is capable of executing program instructions 618 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 608 to perform the various functions described herein. Data storage 608 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 600, enable device 600 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 618 by processor 606 may result in processor 606 using data 612.
[0104] For example, program instructions 618 may include an operating system 622 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 600 and one or more application programs 620 (e.g., a browser, social application, or game application). Similarly, data 612 may include operating system data 616 and application data 616. Operating system data 616 is primarily accessible to the operating system 622, while application data 616 is primarily accessible to one or more application programs 620. Application data 616 may reside in a file system visible or hidden from the user of device 600.
[0105] Application 620 can communicate with operating system 622 through one or more application programming interfaces (APIs). These APIs help application 620 read and / or write application data 616, transmit or receive information via communication interface 602, receive or display information on user interface 606, etc.
[0106] In some terminology, application 620 may be simply referred to as "app". Furthermore, application 620 can be downloaded to device 600 through one or more online app stores or app markets. However, applications can also be installed on device 600 in other ways, such as through a web browser or a physical interface on device 600 (e.g., a USB port).
[0107] Please refer to Figure 7 Container caching devices can be applied to, for example, Figure 6 The device shown implements the technical solution of this specification. The container caching device 70 may include:
[0108] The acquisition module 72 is used to, upon receiving a call request for the target container, if the target container is not the first container to be called, acquire the current decayed container temperature of the target container. The decayed container temperature is obtained by decaying the container temperature of the target container after the last call. The container temperature of the target container is positively correlated with the cache priority of the target container.
[0109] The temperature rise determination module 74 is used to determine the temperature rise caused by this call based on the current container temperature influencing factors of the target container, wherein the container temperature influencing factors are factors that affect the cache priority of the target container;
[0110] The heating module 76 is used to heat the temperature of the decaying container according to the heating amount, so as to obtain the container temperature of the target container after this call.
[0111] The caching module 78 is used to determine the caching strategy of the target container based on the container temperature of the target container after this call.
[0112] In some embodiments, if the target container is the first container to be invoked, the container temperature of the target container after this invocation is a preset temperature.
[0113] In some embodiments, if the target container is not found in the cache and the call information of the target container is not found in the historical call record table, then the target container is determined to be the container being called for the first time; or
[0114] If the call information of the target container is found in the historical call record table, and the interval between the current call time and the previous call time of the target container is longer than the target duration, then the target container is determined to be the container being called for the first time. The target duration is determined based on the average call interval of the target container.
[0115] The historical call record table is used to record call information of containers that have been called but not cached.
[0116] In some embodiments, the attenuation of the container temperature is obtained by attenuating the container temperature of the target container after the last call, including:
[0117] Obtain the container temperature of the target container since the last call;
[0118] The temperature decay of the target container is determined based on the interval between the current call time and the previous call time.
[0119] The temperature of the target container after the last call is reduced according to the stated temperature reduction amount to obtain the reduced container temperature.
[0120] In some embodiments, determining the temperature decay of the target container based on the interval between the current call time and the previous call time includes:
[0121] If the interval between the current and previous calls of the target container is less than or equal to a preset insulation duration, the temperature decay is 0; if the interval between the current and previous calls of the target container is greater than the preset insulation duration, the temperature decay is positively correlated with the actual decay duration and the difference between the container temperature of the target container after the previous call and the preset ambient temperature, wherein the actual decay duration is the difference between the interval duration and the insulation duration; and / or
[0122] The temperature decay amount is determined based on the interval between the current call time and the previous call time of the target container, as well as the factors affecting the container temperature.
[0123] In some embodiments, the factors affecting container temperature include: factors characterizing container activity and / or factors characterizing container cold start overhead.
[0124] In some embodiments, the factors characterizing container activity include one or more of the following: the call frequency of the target container, the resource utilization rate of the target container, and the factors characterizing container cold start overhead include the cold start duration of the target container; the amount of temperature rise is positively correlated with the call frequency of the target container, the resource utilization rate of the target container, and the cold start duration of the target container.
[0125] and / or
[0126] The factors characterizing container activity include one or more of the following: the call frequency of the target container, the resource utilization rate of the target container, and the factors characterizing container cold start overhead include the cold start duration of the target container; the temperature decay is negatively correlated with the call frequency of the target container, the resource utilization rate of the target container, and the cold start duration of the target container.
[0127] In some embodiments, the caching module is used to determine the caching strategy of the target container based on the container temperature after the current call, specifically for:
[0128] If the target container is found in the cache, the call information of the target container recorded in the cache is updated;
[0129] If the target container is not found in the cache, it is determined whether the container temperature after this call is greater than or equal to a preset lower limit temperature, wherein the lower limit temperature is the lowest temperature that the cached container is allowed to have.
[0130] If not, the target container is destroyed after the target task is performed using the target container;
[0131] If so, the decision to cache the target container is based on the current available storage space of the cache, the current container temperature of each container already stored in the cache, and the container temperature of the target container after this call. The current container temperature of each container already stored in the cache is obtained by attenuating the container temperature of the container after the last call.
[0132] In some embodiments, the caching module is configured to determine whether to cache the target container based on the currently available storage space in the cache, the current container temperature of each container already stored in the cache, and the container temperature of the target container after this call, specifically configured to:
[0133] If the available storage space in the cache is greater than the storage space required to store the target container, then the target container is stored in the cache.
[0134] If the available storage space in the cache is less than the storage space required to store the target container, then it is determined whether the container temperature of the target container after this call is higher than the container temperature of a specified container in the cache, where the specified container is the container with the lowest container temperature in the cache.
[0135] If so, then the specified container in the cache is replaced with the target container;
[0136] If not, then the target container is destroyed after the target task is executed using the target container.
[0137] In some embodiments, after destroying the target container, the device is further configured to:
[0138] Update the call information of the target container in the historical call record table, wherein the historical call record table is used to record the call information of containers that have been called but not cached.
[0139] In some embodiments, the call information includes one or more of the following: the last call time, the temperature after the last call, the total number of calls, and the average call interval.
[0140] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0141] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0142] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0143] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0144] What those skilled in the art will understand is:
[0145] In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.
[0146] In this specification, “a,” “an,” and “the” do not specifically refer to the singular, but may also include the plural.
[0147] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0148] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0149] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0150] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.
[0151] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.
Claims
1. A container caching method, comprising: after receiving a calling request of a target container, if the target container is a non-first-time-called container, obtaining a current decay container temperature of the target container, the current decay container temperature being obtained by decaying a container temperature of the target container after a last time calling, wherein the container temperature of the target container is positively correlated with a caching priority of the target container; determining a temperature rising amount caused by the current calling based on a current container temperature influencing factor of the target container, wherein the container temperature influencing factor is a factor influencing the caching priority of the target container; performing a temperature rising process on the decay container temperature according to the temperature rising amount, to obtain a container temperature of the target container after the current calling; determining a caching strategy of the target container based on the container temperature of the target container after the current calling. 2.The method of claim 1, wherein if the target container is a first-time-called container, the container temperature of the target container after the current calling is a preset temperature. 3.The method of claim 2, wherein if the target container is determined to be the first-time-called container, the target container is not found in a cache, and calling information of the target container is not found in a historical calling record table; or the target time length is determined based on an average calling time interval of the target container. If the calling information of the target container is found in the historical calling record table, and the interval between the current calling time and the last calling time of the target container is greater than a target interval, the target container is determined as a container that is called for the first time, wherein, The historical calling record table is used to record calling information of containers that have been called but not cached. 4.The method of claim 1, wherein the decay container temperature is obtained by decaying the container temperature of the target container after the last time calling, comprising: obtaining the container temperature of the target container after the last time calling; determining a temperature decay amount of the target container based on an interval time length between a current calling time and a last calling time of the target container; performing a decay process on the container temperature of the target container after the last time calling according to the temperature decay amount, to obtain the decay container temperature. 5.The method of claim 1, wherein the temperature decay amount of the target container is determined based on the interval time length between the current calling time and the last calling time of the target container, comprising: if the interval time length between the current calling time and the last calling time of the target container is less than or equal to a preset holding time length, the temperature decay amount is 0; if the interval time length between the current calling time and the last calling time of the target container is greater than the preset holding time length, the temperature decay amount is positively correlated with an actual decay time length and a difference between the container temperature of the target container after the last time calling and a preset environment temperature, wherein the actual decay time length is a difference between the interval time length and the holding time length; and / or the temperature decay amount is determined based on the interval time length between the current calling time and the last calling time of the target container and the container temperature influencing factor. factors representing container activity and / or factors representing container cold start overhead.
6. The method of claim 1 or 5, the container temperature influencing factor comprising: 7. The method of claim 6, wherein the factor indicative of the container activity level comprises one or more of a call frequency of the target container, a resource utilization of the target container, and the factor indicative of the container cold start overhead comprises a cold start duration of the target container; and wherein the warming-up amount is positively correlated with the call frequency of the target container, the resource utilization of the target container, and the cold start duration of the target container. and / or the factor indicative of the container activity level comprises one or more of a call frequency of the target container, a resource utilization of the target container, and the factor indicative of the container cold start overhead comprises a cold start duration of the target container; and wherein the temperature decay amount is negatively correlated with the call frequency of the target container, the resource utilization of the target container, and the cold start duration of the target container.
8. The method of claim 1, wherein, determining the cache policy of the target container based on the container temperature after the current call, comprises: updating the call information of the target container recorded in the cache if the target container is found in the cache; determining whether the container temperature after the current call is greater than or equal to a preset lower limit temperature if the target container is not found in the cache, wherein the lower limit temperature is the lowest temperature of the container allowed to be cached; destroying the target container after executing the target task by using the target container if the container temperature after the current call is not greater than or equal to the preset lower limit temperature; determining whether to cache the target container based on the current available storage space of the cache, the current container temperatures of the containers already stored in the cache, and the container temperature after the current call of the target container if the container temperature after the current call is greater than or equal to the preset lower limit temperature, wherein the current container temperature of each container already stored in the cache is obtained by decaying the container temperature after the last call of the container.
9. The method of claim 8, wherein determining whether to cache the target container based on the current available storage space of the cache, the current container temperatures of the containers already stored in the cache, and the container temperature after the current call of the target container, comprises: storing the target container into the cache if the current available storage space of the cache is greater than the storage space required for storing the target container; determining whether the container temperature after the current call of the target container is higher than the container temperature of a specified container among the cached containers if the current available storage space of the cache is less than the storage space required for storing the target container, wherein the specified container is the container with the lowest container temperature in the cache; replacing the specified container in the cache with the target container if the container temperature after the current call of the target container is higher than the container temperature of the specified container; and destroying the target container after executing the target task by using the target container if the container temperature after the current call of the target container is not higher than the container temperature of the specified container.
10. The method of claim 8 or 9, wherein after destroying the target container, the method further comprises: updating the call information of the target container in a historical call record table, wherein the historical call record table is used to record the call information of the containers that have been called but not cached. 11.The method of any one of claims 3 or 8-10, wherein the call information comprises one or more of: a last call time, a temperature after the last call, a total number of calls, an average call interval. 12.A container caching apparatus, the apparatus comprising: an obtaining module configured to, after receiving a call request for a target container, if the target container is a non-first call container, obtain a current decay container temperature of the target container, the decay container temperature being obtained by decaying a container temperature of the target container after a last call, wherein the container temperature of the target container is positively correlated with a caching priority of the target container; a temperature increase amount determining module configured to determine a temperature increase amount caused by the current call based on a container temperature influencing factor of the target container, wherein the container temperature influencing factor is a factor influencing the caching priority of the target container; a temperature increasing module configured to increase the decay container temperature by the temperature increase amount to obtain a container temperature of the target container after the current call; a caching module configured to determine a caching strategy of the target container based on the container temperature of the target container after the current call.
13. An electronic device comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the steps of the method of any one of claims 1-11 by running the executable instructions. 14.A computer readable storage medium having computer instructions stored thereon, the instructions being executed by a processor to implement the steps of the method of any one of claims 1-11. 15.A computer program product comprising computer program / instructions, the computer program / instructions being executed by a processor to implement the steps of the method of any one of claims 1-11.