A method for accelerating pod startup
Patent Information
- Application Number
- CN202310321582.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-03-29
AI Technical Summary
[0003]1、大量pod启动,从同一个镜像仓库拉取镜像,镜像仓库存在性能瓶颈;
[0024] The present invention discloses a pod startup acceleration method. Each node in the k8s cluster starts an image proxy module, which is responsible for image processing that the current node pod startup depends on. The method reduces the download of images from external image repositories. The method evenly downloads images from the image proxy of each node in the k8s cluster to achieve load balancing. The method also provides a distributed image cache mechanism, memory and local disk cache, to improve the image cache hit rate and achieve rapid pod startup.
Smart Images

Figure CN116560745B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing, and in particular relates to a pod startup acceleration method. Background Art
[0002] When a Pod is started and the current node image does not exist, it needs to pull the image from the configured image repository. Only after the image is pulled can the Pod be started. Currently, the following problems exist:
[0003] 1. A large number of pods are started and pull images from the same image repository, which creates a performance bottleneck for the image repository.
[0004] 2. When the local node has no image, the image is pulled from the image repository, which increases the pod startup time;
[0005] 3. When an image exists locally and is loaded from the local hard disk, the reading time from the hard disk is longer than the reading time from the memory, and the pod cannot start quickly. Summary of the Invention
[0006] In view of this, the present invention aims to propose a pod startup acceleration method. Combined with the image layered storage mechanism, the same layered data exists between different images. This paper proposes a k8s cluster distributed image layered caching and downloading mechanism, a LFU cache algorithm (Least Frequently Used, least frequently used algorithm), which is implemented using HashMap+bidirectional linked list to reduce the download of images from the image repository, reduce the disk read operations of the local image repository for the same layered data, and improve the cache hit rate of the same layered data, thereby achieving the purpose of quickly starting the pod.
[0007] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0008] A method for accelerating pod startup includes the following steps:
[0009] S1. Each node in the cluster runs the image proxy module. When the proxy module is first started, it reads the image from the local warehouse and builds the image layer data cache information based on the cache size. If the cache cannot hold all the local warehouse data, it is deemed that there is no actual data.
[0010] S2. When the pod starts, the proxy module on the pod scheduling node queries and downloads the dependent image layer data;
[0011] S3. When the local proxy module query cache hits, the image layer data is obtained from the local proxy module and the image layer access count is refreshed;
[0012] S4. When the local proxy module query cache does not hit, it queries each proxy module of the cluster node whether the image cache exists, and obtains the node and download connection number of the image layer data;
[0013] S5. The current node agent module sorts the nodes by the number of download connections according to the information and downloads to the node with the least connection in turn until the download is successful;
[0014] S6. If the download in step S5 fails or the image layered data does not exist on each node in the cluster, download the layered data from the repository specified by the image;
[0015] S7. After the required dependent layered data is downloaded by the proxy module, the pod is started successfully.
[0016] Furthermore, in step S1, the mirror layer data cache information includes the number of accesses and whether the mirror layer data is stored in the memory.
[0017] Furthermore, in step S5, if the download is successful, the local proxy module notifies the node proxy module where the image layered data exists, refreshes the image cache information, and updates the access count; the current node proxy module confirms whether the configured cache upper limit is reached after storing the image layered data. If not, the image cache information is inserted. If the upper limit is reached, the image with the smallest access count is eliminated and deleted from the cache, and this process continues until the image layered data can be stored, and then the image cache information is inserted.
[0018] Furthermore, in step S6, if the download is successful, the current node proxy module cache is notified, and the proxy module confirms whether the layered data stored in the local warehouse has reached the threshold. If it has reached the threshold, the layered data with the smallest number of layered accesses in the local warehouse mirror is eliminated; it is determined whether the data storage memory has reached the cache memory threshold.
[0019] If it is not reached, the cache information of the layered data is inserted. When the upper limit is reached, the layered data with the least number of accesses is eliminated and deleted from the cache until the data can be stored. If the download fails, the pod startup fails.
[0020] Furthermore, the present solution discloses an electronic device, comprising a processor and a memory communicatively connected to the processor and used to store instructions executable by the processor, wherein the processor is used to execute a pod startup acceleration method.
[0021] A server includes at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to cause the at least one processor to perform a pod startup acceleration method.
[0022] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a pod startup acceleration method.
[0023] Compared with the prior art, the pod startup acceleration method described in the present invention has the following beneficial effects:
[0024] The present invention discloses a pod startup acceleration method. Each node in the k8s cluster starts an image proxy module, which is responsible for image processing that the current node pod startup depends on. The method reduces the download of images from external image repositories. The method evenly downloads images from the image proxy of each node in the k8s cluster to achieve load balancing. The method also provides a distributed image cache mechanism, memory and local disk cache, to improve the image cache hit rate and achieve rapid pod startup. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings, which constitute part of the present invention, are provided to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are provided to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings:
[0026] Figure 1 This is a schematic diagram of a pod startup acceleration method according to an embodiment of the present invention;
[0027] Figure 2 This is a schematic diagram of mirrored layered data according to an embodiment of the present invention;
[0028] Figure 3 This is a schematic diagram of the initialization data structure for starting the node1 node agent module according to an embodiment of the present invention;
[0029] Figure 4 A flowchart showing how to start a pod on node 1 and download image 3 according to an embodiment of the present invention is shown.
[0030] Figure 5 This is a schematic diagram of updating the cache data structure of the node1 proxy module according to an embodiment of the present invention;
[0031] Figure 6 This is a schematic diagram of restarting a pod on node node1 according to an embodiment of the present invention, relying on the base image image3, hitting image3 from the local cache, and updating the cache data structure of the node1 proxy module;
[0032] Figure 7 This is a schematic diagram of deleting the pod on the node Node1 and updating the cache data structure of the node1 proxy module according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0034] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0035] like Figure 1 As shown in the figure, the operation process of the proxy module of this solution is as follows:
[0036] 1. Each node in the cluster runs a mirror proxy module. When the proxy module is first started, it reads the image from the local warehouse and builds the image layer data cache information (number of accesses, whether the image layer data is stored in memory) based on the cache size. If the cache cannot hold all the local warehouse data, the actual data will not be stored.
[0037] 2. When the pod starts, the proxy module on the pod scheduling node queries and downloads the dependent image layer data;
[0038] 3. When the local proxy module query cache hits, the image layer data is obtained from the local proxy module and the image layer access count is refreshed;
[0039] 4. If the local proxy module query cache does not hit, it queries the proxy modules of the cluster nodes (except the current node code module) to see whether the image cache exists, and obtains the node and download connection number of the image layer data.
[0040] 5. The current node proxy module, based on the information, sorts the nodes by the number of download connections and then downloads to the node with the least number of connections in turn until the download is successful. If the download is successful, the local proxy module notifies the node proxy module that has the image layer data, refreshes the image cache information, and updates the access count. The current node proxy module confirms whether the configured cache limit is reached after storing the image layer data. If not, the image cache information is inserted. If the limit is reached, the image with the least number of accesses is eliminated and deleted from the cache. This continues until the image layer data can be stored and the image cache information is inserted.
[0041] 6. If the download in step 5 fails or the image layer data does not exist on each node in the cluster, the layer data is downloaded from the repository specified by the image. If the download is successful, the current node proxy module cache is notified. The proxy module confirms whether the storage of the layer data in the local repository has reached the threshold. If so, the layer data with the least number of accesses to the local repository image layer is eliminated. The data storage memory is judged to have reached the cache memory threshold.
[0042] If the limit is not reached, the cache information of the layered data (number of accesses, memory for storing mirrored layered data) is inserted. If the limit is reached, the layered data with the least number of accesses is eliminated and deleted from the cache until the data can be stored. If the download fails, the pod startup fails.
[0043] 7. After the required dependent layered data is downloaded by the proxy module, the pod is started successfully.
[0044] In the specific implementation process, the method is as follows:
[0045] There are three images: image1, image2, and image3. The image layer data is as follows: Figure 2 As shown:
[0046] exist Figure 3 In the K8S cluster nodes: node1, node2, node3, the local warehouse of each node has the following mirror:
[0047] node1:image1、image2
[0048] node2:image3
[0049] node3: no mirror
[0050] The node1 node agent module startup initialization data structure is as follows:
[0051] The number of times the image layer data appears is as follows:
[0052] A:2
[0053] B:2
[0054] C:1
[0055] D:1
[0056] E:1
[0057] Among them, Y means that the data is in the cache, and N means that the data is not in the cache. According to the cache size, the cache only stores the data of layers A, B, and C, and the data of D and E are in the local warehouse;
[0058] Start a pod on node1 and download image3. The flow chart is as follows Figure 4 As shown;
[0059] The node1 proxy module cache data structure is updated as follows Figure 5 As shown (the local warehouse eliminates data E, and the cache eliminates data C);
[0060] A pod is started again on node 1, which depends on the base image image 3. Image 3 is hit from the local cache. The cache data structure of the node 1 proxy module is updated as follows: Figure 6 As shown;
[0061] Delete the pod on node Node1, and the cache data structure of node1 proxy module is updated as follows Figure 7 shown.
[0062] Those skilled in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0063] In the several embodiments provided in this application, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the division of the units described above is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The above-mentioned units may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
[0064] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention.
[0065] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A pod startup acceleration method, characterized in that: The following steps are involved: S1. Each node in the cluster runs the image proxy module. When the proxy module is first started, it reads the image from the local warehouse and builds the image layered data cache information according to the cache size. S2. When the pod starts, it queries and downloads the dependent image layer data from the agent module on the pod scheduling node; S3. When the local proxy module query cache hits, the image layer data is obtained from the local proxy module and the image layer access count is refreshed; S4. When the local proxy module query cache does not hit, it queries each proxy module of the cluster node whether the image cache exists, and obtains the number of node download connections that have the image layer data; S5. The current node agent module sorts the nodes by the number of download connections according to the information and downloads to the node with the least connection in turn until the download is successful; S6. If the download in step S5 fails or the image layered data does not exist on any node in the cluster, download the layered data from the repository specified by the image; S7. After the required layered data is downloaded by the proxy module, the pod is started successfully; In step S5, if the download is successful, the local proxy module notifies the node proxy module where the image layer data exists, refreshes the image cache information, and updates the access count; The current node agent module confirms whether the configured cache limit is reached after storing the image layered data. If not, the image cache information is inserted. If the limit is reached, the image with the least number of accesses is eliminated and deleted from the cache. This process continues until the image layered data can be stored, and then the image cache information is inserted.
2. A pod startup acceleration method according to claim 1, characterized in that: In step S1, the mirror layer data cache information includes the number of accesses and whether the mirror layer data is stored in the memory.
3. A pod startup acceleration method according to claim 1, characterized in that: In step S6, if the download is successful, the current node agent module cache is notified, and the agent module confirms whether the layered data stored in the local warehouse has reached a threshold. If so, the layered data with the smallest number of layered accesses in the local warehouse mirror is eliminated; Determine whether the data storage memory has reached the cache memory threshold, If it is not reached, the cache information of the hierarchical data is inserted. If the upper limit is reached, the hierarchical data with the smallest number of accesses is eliminated and deleted from the cache until the data can be stored; If the download fails, the pod startup fails.
4. An electronic device comprising a processor and a memory in communication with the processor and configured to store instructions executable by the processor, wherein: The processor is used to execute the pod startup acceleration method described in any one of claims 1 to 3.
5. A server, characterized in that: The system comprises at least one processor and a memory in communication with the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor so that the at least one processor executes a pod startup acceleration method according to any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the pod startup acceleration method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Pod scheduling method, scheduler, scheduling system and electronic equipment
CN115421850A
Method and apparatus for starting secure container
WO2022206230A1