Cloud platform container management method and device and storage medium
By generating snapshots and memory templates for the functions of the Serverless cloud platform, the rapid recovery of containers and memory sharing are achieved, and the resource waste and latency problems caused by cold startup are solved, and memory utilization and resource efficiency are improved.
Patent Information
- Application Number
- CN202411170524.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-17
AI Technical Summary
The Serverless cloud platform is difficult to avoid resource waste when processing idle functions. It brings computing resource overhead and delay when creating an operating environment when cold startup creates a running environment, and the container memory utilization rate is low.
By generating snapshots for functions and generating memory templates based on snapshots, and recovering containers when running requests in response to objective function, snapshot recovery technology and memory sharing are implemented, reducing overhead for isolated environment creation, reducing cold startup delays, and optimizing memory resource utilization through container reuse.
Quickly implement memory state recovery, reduces container creation overhead and latency, improves memory utilization, and reduces memory duplication and resource usage.
Smart Images

Figure CN119149170A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of cloud platforms, and in particular to a cloud platform container management method, device and storage medium. Background Art
[0002] Serverless is an emerging cloud service computing model. Users upload the code they need to execute (i.e., function) to the Serverless cloud platform and set the corresponding trigger conditions. When the corresponding conditions occur, the cloud platform will be responsible for creating the corresponding execution environment to execute the user code, and dynamically adjust the allocated resources as the load of the execution request increases, such as starting more execution environments on more servers. As you can see, through Serverless, traditional operations, expansion, resource allocation and other tasks can be transferred to the cloud platform, and users only need to care about their business code logic. On the other hand, Serverless charges according to the actual function execution time. When there is no load or request, no fees are charged. This model is very suitable for applications with large load fluctuations or uncertain request volume.
[0003] As a cloud service, Serverless itself needs to provide resource isolation and security isolation. Currently, the commonly used operating environment is usually a virtual machine or container. Due to the special billing model, it is impossible for the cloud platform to maintain the operating environment of idle functions for a long time. The ideal situation for the cloud platform is not to pay extra resources for any idle functions, but in fact it is difficult to do this. If a function needs to be executed and there is no operating environment, it needs to be created from scratch (also called cold start) The operating environment will introduce a large computing resource overhead. After all, no fees will be charged during the creation of the operating environment. In addition, the delay caused by the cold start of the container will also affect the user experience. Creating an operating environment from scratch will also lead to problems with memory duplication and low utilization. Summary of the invention
[0004] In view of this, the present disclosure proposes a cloud platform container management method, device and storage medium.
[0005] According to one aspect of the present disclosure, a cloud platform container management method is provided. The method includes:
[0006] Generate a snapshot based on one or more categories of functions. The snapshot represents the memory state of the corresponding function after initialization.
[0007] Generate a memory template for each function's process based on the snapshot. The memory template is used to map the function's process's virtual address to a physical address.
[0008] In response to the existence of the target function execution request, allocating a target container for the target function execution request;
[0009] The target container is restored according to the snapshot and memory module corresponding to the target function, and the restored target container is used to execute the target function running request in the cloud platform.
[0010] In a possible implementation, the target container is restored according to the snapshot and memory module corresponding to the target function, including:
[0011] Create a target process based on the snapshot corresponding to the target function, and add the target process to the target container;
[0012] The memory template corresponding to the target function is copied to the target process to obtain the restored target container.
[0013] In a possible implementation, a snapshot is generated based on one or more categories of functions, including:
[0014] Generate snapshots for each category of functions;
[0015] Perform deduplication operations on the newly generated snapshots based on the snapshots stored in the memory pool, and store the deduplicated snapshots in the memory pool.
[0016] In a possible implementation, performing a deduplication operation on the newly generated snapshot according to the snapshots stored in the memory pool, and storing the deduplicated snapshots in the memory pool includes:
[0017] For each page in the newly generated snapshot and the stored snapshot, determine whether the hash values of the two are the same;
[0018] In response to the hash values being the same, a byte-by-byte comparison is performed on the page to determine whether the newly generated snapshot and the stored snapshot are duplicates;
[0019] For duplicate newly generated snapshots and stored snapshots, select one of the snapshots to store in the memory pool.
[0020] In a possible implementation, the memory template includes a virtual memory area of a process of the function and a page table, where the page table is used to map a virtual address of the virtual memory area to a physical address.
[0021] In one possible implementation, the physical address includes calculating an address of a fast link CXL memory, and the method further includes:
[0022] Write-protect the data in CXL memory.
[0023] In a possible implementation, the physical address includes an address of a remote direct memory access (RDMA) memory, and a page table associated with the RDMA memory is marked as an invalid page table.
[0024] In a possible implementation, in response to the existence of a target function execution request, allocating a target container for the target function execution request includes:
[0025] In response to a target function execution request, determining an idle container from a sandbox pool, where the sandbox pool includes one or more containers that have executed a function process.
[0026] Adjust the idle containers to obtain the target container.
[0027] In a possible implementation, adjusting the idle container to obtain the target container includes:
[0028] In response to the source function type in the idle container being different from the target function type, unmounting a first file system associated with the source function in the idle container, the first file system including dependencies specific to the source function;
[0029] A second file system associated with the target function is mounted into the idle container, where the second file system includes dependencies specific to the target function.
[0030] In a possible implementation, creating a target process according to a snapshot corresponding to the target function includes:
[0031] Specifies the control group to which the target process belongs during the process creation.
[0032] In one possible implementation, the cloud platform is a Serverless cloud platform.
[0033] According to another aspect of the present disclosure, a cloud platform container management device is provided. The device includes:
[0034] A first generating module, configured to generate a snapshot based on one or more categories of functions, wherein the snapshot represents a memory state after the corresponding function is initialized;
[0035] A second generating module is used to generate a memory template for the process of each function based on the snapshot, and the memory template is used to map the virtual address of the process of the function to the physical address;
[0036] an allocation module, configured to allocate a target container for the target function execution request in response to the existence of the target function execution request;
[0037] The recovery module is used to recover the target container according to the snapshot and memory module corresponding to the target function. The recovered target container is used to execute the target function running request in the cloud platform.
[0038] In a possible implementation, the recovery module is used to:
[0039] Create a target process based on the snapshot corresponding to the target function, and add the target process to the target container;
[0040] The memory template corresponding to the target function is copied to the target process to obtain the restored target container.
[0041] In a possible implementation, the first generating module is used to:
[0042] Generate snapshots for each category of functions;
[0043] Perform deduplication operations on the newly generated snapshots based on the snapshots stored in the memory pool, and store the deduplicated snapshots in the memory pool.
[0044] In a possible implementation, performing a deduplication operation on the newly generated snapshot according to the snapshots stored in the memory pool, and storing the deduplicated snapshots in the memory pool includes:
[0045] For each page in the newly generated snapshot and the stored snapshot, determine whether the hash values of the two are the same;
[0046] In response to the hash values being the same, a byte-by-byte comparison is performed on the page to determine whether the newly generated snapshot and the stored snapshot are duplicates;
[0047] For duplicate newly generated snapshots and stored snapshots, select one of the snapshots to store in the memory pool.
[0048] In a possible implementation, the memory template includes a virtual memory area of a process of the function and a page table, where the page table is used to map a virtual address of the virtual memory area to a physical address.
[0049] In a possible implementation, the physical address includes calculating an address of a fast link CXL memory, and the apparatus further includes:
[0050] The marking module is used to mark the data in the CXL memory as write-protected.
[0051] In a possible implementation, the physical address includes an address of a remote direct memory access (RDMA) memory, and a page table associated with the RDMA memory is marked as an invalid page table.
[0052] In a possible implementation, the allocation module is used to:
[0053] In response to a target function execution request, determining an idle container from a sandbox pool, where the sandbox pool includes one or more containers that have executed a function process.
[0054] Adjust the idle containers to obtain the target container.
[0055] In a possible implementation, adjusting the idle container to obtain the target container includes:
[0056] In response to the source function type in the idle container being different from the target function type, unmounting a first file system associated with the source function in the idle container, the first file system including dependencies specific to the source function;
[0057] A second file system associated with the target function is mounted into the idle container, where the second file system includes dependencies specific to the target function.
[0058] In a possible implementation, creating a target process according to a snapshot corresponding to the target function includes:
[0059] Specifies the control group to which the target process belongs during the process creation.
[0060] In one possible implementation, the cloud platform is a Serverless cloud platform.
[0061] According to another aspect of the present disclosure, a cloud platform container management device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0062] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.
[0063] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0064] According to the embodiment of the present application, by generating a snapshot for the function and generating a memory module for the function process based on the snapshot, when there is a target function running request, the target container is restored according to the snapshot and memory module corresponding to the target function, and the memory state can be quickly restored through snapshot recovery technology and memory sharing to execute the target function running request in the cloud platform, thereby reducing the creation overhead of the isolated environment and reducing the computing resource overhead and delay caused by the cold start. The memory occupancy rate of the container is reduced through the reuse of containers, the memory resource occupancy is optimized, the memory duplication is reduced, and the memory utilization rate is improved.
[0065] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
[0067] Figure 1 A schematic diagram showing an application scenario according to an embodiment of the present application.
[0068] Figure 2 A flow chart of a cloud platform container management method according to an embodiment of the present application is shown.
[0069] Figure 3 A schematic diagram showing adjustment of idle containers according to an embodiment of the present application is shown.
[0070] Figure 4 A schematic diagram of a process of a cloud platform container management method according to an embodiment of the present application is shown.
[0071] Figure 5 A schematic diagram showing the effect of a cloud platform container management method according to an embodiment of the present application is shown.
[0072] Figure 6 A schematic diagram showing the effect of a cloud platform container management method according to an embodiment of the present application is shown.
[0073] Figure 7 A structural diagram of a cloud platform container management device according to an embodiment of the present application is shown.
[0074] Figure 8 It is a block diagram of a device 1900 for cloud platform container management according to an exemplary embodiment. DETAILED DESCRIPTION
[0075] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0076] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0077] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0078] Serverless is an emerging cloud service computing model. Users upload the code they need to execute (i.e., function) to the Serverless cloud platform and set the corresponding trigger conditions. When the corresponding conditions occur, the cloud platform will be responsible for creating the corresponding execution environment to execute the user code, and dynamically adjust the allocated resources as the load of the execution request increases, such as starting more execution environments on more servers. As you can see, through Serverless, traditional operations, expansion, resource allocation and other tasks can be transferred to the cloud platform, and users only need to care about their business code logic. On the other hand, Serverless charges according to the actual function execution time. When there is no load or request, no fees are charged. This model is very suitable for applications with large load fluctuations or uncertain request volume.
[0079] As a cloud service, Serverless itself needs to provide resource isolation and security isolation. Currently, the commonly used operating environment is usually a virtual machine or container. Due to the special billing model, it is impossible for the cloud platform to maintain the operating environment of idle functions for a long time. The ideal situation for the cloud platform is not to pay extra resources for any idle functions, but in fact it is difficult to do this. If a function needs to be executed and there is no operating environment, it needs to be created from scratch (also called cold start) The operating environment will introduce a large computing resource overhead. After all, no fees will be charged during the creation of the operating environment. In addition, the delay caused by the cold start of the container will also affect the user experience. Creating an operating environment from scratch will also lead to problems with memory duplication and low utilization.
[0080] In view of this, the present application provides a cloud platform container management method, device and storage medium. The method of the embodiment of the present application generates a snapshot for the function and generates a memory module for the function process based on the snapshot. When there is a target function running request, the target container is restored according to the snapshot and memory module corresponding to the target function. Through snapshot recovery technology and memory sharing, the memory state can be quickly restored to execute the target function running request in the cloud platform, reducing the creation overhead of the isolated environment and reducing the computing resource overhead and delay caused by the cold start. The memory occupancy rate of the container is reduced through the reuse of containers, the memory resource occupancy is optimized, the memory duplication is reduced and the memory utilization rate is improved.
[0081] Figure 1 A schematic diagram of an application scenario according to an embodiment of the present application is shown. The method of the present application can be applied to a scenario in which a user uses a Serverless cloud platform to execute a function, such as Figure 1As shown in the figure, the Serverless cloud platform may include one or more nodes (such as nodes 1 to 3), and the nodes may be connected to remote memory (called memory pool), which may be used to store data. There may be one or more memory pools, which are implemented based on Remote Direct Memory Access (RDMA) or Compute Express Link (CXL).
[0082] In the scenario of the embodiment of the present application, the user can upload the function to be executed (expressed as code) to the Serverless cloud platform and set the trigger conditions (such as timed triggering). When the trigger conditions are met, the cloud platform uses the method of the present application to create a container as the function's operating environment on any one or more nodes, so that the function uploaded by the user can be run in an isolated environment (i.e., the created container) to obtain the function's running results.
[0083] The above-mentioned nodes 1 to 3 can be servers, which can be located locally or in the cloud, and can be physical devices or virtual devices, such as virtual machines, containers, etc., and have wireless communication functions, wherein the wireless communication functions can be set in the chip (system) or other parts or components of the server. The wireless communication function can be realized, for example, through mobile communication technologies such as 2G / 3G / 4G / 5G, as well as Wi-Fi, Bluetooth, frequency modulation (FM), digital radio, satellite communication, etc. Communication can also be carried out through wired connections to achieve interaction with other devices.
[0084] Figure 2 A flow chart of a cloud platform container management method according to an embodiment of the present application is shown. The method can be used for the above-mentioned server, such as Figure 2 As shown, the method includes:
[0085] Step S201 : generating a snapshot based on one or more categories of functions.
[0086] One or more categories of functions may be functions that have been previously uploaded to a cloud platform, which may be a Serverless cloud platform. For example, each time a user uploads a function, a snapshot may be generated for the function. Functions of different categories may refer to functions with different contents.
[0087] The snapshot represents the memory state after the corresponding function is initialized. The snapshot may include one or more pages, and different pages may store different memory states after the function is initialized. For example, it includes the virtual addresses (expressed as the mapping relationship from the virtual address to the corresponding page in the snapshot) and values of the local variables and global variables of the function in the memory.
[0088] When generating snapshots based on one or more categories of functions, in order to save only one snapshot corresponding to the same type of function, you can:
[0089] Generate snapshots for each category of function; perform deduplication operations on the newly generated snapshots based on the snapshots stored in the memory pool, and store the deduplicated snapshots in the memory pool.
[0090] The memory pool can be the above-mentioned RDMA memory pool or CXL memory pool. During the deduplication operation, you can:
[0091] For each page (a page of 4KB, for example) in the newly generated snapshot and the stored snapshot, determine whether the hash values of the two are the same; in response to the hash values of the two being the same, perform a byte-by-byte comparison on the page to determine whether the newly generated snapshot and the stored snapshot are duplicates; for duplicate newly generated snapshots and stored snapshots, select one of the snapshots and store it in the memory pool.
[0092] If the hash value of a page in the newly generated snapshot is different from that in the stored snapshot, or a byte is found to be different when comparing byte by byte in a page, it can be considered that the two snapshots are not duplicated, and the newly generated snapshot can be stored in the memory pool.
[0093] Among them, when a page of the newly generated snapshot is repeated with one or several pages in the stored snapshot, but other pages are not repeated, only the non-duplicate pages in the newly generated snapshot can be saved in the memory pool, and for the duplicate pages, the page in one of the snapshots can be selected to be stored in the memory pool. If you choose to save the page in the stored snapshot, you can update the mapping relationship between the virtual address in the newly generated snapshot and the page in the snapshot, and map the original virtual address to the page in the stored snapshot; if you choose to save the page in the newly generated snapshot, you can update the mapping relationship between the virtual address in the stored snapshot and the page in the snapshot, and map the original virtual address to the page in the newly generated snapshot.
[0094] Step S202: Generate a memory template for the process of each function based on the snapshot.
[0095] The memory template may be used to map the virtual address of the function process to a physical address. The virtual address may refer to an address in a virtual memory area (VMA), and the physical address may include an address of a CXL memory and / or an address of an RDMA memory.
[0096] A memory template may be generated based on a mapping relationship between a virtual address in a snapshot and a corresponding page in the snapshot. For example, a range of virtual addresses corresponding to pages in the memory snapshot may be determined based on the mapping relationship, thereby obtaining a VMA corresponding to the function. The memory template may include a virtual memory area and a page table of the process of the function. The memory template may be saved to the memory on the node.
[0097] In this application, a process for each function can create a mm_struct similar to the one maintained by the operating system in Linux for the process corresponding to each function, and fill it with VMA as the virtual memory area of the process of the function. The page table is used to map the virtual address of the virtual memory area to the physical address.
[0098] For CXL memory, since the processor (CPU) can directly access (read / write) CXL memory through Load / Store instructions, a mapping from a virtual address to a CXL memory address can be directly established in the page table. Since there may be multiple functions in multiple containers accessing data at the address at the same time when running a function, the method may further include:
[0099] Write-protect the data in CXL memory.
[0100] Therefore, the copy on write (COW) function can be implemented, that is, when multiple containers use the same memory template, the memory template is copied, so that when a container needs to modify the memory template, the copy of the memory template is actually modified. In this way, memory template sharing can be achieved across functions and nodes.
[0101] For CXL memory, this application does not introduce any runtime overhead for read-only access. In the subsequent container recovery phase, there is no need to copy the memory data, but to copy the memory template into the target function's process. Since the memory template only saves the VMA and page table, the copy overhead is extremely low, comparable to the overhead of process duplication (fork).
[0102] As for RDMA memory, since the processor cannot directly access this type of memory pool, only the corresponding physical address (RDMA memory address) can be recorded in the page table, and the page table associated with the RDMA memory is marked as an invalid page table.
[0103] In this way, accessing the corresponding page during the subsequent function execution will trigger a page fault exception. At this time, the corresponding page can be read from the RDMA memory pool according to the physical address recorded in the page table.
[0104] The above steps S201 to S202 may be performed offline.
[0105] Step S203: In response to the existence of the target function execution request, a target container is allocated for the target function execution request.
[0106] The target function running request can be initiated by the user, and the target function can be a function that the user has uploaded to the Serverless cloud platform in advance.
[0107] For container instances running on the Serverless cloud platform, you do not need to clean them up immediately after execution. Instead, you can save the containers to the sandbox pool, which can be a part of the memory on the node. The sandbox pool can include one or more containers that have run function processes. The container can represent the isolated environment of the Serverless cloud platform, that is, the running environment of the function process.
[0108] Among them, you can:
[0109] In response to a target function execution request, an idle container is determined from the sandbox pool; and the idle container is adjusted to obtain a target container.
[0110] An idle container may be a container that is not running a function.
[0111] In this application, the idle container instances can be fine-tuned to meet the needs of the target function, so as to reuse the vast majority of the isolation environments as much as possible.
[0112] Resources that can be directly reused in idle containers, such as network namespaces and virtual network devices, can be reused directly to omit the creation overhead of recreating these resources.
[0113] As for the root file system, it cannot be reused directly (because different functions have different file requirements), so in the offline processing stage, according to the file system image of each type of function, its unique dependencies can be extracted, that is, dependencies specific to this type of function, such as Python third-party libraries, special files in the file system image, etc.
[0114] When adjusting the idle containers to obtain the target container, you can:
[0115] In response to the source function type and the target function type in the idle container being different, the first file system associated with the source function is unmounted in the idle container, and the second file system associated with the target function is mounted in the idle container.
[0116] The source function may be an idle container instance, and may include functions that have not been cleared from the last run.
[0117] The first file system and the second file system may refer to a joint file system (OverlayFS) provided by Linux.
[0118] The first file system can be a file system originally mounted in an idle container, and the first file system includes dependencies specific to the source function. Since the source function and the target function are of different types, their dependencies may also be different, so the first file system can be unmounted (unmount) from the idle container, and the second file system can be bind-mounted (bindmount) to the corresponding path in the mount namespace of the idle container. The second file system can include dependencies specific to the target function, and the path can be a directory in the internal file system of the container. The path can be determined when the user uploads the function, so that the file system can be mapped to the specified location of the container.
[0119] Figure 3 FIG. 2 is a schematic diagram showing how to adjust an idle container according to an embodiment of the present application. Figure 3 As shown, the red box represents the mount point (mount path) in the idle container, and the dotted box represents different file systems. The reused part can represent the reusable mount point in the idle container, including the character class content "char dev" stored under " / dev / null", the file system "sysfs" under " / sys / ", and the Base Overlay FS under " / " (which can represent the reusable part in OverlayFS). APP XOverlayFS and APP Y OverlayFS can represent the above-mentioned second file system, including dependencies specific to function X and function Y, respectively. APP X OverlayFS and APP Y OverlayFS can be fine-tuned (modified) and then mounted under the path " / home / app / " in the idle container to obtain the target container.
[0120] In this application, by constructing OverlayFS, multiple container instances of a class of functions can be allowed to share a unique dependency folder (i.e., the above-mentioned file system including function-specific dependencies) through a copy-on-write (COW) mechanism, where each container instance has write permissions. On the other hand, when reusing containers, only OverlayFS needs to be replaced, and most of the other mount points can be reused, thus omitting the creation overhead.
[0121] Among them, a file system pool (overlayfs pool, stored in the node memory) can be maintained for each type of function. During each adjustment, the first file system replaced in the idle container is put back into the pool. Subsequently, the second file system associated with the function consistent with the target function type is obtained from the pool first for use, which can further reduce the creation overhead of overlayfs.
[0122] Step S204: restore the target container according to the snapshot and memory module corresponding to the target function. The restored target container is used to execute the target function running request in the cloud platform.
[0123] Among them, the memory status, register status, process status, file descriptor status, etc. in the container can be restored.
[0124] According to the embodiment of the present application, by generating a snapshot for the function and generating a memory module for the function process based on the snapshot, when there is a target function running request, the target container is restored according to the snapshot and memory module corresponding to the target function, and the memory state can be quickly restored through snapshot recovery technology and memory sharing to execute the target function running request in the cloud platform, thereby reducing the creation overhead of the isolated environment and reducing the computing resource overhead and delay caused by the cold start. The memory occupancy rate of the container is reduced through the reuse of containers, the memory resource occupancy is optimized, the memory duplication is reduced, and the memory utilization rate is improved.
[0125] In this application, the register state, process state, file descriptor state, etc. can be restored through the CRIU (Checkpoint / Restore In Userspace) library in Linux when creating the target process. For the restoration of the memory state, in step S204, you can:
[0126] According to the snapshot corresponding to the target function, a target process is created, and the target process is added to the target container; the memory template corresponding to the target function is copied to the target process to obtain the restored target container.
[0127] For example, a new process (i.e., target process) can be created through the CRIU library, wherein the memory state of the target process can be restored through the state initialized by the function saved in the snapshot.
[0128] By copying the memory template corresponding to the target function to the target process, when the target function request is executed in the target container, physical addressing can be performed according to the memory template to find the required data.
[0129] In the scenario of Serverless cloud platform, in order to achieve performance isolation, a control group (cgroup) needs to be created for each function. In order to further reduce the synchronization overhead when executing cgroup, this application can create a target process according to the snapshot corresponding to the target function:
[0130] Specifies the control group to which the target process belongs during the process creation.
[0131] You can use the Linux CLONE_INTO_CGROUP instruction to specify the cgroup to which the target process belongs before the target process is created.
[0132] Steps S203 to S204 may be performed online.
[0133] Figure 4 FIG. 1 is a flow chart showing a method for managing cloud platform containers according to an embodiment of the present application. Figure 4 As shown, taking node 1 on the Serverless cloud platform as an example, the solution of this application may include an offline preprocessing stage (A1-A2) and an online recovery stage (B1-B4). The offline preprocessing stage includes:
[0134] A1: Generate a snapshot for each type of function (such as function Y), deduplicate the snapshot, and place the deduplicated snapshot into a memory pool (such as Figure 1 in the memory pool).
[0135] As shown in the example in the figure, the memory pool may include a deduplicated memory snapshot of function X and a deduplicated memory snapshot of function Y.
[0136] A2: Generate a memory template for each function process (such as function Y process) according to the snapshot through the operating system interface.
[0137] The memory template records the memory mapping metadata (such as VMA) and page table of the corresponding function process.
[0138] The offline preprocessing phase only needs to be executed once for each type of function. Subsequent function run requests can start the container through the online recovery phase. The online recovery phase includes:
[0139] B1: Each container (such as a function X container that has executed function X) will not be cleaned up immediately after execution, and its isolated environment will be continuously saved in the sandbox pool.
[0140] As shown in the figure, the container isolation environment of function X includes the memory of X (corresponding to the memory state) and the remaining X states.
[0141] B2: When there is a new function running request (for example, a function Y running request), if there are idle containers in the sandbox pool, the corresponding idle containers will be fine-tuned to meet the needs of the current function, so as to reuse the vast majority of isolated environments as much as possible.
[0142] The idle containers may be adjusted in the manner described in step S203.
[0143] B3: Start a new process through the CRIU library based on the snapshot generated in the offline preprocessing stage and move it to the isolated environment obtained after fine-tuning in B2.
[0144] A new process can be started based on the snapshot corresponding to function Y, and the remaining states of the new process except the memory state can be restored through the CRIU library.
[0145] B4: The memory template of the corresponding function is copied to the container process being restored, and the new container can execute the function running request.
[0146] Therefore, the memory state of the function (such as the memory of Y in the figure) can be restored based on the snapshot and memory template.
[0147] Figure 5 The following is a schematic diagram showing the effect of a cloud platform container management method according to an embodiment of the present application. Figure 5 , showing the end-to-end latency (E2E Latency), where T-CXL and T-RDMA represent the two versions of the CXL memory pool and RDMA memory pool of this application, respectively, FaaSnap+ and REAP+ are the two best lazy snapshot-recovery systems currently, faasd and CRIU represent the traditional startup and snapshot-recovery startup technologies for containers, respectively. The horizontal axis represents the different serverless functions used in the test, and the vertical axis represents the speedup ratio of various solutions relative to FaaSnap+.
[0148] It can be seen that the performance improvement of using CXL memory pool (such as T-CXL in the figure) is between 1.2 times and 9.2 times, while the performance of using RDMA memory pool (such as T-RDMA in the figure) is lower than REAP and FaaSnap in some functions, mainly because the access latency of RDMA itself is one order of magnitude higher than that of CXL memory, but in other functions, the performance improvement is basically 1.11 times to 4.64 times. Under normal load, the cold start time (P99) of most functions can be optimized to within 10ms, even some particularly complex functions (with more than 100 threads and actual memory size of more than 200MB) are around 30ms.
[0149] Figure 6 The following is a schematic diagram showing the effect of a cloud platform container management method according to an embodiment of the present application. Figure 6, showing the memory usage (Mem Usage) optimization gain of this application. Among them, the left figure shows the memory usage under 4 different workloads (workload), and the right figure shows the memory usage of starting 50 IR functions and IFR functions separately. Among them, IR function is a function with more read-only requests, while IFR is a function with fewer read-only requests. It can be seen that memory sharing through the CXL memory pool used in this application can bring about a 25%-60% reduction in memory usage, and due to the direct access characteristics of CXL memory, it can have an additional memory usage reduction of about 10% compared to the RDMA memory pool.
[0150] Figure 7 FIG. 1 shows a structural diagram of a cloud platform container management device according to an embodiment of the present application. Figure 7 As shown, the device comprises:
[0151] A first generating module 701 is used to generate a snapshot based on one or more categories of functions, where the snapshot represents the memory state of the corresponding function after initialization;
[0152] A second generating module 702, used to generate a memory template for the process of each function based on the snapshot, where the memory template is used to map the virtual address of the process of the function to a physical address;
[0153] An allocation module 703 is used to allocate a target container for the target function execution request in response to the existence of the target function execution request;
[0154] The recovery module 704 is used to recover the target container according to the snapshot and memory module corresponding to the target function. The recovered target container is used to execute the target function running request in the cloud platform.
[0155] In a possible implementation, the recovery module 704 is configured to:
[0156] Create a target process based on the snapshot corresponding to the target function, and add the target process to the target container;
[0157] The memory template corresponding to the target function is copied to the target process to obtain the restored target container.
[0158] In a possible implementation, the first generating module 701 is configured to:
[0159] Generate snapshots for each category of functions;
[0160] Perform deduplication operations on the newly generated snapshots based on the snapshots stored in the memory pool, and store the deduplicated snapshots in the memory pool.
[0161] In a possible implementation, performing a deduplication operation on the newly generated snapshot according to the snapshots stored in the memory pool, and storing the deduplicated snapshots in the memory pool includes:
[0162] For each page in the newly generated snapshot and the stored snapshot, determine whether the hash values of the two are the same;
[0163] In response to the hash values being the same, a byte-by-byte comparison is performed on the page to determine whether the newly generated snapshot and the stored snapshot are duplicates;
[0164] For duplicate newly generated snapshots and stored snapshots, select one of the snapshots to store in the memory pool.
[0165] In a possible implementation, the memory template includes a virtual memory area of a process of the function and a page table, where the page table is used to map a virtual address of the virtual memory area to a physical address.
[0166] In a possible implementation, the physical address includes calculating an address of a fast link CXL memory, and the apparatus further includes:
[0167] The marking module is used to mark the data in the CXL memory as write-protected.
[0168] In a possible implementation, the physical address includes an address of a remote direct memory access (RDMA) memory, and a page table associated with the RDMA memory is marked as an invalid page table.
[0169] In a possible implementation, the allocation module 703 is configured to:
[0170] In response to a target function execution request, determining an idle container from a sandbox pool, where the sandbox pool includes one or more containers that have executed a function process.
[0171] Adjust the idle containers to obtain the target container.
[0172] In a possible implementation, adjusting the idle container to obtain the target container includes:
[0173] In response to the source function type in the idle container being different from the target function type, unmounting a first file system associated with the source function in the idle container, the first file system including dependencies specific to the source function;
[0174] A second file system associated with the target function is mounted into the idle container, where the second file system includes dependencies specific to the target function.
[0175] In a possible implementation, creating a target process according to a snapshot corresponding to the target function includes:
[0176] Specifies the control group to which the target process belongs during the process creation.
[0177] In one possible implementation, the cloud platform is a Serverless cloud platform.
[0178] According to the embodiment of the present application, by generating a snapshot for the function and generating a memory module for the function process based on the snapshot, when there is a target function running request, the target container is restored according to the snapshot and memory module corresponding to the target function, and the memory state can be quickly restored through snapshot recovery technology and memory sharing to execute the target function running request in the cloud platform, thereby reducing the creation overhead of the isolated environment and reducing the computing resource overhead and delay caused by the cold start. The memory occupancy rate of the container is reduced through the reuse of containers, the memory resource occupancy is optimized, the memory duplication is reduced, and the memory utilization rate is improved.
[0179] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0180] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.
[0181] The embodiment of the present disclosure also proposes a cloud platform container management device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0182] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0183] Figure 8 1 is a block diagram of an apparatus 1900 for cloud platform container management according to an exemplary embodiment. For example, the apparatus 1900 may be provided as a server or a terminal device. Figure 8, the apparatus 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions, such as an application, that can be executed by the processing component 1922. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0184] The device 1900 may also include a power supply component 1926 configured to perform power management of the device 1900, a wired or wireless network interface 1950 configured to connect the device 1900 to a network, and an input / output interface 1958 (I / O interface). The device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2000. TM , MacOS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.
[0185] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the device 1900 to perform the above method.
[0186] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0187] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0188] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0189] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0190] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0191] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0192] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0193] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0194] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A cloud platform container management method, characterized in that: The method comprises: Generate a snapshot based on one or more categories of functions, where the snapshot represents a memory state of the corresponding function after initialization; Generate a memory template for the process of each function based on the snapshot, wherein the memory template is used to map the virtual address of the process of the function to a physical address; In response to a target function execution request, allocating a target container for the target function execution request; The target container is restored according to the snapshot and memory module corresponding to the target function, and the restored target container is used to execute the target function running request in the cloud platform.
2. The method according to claim 1, characterized in that The restoring the target container according to the snapshot and the memory module corresponding to the target function includes: Creating a target process according to the snapshot corresponding to the target function, and adding the target process to the target container; The memory template corresponding to the target function is copied to the target process to obtain a restored target container.
3. The method according to claim 1, characterized in that The function based on one or more categories generates a snapshot, including: Generate snapshots for each category of functions; A deduplication operation is performed on the newly generated snapshot according to the snapshots stored in the memory pool, and the deduplicated snapshot is stored in the memory pool.
4. The method according to claim 3, characterized in that The deduplication operation is performed on the newly generated snapshot according to the snapshots stored in the memory pool, and the deduplication snapshots are stored in the memory pool, including: For each page in the newly generated snapshot and the stored snapshot, determine whether the hash values of the two are the same; In response to the hash values being the same, a byte-by-byte comparison is performed on the page to determine whether the newly generated snapshot and the stored snapshot are duplicates; For duplicate newly generated snapshots and stored snapshots, one of the snapshots is selected to be stored in the memory pool.
5. The method according to claim 1, characterized in that The memory template includes a virtual memory area and a page table of a function process, and the page table is used to map a virtual address of the virtual memory area to a physical address.
6. The method according to claim 5, characterized in that The physical address includes calculating the address of the fast link CXL memory, and the method further includes: Write-protect the data in CXL memory.
7. The method according to claim 5, characterized in that The physical address includes an address of a remote direct memory access (RDMA) memory, and a page table associated with the RDMA memory is marked as an invalid page table.
8. The method according to claim 1, characterized in that: In response to the existence of the target function execution request, allocating a target container for the target function execution request includes: In response to a target function execution request, determining an idle container from a sandbox pool, where the sandbox pool includes one or more containers that have executed a function process; The idle container is adjusted to obtain a target container.
9. The method according to claim 8, characterized in that The step of adjusting the idle container to obtain a target container includes: In response to the source function type in the idle container being different from the target function type, unmounting a first file system associated with the source function in the idle container, wherein the first file system includes dependencies specific to the source function; A second file system associated with the target function is mounted into an idle container, wherein the second file system includes dependencies specific to the target function.
10. The method according to claim 2, characterized in that The step of creating a target process according to the snapshot corresponding to the target function includes: The control group to which the target process belongs is specified during the process of creating the target process.
11. The method according to claim 1, characterized in that: The cloud platform is a Serverless cloud platform.
12. A cloud platform container management device, characterized in that: The device comprises: A first generating module, configured to generate a snapshot based on one or more categories of functions, wherein the snapshot represents a memory state after the corresponding function is initialized; A second generating module, used for generating a memory template for the process of each function based on the snapshot, wherein the memory template is used for mapping the virtual address of the process of the function to a physical address; an allocation module, configured to allocate a target container for the target function execution request in response to the existence of the target function execution request; The recovery module is used to recover the target container according to the snapshot and memory module corresponding to the target function, and the recovered target container is used to execute the target function running request in the cloud platform.
13. A cloud platform container management device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method described in any one of claims 1 to 11 when executing the instructions stored in the memory.
14. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 11 is implemented.
