Container launch method, apparatus, storage medium, and system
By converting application code files into metadata and data file formats, and only downloading and parsing directory index information, the slow startup speed of traditional containers is solved, resulting in faster container startup.
Patent Information
- Application Number
- CN202310397269.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-04
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2043-04-04
AI Technical Summary
In Function Compute service, the traditional container startup process requires downloading and decompressing the complete code package, resulting in a slow cold start speed, especially when the code package is large.
By converting application code files into a specific file format, including metadata files and compressed data files, only the directory index information in the metadata files is downloaded and parsed. The target container then reads the startup data on demand based on this information, avoiding full download and decompression.
It accelerates the container startup process, reduces the load of downloading and decompression, and improves container startup speed.
Smart Images

Figure CN116506431B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing technology, and in particular to a container startup method, device, storage medium, and system. Background Technology
[0002] Serverless architecture is a new serverless application development architecture that allows users to avoid purchasing, maintaining, and setting up server environments and installing software. These tasks are handled by cloud providers, meaning users don't need to worry about servers and can focus solely on application code development, paying only for the cloud resources they actually use. This simplifies application code development.
[0003] Function Compute is a form of Serverless architecture that provides fully managed, event-driven computing services. With Function Compute, users don't need to purchase and manage servers or other infrastructure; they only need to write and upload their application code. Function Compute will prepare the necessary computing resources for the user, running their application code in an elastic and reliable manner, and providing features such as log querying, alerting, and performance monitoring.
[0004] Running a user's application code first requires building a container to run that application code. The traditional deployment method involves uploading the user's application code in a compressed format, such as ZIP, to a cloud storage space. The Function Compute service then downloads the compressed code package, cold-starts the container, and executes the user's application code. Cold start refers to the process by which the Function Compute service creates an execution environment (i.e., a container) for the application code. When deploying using a raw ZIP compressed code package on the Function Compute service, the cold start process involves downloading and decompressing the entire compressed code package. The larger the compressed code package, the longer the download and decompression time, resulting in a slower cold start speed, i.e., a longer container startup time. Summary of the Invention
[0005] This invention provides a container startup method, device, storage medium, and system to reduce the creation time of containers running application code.
[0006] In a first aspect, embodiments of the present invention provide a container startup method applied to a server, the method comprising:
[0007] Obtain runtime environment configuration information from application code files;
[0008] Based on the runtime environment configuration information, a target container for running the application code file is created in the server.
[0009] acquire the metadata file from a target storage space storing the metadata file and the compressed data file corresponding to the application code file, and transmit the metadata file into the target container, the metadata file storing directory index information of each data block in the data file;
[0010] read corresponding start-up data from the target storage space in response to a start-up data reading request triggered by the target container according to the directory index information, and transmit the decompressed start-up data to the target container, so that the target container runs the start-up data to complete start-up of the target container.
[0011] In a second aspect, an embodiment of the present application provides a container start-up apparatus applied to a server, and the apparatus comprises:
[0012] an acquisition module configured to acquire running environment configuration information of an application code file;
[0013] a creation module configured to create a target container for running the application code file in the server according to the running environment configuration information, and acquire a metadata file from a target storage space storing the metadata file and compressed data file corresponding to the application code file, and transmit the metadata file into the target container, the metadata file storing directory index information of each data block in the data file;
[0014] a start module configured to read corresponding start-up data from the target storage space in response to a start-up data reading request triggered by the target container according to the directory index information, and transmit the decompressed start-up data to the target container, so that the target container runs the start-up data to complete start-up of the target container.
[0015] In a third aspect, an embodiment of the present application provides a container start-up method, and the method comprises:
[0016] in response to a user's update operation on an application code file, acquiring a compressed file in a first file format corresponding to the application code file;
[0017] decompressing the compressed file in the first file format to obtain the application code file;
[0018] converting the application code file into a file in a second file format, the file in the second file format including a metadata file and compressed data file corresponding to the application code file, the metadata file storing directory index information of each data block in the data file;
[0019] storing the file in the second file format into a target storage space for a server to start a target container running the application code file in the server according to the file in the second file format.
[0020] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the container starting method in the first aspect or the third aspect.
[0021] In a fifth aspect, an embodiment of the present application provides a non-transitory machine readable storage medium, which stores executable code, and when the executable code is executed by a processor of an electronic device, the processor can at least implement the container starting method in the first aspect or the third aspect.
[0022] In a sixth aspect, an embodiment of the present application provides a function calculation service system, comprising a management and control component, a plurality of servers, and a plurality of storage spaces associated with the plurality of servers; the plurality of storage spaces comprise storage spaces in the plurality of servers and storage spaces not in the plurality of servers; the plurality of storage spaces are used to store metadata files and compressed data files corresponding to application code files;
[0023] The management and control component is configured to receive a running request triggered by a user terminal for an application code file, determine whether a created container corresponding to the application code file is available according to locally stored container running state information corresponding to the application code file, and if it is determined that the created container corresponding to the application code file is not available, trigger a container creation request corresponding to the application code file to a target server in the plurality of servers.
[0024] The target server is configured to at least execute the container starting method in the first aspect.
[0025] The container starting method provided by the embodiments of the present application can be executed in a function calculation service system, which comprises a management and control component, a plurality of servers, and a plurality of storage spaces. When the management and control component receives a running request triggered by a user terminal for an application code file, it determines whether a created container corresponding to the application code file is available according to locally stored container running state information corresponding to the application code file, and if it is determined that the created container corresponding to the application code file is not available, it triggers a container creation request corresponding to the application code file to a target server.
[0026] The target server first acquires the running environment configuration information of the application code file, creates a target container for running the application code file according to the running environment configuration information, such as creating a virtual machine in the target server, creating the target container in the virtual machine, to complete the initial creation of the target container. Then, the metadata file is acquired from the target storage space in which the metadata file and the compressed data file corresponding to the application code file are stored, to transmit the metadata file into the target container. The target storage space is located in the target server or not. In the embodiment of the application, the application code file of the user is stored into the target storage space in a certain file format. The file in the file format includes the metadata file and the compressed data file corresponding to the application code file. The data file stores a plurality of data blocks obtained by dividing each sub-code file included in the application code file. The data blocks in the data file are compressed to obtain the compressed data file. The metadata file stores directory index information of each data block in the compressed data file.
[0027] In the process of initially creating the target container, the directory index information of each data block in the metadata file is transmitted into the target container, so that the target container can see which sub-code files are included in the application code file and the corresponding identifiers of the data blocks in the data file included in each code sub-file. After the target container is created, the target container needs to be started, so that the target container can normally run. The target container determines the directory index information corresponding to the code (referred to as startup data) required for starting based on the directory index information included in the above-mentioned metadata file which is locally visible, triggers a reading request for the determined directory index information, so as to finally read the corresponding startup data from the target storage space, decompress the startup data and transmit the startup data to the target container, so that the target container runs the startup data to complete the starting process of the target container.
[0028] Therefore, in the process of creating and starting the target container, only the metadata file needs to be downloaded and parsed, and the data required for starting is read on demand according to the directory index information in the metadata file, without the need to download and decompress the complete data file, thereby accelerating the starting of the target container. BRIEF DESCRIPTION OF DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0030] Figure 1 A schematic diagram of a function calculation service system provided by the embodiment of the present application;
[0031] Figure 2 A file structure diagram after an application code file is converted for an embodiment of the present application is provided;
[0032] Figure 3 A flow chart of a container starting method for an embodiment of the present application is provided;
[0033] Figure 4 A schematic diagram of a file path information mapping relationship for an embodiment of the present application is provided;
[0034] Figure 5 A schematic diagram of a transmission process of directory index information in a metadata file for an embodiment of the present application is provided;
[0035] Figure 6 A flow chart of a container starting method for an embodiment of the present application is provided;
[0036] Figure 7 A flow chart of a container starting method for an embodiment of the present application is provided;
[0037] Figure 8 A flow chart of a container starting method for an embodiment of the present application is provided;
[0038] Figure 9 A structure schematic diagram of a container starting device for an embodiment of the present application is provided;
[0039] Figure 10 A structure schematic diagram of an electronic device for the present embodiment is provided. DETAILED DESCRIPTION
[0040] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application. In addition, the step sequence in each method embodiment below is only an example, not a strict limitation.
[0041] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0042] The container starting method provided by the embodiments of the present application can be applied to Figure 1 As shown in the function calculation service system, the system can include a management and control component, a plurality of servers, and a plurality of storage spaces.
[0043] The management and control component can be a functional component running in a virtual machine in the cloud, mainly providing an interactive interface (API interface) to the outside to realize interaction between the user end and the above-mentioned servers, so as to Figure 1 As shown in the figure, the management and control component can also be called API-server (interface service component).
[0044] In general, the user end can trigger an update request such as an application code file and / or its corresponding running environment configuration information, a running request of the application code file, etc. to the management and control component. In response to the request triggered by the user end, the management and control component can trigger a container creation request, an application code file running request, etc. to the server.
[0045] For example, in an embodiment, after the management and control component receives a running request triggered by the user end for an application code file, according to the container running state information corresponding to the application code file stored locally, it is determined that the created container corresponding to the application code file is unavailable, and then a container creation request corresponding to the application code file is triggered to the target server.
[0046] In fact, the code contained in the application code file provided by the user can complete a certain function, such as the function of realizing the resolution conversion of video or image, the function of detecting the abnormal value of the running state data of a certain device, etc. The user can trigger a running request for the application code file provided to the function calculation service system according to actual needs, such as triggering the above-mentioned running request when the data to be processed (for example, the video, image, and collected running state data of a certain device in the above-mentioned example) needs to be processed using the application code file, and the running request contains the data to be processed.
[0047] The function computing service system can flexibly create one or more containers running the application code file according to the user demand, and delete the created containers after a period of time after the task execution ends, so as to achieve the purpose of flexible supply. In the above management component, the container running state information corresponding to the application code file can be stored, which reflects whether the container created for the application code file currently exists or is in an idle state. When it is determined according to the container running state information that the created container corresponding to the application code file is currently unavailable, the management component randomly selects or selects target servers according to the load of each server from the plurality of servers, and triggers a container creation request for the application code file to the target servers.
[0048] The created container corresponding to the application code file can be currently running the application code file to process other to-be-processed data, or the created container is deleted because it is not running within a set time. It can be understood that if the created container is available, the to-be-processed data included in the running request can be sent to the created container, and the created container can complete the processing of the to-be-processed data by running the relevant code in the application code file.
[0049] The number of target servers can be one or more. For example, the running request triggered by the user end can include the required number of containers or the data amount of to-be-processed data, and the management component determines the number of containers to be created according to the above information, and then selects one target server to create the number of target containers in the target server, or selects multiple target servers to create at least one target container in each target server for running the application code file. In this paper, the container created by the server to run the application code file after receiving the container creation request is called target container.
[0050] The running request can also include running environment configuration information corresponding to the application code file, so that when it is determined that the target container corresponding to the application code file needs to be created, the running environment configuration information is carried in the container creation request and sent to the target server.
[0051] After the target server receives the container creation request, the creation and starting process of the target container corresponding to the application code file is performed, which will be described in detail below. In fact, as shown in Figure 1 Each server includes an execution engine that provides function computing service, and the subsequent container creation, starting and other processes are completed by the execution engine.
[0052] As shown in Figure 1As shown, the multiple storage spaces may include storage spaces L1 located locally on each server, such as disks, and may also include external storage spaces Lx that are not located on any server, which can be shared by multiple servers.
[0053] In practical applications, storage space Lx can be, for example, storage space provided by Object Storage Service (OSS) or network-side storage space provided by Network File System (NFS).
[0054] In this case, the storage space in NFS can be mounted on multiple servers. In this way, from the perspective of multiple servers, the file path in NFS on the remote network is as if it is on their local machine. They only need to read it as needed, without downloading it.
[0055] In an alternative embodiment, such as Figure 1 As shown, the external storage space Lx can include storage space L2 provided by NFS and storage space L3 provided by OSS. Thus, a three-tier storage system of L1, L2, and L3 can be formed. Since storage space L1 is located locally on the server, and the read / write performance of storage space L2 is generally better than that of storage space L3, the order of data reading speed from these three storage spaces by the server from highest to lowest can be: storage space L1 > storage space L2 > storage space L3.
[0056] The aforementioned storage spaces can be used to store files obtained after application code files have been converted into a specific file format. These files include metadata files corresponding to the application code files and compressed data files.
[0057] In practice, an application code file can include multiple sub-code files, each providing different functionalities. The application code file is essentially a file with a directory structure. For ease of understanding, let's combine... Figure 2 Example illustration. In Figure 2 In this example, assuming the root directory of the application code files is ` / root`, there are two subdirectories: ` / ab` and ` / cd`, and one sub-code file: `5.xls`. The subdirectory ` / ab` contains two sub-code files: `1.txt` and `2.doc`. The subdirectory ` / cd` contains two sub-code files: `3.xml` and `4.json`.
[0058] In the process of generating the file in the above specific file format, the sub-code files can be split into data blocks of a certain size, and then compressed for each data block. For example, if the data block size is 1 MB and the total data amount of the sub-code files is 100 MB, 100 data blocks can be split. Assuming that the size of each data block after compression is 0.3 MB, the size of the above data file containing the compressed data blocks is 30 MB, which is reduced compared to the 100 MB before compression. Figure 1 In the above process, assuming that each sub-code file is finally split into N data blocks as shown in the figure, the correspondence between the data blocks and the sub-code files is as shown in Figure 1 For example, the sub-code file 1.txt is split into data block 1 and data block 2.
[0059] The metadata file stores the directory index information of the data blocks corresponding to each sub-code file. Taking the above data block 1 as an example, the corresponding target index information is: / root / ab / 1.txt / data block 1. As can be seen, the directory index information of each data block stored in the metadata file actually reflects the directory level information of each sub-code file in the application code file and the corresponding identification information of the compressed data blocks in the data file.
[0060] In actual application, the above metadata file and data file can form a specific file format, such as a Registry Acceleration File System (RAFS) format.
[0061] In the embodiment of the application, the above plurality of storage spaces can be used to store the metadata file and the compressed data file obtained by converting the application code file into a specific file format, and the storage logic will be described in detail below.
[0062] In an optional embodiment, before a user wants to use his own application code file to complete the processing of the to-be-processed data, he first needs to edit and generate the application code file and upload it to the function calculation service system for storage.
[0063] In actual application, the user can log in to the application code file creation interface of the function calculation service system, edit his own application code file in the interface, and trigger a confirmation operation such as “save”, “submit”, etc. after editing. During the editing process, the user also needs to set the runtime environment configuration information, select the compression format, etc. The runtime environment configuration information includes, for example, the number of CPU cores to be used, the memory capacity, the network configuration, the language environment, etc. The compression format can be, for example, ZIP, RAR, etc.
[0064] Based on the compression format selected by the user, the application code file will be finally compressed accordingly, and the compressed application code file will be stored in a specific external storage space. Among them, the file compression format originally used by the user in this paper is referred to as the first file format, and the specific file format that can be converted into a metadata file and a compressed data file is referred to as the second file format. As described above, the first file format can be a ZIP format, and the second file format can be a RAFS format. The above-mentioned specific external storage space is external, that is, not located inside any server, in combination Figure 1 with the examples in the above, the external storage space is, for example, the storage space L3 of the OSS.
[0065] Assuming that the application code file in the original ZIP format of the user is stored in the storage space L3, the storage address C1 in the storage space L3 is provided to the management component. Then, the management component can trigger the format conversion process for the application code file in the ZIP format. The management component can complete the conversion process itself, or complete the conversion process through other functional components.
[0066] For example, as shown in Figure 1 , the function calculation service system can further include a file conversion component for converting the compressed file in the first file format corresponding to the application code file into a file in the second file format, that is, converting the application code file in the ZIP format into a file in the RAFS format, and the file in the RAFS format includes the metadata file and the compressed data file. The file conversion component can be deployed in all or part of the servers in the above-mentioned multiple servers, or can be deployed independently of these servers.
[0067] Specifically, the management component can send a file conversion command carrying the above-mentioned storage address C1 and storage addresses C2 and C3 to the file conversion component, wherein the storage address C1 is the storage address of the application code file in the ZIP format in the storage space L3, the storage address C3 is the destination storage address to which the converted file in the RAFS format needs to be stored in the storage space L3, and the storage address C2 is the destination storage address to which the converted file in the RAFS format needs to be stored in the storage space L2. Based on the file conversion command, the file conversion component reads and fully decompresses the application code file in the ZIP format from the storage address C1, converts it into a file in the RAFS format, stores the file in the RAFS format into the above-mentioned storage addresses C2 and C3, and can feed back confirmation information to the management component after successfully completing the conversion.
[0068] The above-mentioned example is based on the assumption that the external storage space includes the storage space L2 and the storage space L3. In fact, if the external storage space can also include only one of the two.
[0069] The running environment configuration information corresponding to the application code file submitted by the user can also be stored in the management and control component. Specifically, the management and control component can store the correspondence between the user identifier, the application code file identifier, the running environment configuration information, and the storage addresses of the application code file in the two file formats in the respective external storage spaces. Based on this, when the user terminal triggers a running request for the application code file, the management and control component can determine the corresponding running environment configuration information and the storage addresses of the application code file in the two file formats in the respective external storage spaces based on the user identifier and the application code file identifier included in the running request. When sending a container creation request to the selected target server, the container creation request can carry the user identifier, the application code file identifier, the running environment configuration information, and the storage addresses of the application code file in the two file formats in the respective external storage spaces for use in the target container creation process.
[0070] It should be noted that in actual application, in addition to creating the application code file, the user can also update the application code file and / or the running environment configuration information.
[0071] When the management and control component receives an application code file update request triggered by the user terminal, if the update request only indicates that the running environment configuration information of the original application code file is updated, the management and control component sends a corresponding notification to the server that has built the container corresponding to the application code file, so that the server updates the running environment configuration information of the built container, such as adjusting the number of CPU cores, memory capacity, etc. according to the indication in the update request. If the update request indicates that the user has updated the application code file, i.e., from the old version to the new version, the management and control component can trigger the conversion and storage process of the ZIP format application code file of the new version to the RAFS format, and then create the target container corresponding to the updated application code file when the user triggers a running request for the new application code file.
[0072] In addition, it should be noted that the application code file created by the user includes at least one of the following: user-written code and user-referenced public layer function. Simply put, the user-written code refers to the code written by the user independently, and in the writing process, the user can refer to the public layer function provided by the function computing service system or the custom public layer function. The public layer function can be regarded as a special code file, and the dependent public library can be extracted as a public layer function to reduce the size of the code package during deployment and update.
[0073] That is, if the user refers to the public layer function during the process of writing the code, finally two application code files can be formed, one is the code file written by the user himself, and the other is the code file corresponding to the public layer function referred to by the user, when the referred public layer function is multiple, each public layer function corresponds to an application code file. No matter which application code file is described above, the processing mode in the process of creating and starting the container is similar.
[0074] The above introduces the main functions of different component units in the function calculation service system, and the following embodiments are combined to explain the process of creating and starting the container in detail.
[0075] Figure 3 A flowchart of a container starting method provided by the embodiment of the application is shown in the figure, and the method can be executed by any server in the system shown in the figure, such as the server shown in the figure, and the method comprises the following steps. Figure 1 Figure 3
[0076] 301. Obtain the running environment configuration information of the application code file.
[0077] 302. Create a target container for running the application code file in the server according to the running environment configuration information.
[0078] 303. Obtain the metadata file from the target storage space in which the metadata file and the compressed data file corresponding to the application code file are stored, so as to transmit the metadata file into the target container, and the metadata file stores the directory index information of each data block in the data file.
[0079] 304. In response to the starting data reading request triggered by the target container according to the directory index information, read the corresponding starting data from the target storage space, and transmit the decompressed starting data to the target container, so as to make the target container run the starting data to complete the starting of the target container.
[0080] As described above, the container creation request sent by the management component and received by the server can include the running environment configuration information of the application code file, the identification of the application code file, and the storage address of the application code file in the external storage space in the two file formats. In addition, the container creation request can optionally include the number of target containers to be created and other information.
[0081] The server obtains the running environment configuration information of the application code file contained in the container creation request, and can first complete the initial target container creation process according to the running environment configuration information: creating a virtual machine in the server, and creating a target container for running the application code file in the virtual machine. Of course, if the container creation request contains the target container quantity information, the number of created virtual machines and the number of target containers are consistent with the target container quantity carried in the container creation request. Since the creation process of each target container is the same, the number is not distinguished here.
[0082] In the embodiment of the application, the target container needs to be created first, and the corresponding virtual machine needs to be created to create the target container in the virtual machine, so the virtual machine and the target container therein can be considered to have the same life cycle, and the corresponding running environment configuration information can be considered to be the same. As described above, the running environment configuration information can include language type (such as Java, nodejs, etc.), network configuration (such as whether to access the public network), required memory size, CPU core number, etc. Based on the running environment configuration information, the corresponding memory, CPU resources are allocated in the server, and the corresponding network and language environment configuration is performed to complete the initial creation of the virtual machine and the target container.
[0083] In addition, in the process of creating the virtual machine, the configuration file used to create the virtual machine can contain the running environment configuration information described above, and can also include a configuration parameter: the file path information of the metadata file and the compressed data file corresponding to the server. In this way, the created virtual machine can know which file path information needs to be read from the server subsequently.
[0084] Based on this, if the file path information is referred to as second file path information, the virtual machine can be created in the server according to the running environment configuration information and the second file path information when the virtual machine is created.
[0085] The second file path information on the server is determined by the following method: according to the first file path information of the metadata file and the compressed data file in the target storage space, the second file path information of the metadata file and the compressed data file mapped to the server is determined.
[0086] The target storage space can be a storage space L1 located in the server, or an external storage space Lx not located in the server. For example, if the external storage space only contains Figure 1 The target storage space can also be a storage space L2 or a storage space L3. If the external storage space only contains Figure 1The storage spaces L2 and L3 are shown in the diagram, so the target storage space can also be storage space L2.
[0087] Specifically, assume that the storage space associated with the server includes a first storage space located on the server and a second storage space not located on the server. For example, the first storage space is the server's local disk, i.e., the aforementioned storage space L1, and the second storage space is the aforementioned external storage space. Optionally, assume there is only one external storage space. To avoid ambiguity, we assume here that the second storage space is storage space Lx.
[0088] If storage space L1 contains metadata files and compressed data files, then storage space L1 is determined as the target storage space. At this point, the first file path information of the metadata files and compressed data files in storage space L1 can be mapped to the server, forming the second file path information in the server's file system.
[0089] If storage space L1 does not store the metadata file and compressed data file, but storage space Lx stores the metadata file and compressed data file, then the target storage space is determined to be storage space Lx. In this case, the first file path information of the metadata file and compressed data file in storage space Lx can be mapped to the server to form the second file path information in the server's file system.
[0090] To facilitate understanding of the above mapping relationship, combined with Figure 4 Example description.
[0091] exist Figure 4 In this context, assuming the metadata file is the `rafs.meta` file shown in the diagram, the compressed data files are those with the `rafs.blob` extension, as illustrated in the diagram. Figure 4 In this context, assuming storage space Lx is provided by NFS, the first file path information for these two files within storage space Lx is as follows:
[0092] / NFS / fc / code / functiona / usercodedir / rafs / rafs.meta
[0093] / NFS / fc / code / functiona / usercodedir / rafs / rafs.blob
[0094] NFS indicates the type of storage space.
[0095] Assume that in storage space L1, the first file path information of these two files is as follows:
[0096] / fc / code / functiona / usercodedir / rafs / rafs.meta
[0097] / fc / code / functiona / usercodedir / rafs / rafs.blob
[0098] A default root directory, such as / local, can be set in the file system local to the server, and the second file path information mapped to the server according to the above first file path information can be:
[0099] / local / fc / code / functiona / usercodedir / rafs / rafs.meta
[0100] / local / fc / code / functiona / usercodedir / rafs / rafs.blob
[0101] As can be seen, the mapping result actually establishes a mapping relationship between the second file path information of the above two files in the file system local to the server and the first file path information of the two files in the target storage space (storage space L1 or storage space Lx). If the two files are stored in storage space L1, then during the creation process of the virtual machine and the target container, only the two files stored in storage space L1 can be used.
[0102] In summary, after creating the virtual machine in the server according to the running environment configuration information and the second file path information, and creating the target container in the virtual machine, the starting process of the target container can be performed.
[0103] To start the target container, first, the metadata file needs to be parsed into the virtual machine and the target container, so that the target container can know which sub-code files are included in the application code file.
[0104] In summary, the metadata file needs to be obtained from the target storage space storing the metadata file and the compressed data file corresponding to the application code file, so as to transmit the metadata file into the virtual machine and the target container.
[0105] Specifically, the metadata file can be read from the target storage space according to the mapping relationship between the second file path information and the first file path information in the target storage space, the metadata file is parsed to obtain the directory index information of each data block in the compressed data file stored in the metadata file, and then the directory index information is transmitted into the virtual machine in the form of a directory, wherein the directory index information is opened in a read-only form in the virtual machine to avoid modification.
[0106] In actual application, the metadata file can be transmitted into the virtual machine in a file sharing manner (for example, a virtual file system technology: virtio-fs technology).
[0107] Then, the virtual machine can mount the directory index information in the form of a directory into the target container, and the directory index information is also opened in the form of a directory in the target container and is set to a read-only mode.
[0108] As described above, in actual application, the application code file can be a user-written code or one or more public layer functions. Figure 5 As shown in FIG. 1, if the application code file is a user-written code, a code root directory: / code can be set in the virtual machine, and it is assumed that the target container also sets the root directory, so that the directory structure reflecting the directory index information in the metadata file is stored in the root directory. If the application code file is at least one public layer function, in the virtual machine, each metadata file corresponding to the public layer function can correspond to a layer root directory, for example, the layer root directories: / layer1 and / layer2 corresponding to the two public layer functions in the figure, but when mounted into the target container, only one layer root directory: / opt can be set in the target container, so that the directory index information in the metadata files corresponding to the two public layer functions under / layer1 and / layer2 needs to be merged into one directory structure to be mounted into the layer root directory / opt in the target container. The merging manner can be implemented by using existing related technologies, which will not be described here.
[0109] At this point, the directory index information contained in the metadata file is mounted into the target container, and then the target container can trigger a start data reading request based on the local directory index information. Specifically, the data required by the target container is called start data, and the start data reading request triggered by the target container contains the directory index information corresponding to the start data. The virtual machine triggers a corresponding reading instruction to the file system of the server based on the start data reading request, and the server further reads the corresponding start data from the compressed data file according to the directory index information corresponding to the start data from the target storage space storing the metadata file and the compressed data file on demand, and transmits the decompressed start data to the target container, so that the target container runs the start data to complete the start of the target container.
[0110] Therefore, in the embodiment of the application, the server side providing the function calculation service only needs to read and parse the metadata file from the target storage space to the target container, so that the target container can trigger a reading request for starting data on demand based on the directory index information contained in the metadata file, so that only the data required for starting needs to be read on demand from the compressed data file, without the need to download and decompress all the data files, thereby reducing the download and decompression load of the data and improving the container starting speed.
[0111] Even if the data amount of the application code file itself is large, the data amount of the corresponding metadata file is relatively small, so downloading and reading the metadata file will not take a long time and will not affect the starting speed of the target container.
[0112] The above external storage space can be based on serverless, that is, the storage resources provided by the cloud vendor can be used on demand and can be dynamically expanded, the user's operation and maintenance cost will be lower, and the size of the data of the application code file will not be limited.
[0113] After the target container is started, the application code file can be run to complete the processing task of the user input data. In short, the management component can send a task processing request to the server, and the task processing request includes the to-be-processed data and the application code file identifier and the like. The to-be-processed data is sent to the target container, and the target container can trigger a reading request for different sub-code files in the application code file on demand according to the directory index information in the local metadata file to complete the processing of the to-be-processed data step by step through each read sub-code file. It should be noted that based on the above directory index information, the target container does not need to read all the contents contained in the application code file into the target container at one time, which can reduce the consumption of resources such as memory and CPU of the target container, because actually, many data in the application code file may not be used in the process of executing the task processing.
[0114] The following Figure 6 In the embodiment shown in the figure, it is assumed that the server executing the target container startup is associated with at least two storage spaces, and the at least two storage spaces include a first storage space in the server and a second storage space not in the server. Based on the above example, the first storage space can be a server local disk space, that is, a storage space L1, and the second storage space can be an external storage space such as NFS or OSS, denoted as a storage space Lx. That is, in the embodiment shown in the figure, the server executing the target container startup is associated with at least two storage spaces, and the at least two storage spaces include a first storage space in the server and a second storage space not in the server. Figure 6 In the embodiment shown in the figure, it is assumed that a two-level storage composed of the first storage space and the second storage space is formed.
[0115] At this time, the second storage space is used to persistently store the metadata file and the compressed data file. That is, after the application code file provided by the user in the ZIP format is converted into a file in the RAFS format, the file in the RAFS format and the file in the ZIP format are both persistently stored in the second storage space. The file in the RAFS format includes the metadata file and the compressed data file.
[0116] Figure 6 A flowchart of a container starting method provided for an embodiment of the application, which can be executed by any server in the system shown in FIG. 1, such as the server shown in FIG. 2, includes the following steps. Figure 1 Figure 6
[0117] 601. Obtain the running environment configuration information of the application code file.
[0118] 602. Determine whether the first storage space contains the metadata file and the compressed data file corresponding to the application code file. If yes, execute step 603; otherwise, execute step 604.
[0119] 603. Determine that the target storage space is the first storage space, create a virtual machine in the server according to the running environment configuration information, create a target container for running the application code file in the virtual machine, and obtain the metadata file from the first storage space to transfer the metadata file into the virtual machine and the target container.
[0120] 604. Determine whether the second storage space contains the metadata file and the compressed data file corresponding to the application code file. If yes, execute step 605; otherwise, execute step 608.
[0121] 605. Determine that the target storage space is the second storage space, create a virtual machine in the server according to the running environment configuration information, create a target container for running the application code file in the virtual machine, and obtain the metadata file from the second storage space to transfer the metadata file into the virtual machine and the target container.
[0122] 606. Download the metadata file and the compressed data file from the second storage space to the first storage space, and after the metadata file and the compressed data file are downloaded to the first storage space, hot switch the target storage space to the first storage space.
[0123] 607. In response to a starting data reading request triggered by the target container according to the directory index information in the metadata file, read the corresponding starting data from the target storage space, and transfer the decompressed starting data to the target container, so that the target container runs the starting data to complete the starting of the target container.
[0124] 608、download the compressed file in the first file format corresponding to the application code file from the second storage space to the first storage space, fully decompress the compressed file in the first file format in the first storage space, and start the target container according to the fully decompressed application code file.
[0125] In the embodiment, the second storage space is used to permanently store the files in the second file format, i.e., the metadata file and the compressed data file, and the compressed file in the first file format, i.e., the file obtained after the application code file is compressed in the first file format. The compressed file in the first file format is used as a supplement when the file in the second file format is damaged. In fact, the process of creating and starting the target container using the compressed file in the first file format belongs to the prior art, which is not described in the embodiment.
[0126] The first storage space is located locally on the server. As described above, if there is no data to be processed in a set time after the container corresponding to the application code file is created and started, the created container will be deleted to reduce the waste of resources in the server. When the user needs to use the application code file to perform a task later, the corresponding container will be created again. In order to improve the utilization of the first storage space, garbage collection can be performed on the data stored in the first storage space. For example, when the storage capacity meets the first set data deletion condition, some data stored in the first storage space, e.g., data that has not been accessed recently (in a set time period), is deleted. Therefore, if the metadata file and the compressed data file corresponding to the application code file belong to such data, they can be deleted from the first storage space.
[0127] As can be seen, in the embodiment, there are two data sources for the server to obtain the metadata file and the compressed data file, i.e., the first storage space and the second storage space. Therefore, when creating and starting the virtual machine and the target container, it can be determined which data source is used first. The principle of selecting the data source is as follows: if the metadata file and the compressed data file are saved in the first storage space locally on the server, the data source is determined to be the first storage space, i.e., the target storage space is determined to be the first storage space; otherwise, it is determined whether the metadata file and the compressed data file are stored in the second storage space. If the metadata file and the compressed data file are stored in the second storage space, the data source is determined to be the second storage space, i.e., the target storage space is determined to be the second storage space.
[0128] At this time, optionally, on one hand, the metadata file can be read from the second storage space to be imported into the virtual machine, the target container; on the other hand, the metadata file and the compressed data file are downloaded from the second storage space to the first storage space, and when the downloading is completed, the data source is hot switched to the first storage space. Because the first storage space is local to the server, compared with the second storage space, better access performance can be obtained. Subsequently, when starting reading of data, reading of relevant sub-code files for processing of to-be-processed data, etc., the first storage space can be used as the data source. Wherein, the so-called hot switching refers to a switching mode without affecting the running of the container.
[0129] If the metadata file and the compressed data file are not stored in the second storage space, for example, the conversion from the ZIP format to the RAFS format fails, or the conversion is in progress, or some abnormal conditions occur in the process of storing the converted file into the second storage space, so that the file is not successfully stored into the second storage space, at this time, the ZIP format compressed file stored in the second storage space can be used to start the target container. At this time, the ZIP format compressed file stored in the second storage space needs to be downloaded into the first storage space in full, and full decompression is performed, so that the target container is started and subsequent task execution is performed according to the decompressed application code file.
[0130] As can be seen, as long as the metadata file and the compressed data file exist in the storage space local to the server, the external storage space does not need to be accessed, the delay of starting the target container can be reduced, and reliable access stability can be provided.
[0131] In addition, in fact, after the user updates or creates the application code file, the conversion of the ZIP format compressed file to the RAFS format file is performed asynchronously, that is, after the ZIP format compressed file is stored into the external storage space, the original application code file is read and decompressed, and the conversion to the RAFS format is performed. Even if the conversion fails or other abnormal conditions occur, the original ZIP format compressed file can be used to create and start the target container, so that the user can use the updated application code file.
[0132] In fact, the number of target containers that need to be created in the server is large, such as the number of target containers indicated by the user end to be created, or because the processing task of the to-be-processed data of the user end belongs to an offline type task, the creation and deletion of the container need to be performed relatively frequently, therefore, in order to further improve the access performance, in an optional embodiment, the metadata file and the start-up data read from the first storage space can be stored in the memory for use when another container corresponding to the application code file is created in the server. That is to say, the same content can only be read from the disk (the first storage space) once, and the read content is cached in the memory, and then when other containers corresponding to the application code file are created and started subsequently, the corresponding content can be directly read from the memory, and the disk does not need to be read again.
[0133] The above embodiments introduce the case of two-level caching, and the following Figure 7 In the embodiment shown in the figure, it is assumed that the storage space associated with the server that executes the start-up of the target container includes a first storage space located in the server and a second storage space and a third storage space not located in the server. Based on the above examples, the first storage space can be a local disk space of the server, that is, the storage space L1, the second storage space can be an external storage space provided by, for example, NFS, denoted as the storage space L2, and the third storage space is, for example, a storage space provided by OSS, denoted as the storage space L3. That is, in the Figure 7 In the embodiment shown in the figure, it is assumed that a three-level cache composed of the first storage space L2, the second storage space L2 and the third storage space L3 is formed.
[0134] At this time, the third storage space L3 is used for persistently storing the metadata file and the compressed data file. That is to say, after the application code file provided by the user in, for example, the ZIP format is converted into a file in the RAFS format, both the file in the RAFS format and the file in the ZIP format are persistently stored in the third storage space L3. Among them, the file in the RAFS format contains the metadata file and the compressed data file.
[0135] Figure 7 A flowchart of a container start-up method provided by the embodiment of the application is provided, and the method can be executed by any server in the system shown in the figure, such as Figure 1 The method includes the following steps, as shown in the figure. Figure 7
[0136] 701. Obtain the running environment configuration information of the application code file.
[0137] 702. Determine whether the first storage space contains the metadata file and the compressed data file corresponding to the application code file, if yes, execute step 703, otherwise, execute step 704.
[0138] 703、determining that the target storage space is the first storage space, creating a virtual machine in the server according to the running environment configuration information, and creating a target container for running the application code file in the virtual machine, obtaining the metadata file from the first storage space to transfer the metadata file into the virtual machine and the target container.
[0139] 704、determining whether the second storage space contains the metadata file and the compressed data file corresponding to the application code file, if yes, executing step 705, otherwise, executing step 706.
[0140] 705、determining that the target storage space is the second storage space, creating a virtual machine in the server according to the running environment configuration information, and creating a target container for running the application code file in the virtual machine, obtaining the metadata file from the second storage space to transfer the metadata file into the virtual machine and the target container.
[0141] 706、determining whether the third storage space contains the metadata file and the compressed data file corresponding to the application code file, if yes, executing step 707, otherwise, executing step 709.
[0142] 707、downloading the metadata file and the compressed data file from the third storage space to the first storage space and the second storage space, after the metadata file and the compressed data file are downloaded to the first storage space, switching the target storage space to the first storage space.
[0143] 708、in response to a start data reading request triggered by the target container according to the directory index information in the metadata file, reading the corresponding start data from the target storage space, and transferring the decompressed start data to the target container, so that the target container runs the start data to complete the start of the target container.
[0144] 709、downloading the compressed file in the first file format corresponding to the application code file from the second storage space to the first storage space, fully decompressing the compressed file in the first file format in the first storage space, and starting the target container according to the fully decompressed application code file.
[0145] In this embodiment, the third storage space is used to permanently store the files converted from the application code file into the second file format: the metadata file and the compressed data file, and store the compressed file in the first file format corresponding to the application code file.
[0146] The second storage space and the first storage space can both be subjected to garbage collection.
[0147] For example, when the first storage space meets a first set data clearing condition, some data stored in the first storage space is cleared; when the second storage space meets a second set data clearing condition, some data stored in the second storage space is cleared.
[0148] The first set data clearing condition is, for example, that the storage capacity of the first storage space reaches a set threshold value, and data that has not been accessed in a set time period is cleared. Therefore, if the metadata file and the compressed data file corresponding to the application code file belong to this type of data, they will be cleared from the first storage space.
[0149] The second set data clearing condition is similar, except that the set threshold value corresponding to the storage capacity of the second storage space can be higher than the set threshold value corresponding to the first storage space, and the set time period corresponding to the second storage space can be longer than the set time period corresponding to the first storage space. In short, the data cleaning frequency of the second storage space can be lower than that of the first storage space.
[0150] In this embodiment, the server has two data sources for obtaining the metadata file and the compressed data file, one being the first storage space and the other being the second storage space. Therefore, during the creation and startup of the virtual machine and the target container, it can be determined which data source is currently used. The data source selection principle is as follows: if the first storage space in the server locally stores the metadata file and the compressed data file, it is determined that the data source is the first storage space, i.e., the target storage space is the first storage space; otherwise, it is determined whether the second storage space stores the metadata file and the compressed data file. If the second storage space stores the metadata file and the compressed data file, it is determined that the data source is the second storage space, i.e., the target storage space is the second storage space.
[0151] In addition, if the first storage space does not store the metadata file and the compressed data file, and the third storage space stores the metadata file and the compressed data file, the metadata file and the compressed data file can be downloaded from the third storage space to the first storage space, and then the data source is switched to the first storage space. Similarly, if the second storage space does not store the metadata file and the compressed data file, the metadata file and the compressed data file can also be downloaded from the third storage space to the first storage space. However, if the first storage space already stores the metadata file and the compressed data file, the data source will not be switched.
[0152] When none of the above three storage spaces stores the metadata file and the compressed data file, the compressed file in the first file format is used to start the target container.
[0153] Therefore, the data source can be hot-switched between the first and second storage spaces. Specifically, before the metadata files and compressed data files are fully downloaded to the first storage space, the second storage space can be used as the data source. After the metadata files and compressed data files have been downloaded to the first storage space, the system switches to the first storage space. During this process, there is no impact on the real-time access to the target container's data. Especially since the first storage space is located locally on the server, when the second storage space uses network storage services such as NFS, there is no need to download data; read operations can be performed directly, resulting in good real-time performance and ensuring the startup speed of the target container. The third storage space is used for persistent storage of the metadata files and compressed data files. Even if the metadata files and compressed data files in the first and second storage spaces are cleaned up due to garbage collection, using the metadata files and compressed data files in the third storage space can still achieve a good startup acceleration effect. This is because the directory index information in the metadata files still allows the target container to read and decompress data on demand, without needing to download and decompress the entire data file. Furthermore, if the metadata file and compressed data file are not present in the first and second storage spaces, the metadata file and compressed data file will be downloaded from the third storage space to the first and second storage spaces to restore these two levels of cache, thereby accelerating the creation and startup of subsequent containers.
[0154] Figure 8 This is a flowchart illustrating a container startup method provided in an embodiment of the present invention. This method can be executed by the management component described in the foregoing embodiments, such as... Figure 8 As shown, the method may include the following steps:
[0155] 801. In response to the user's update operation on the application code file, obtain the compressed file in the first file format corresponding to the application code file.
[0156] 802. Unzip the compressed file in the first file format to obtain the application code file.
[0157] 803. Convert the application code file into a second file format file. The second file format file includes a metadata file corresponding to the application code file and a compressed data file. The metadata file stores the directory index information of each data block in the data file.
[0158] 804. Store the file in the second file format in the target storage space so that the server can start and run the target container of the application code file in the server according to the file in the second file format.
[0159] In this embodiment, the user's update operation on the application code file can be to newly edit and generate an application code file, or to upgrade and update an existing application code file (i.e., to change the content therein). In actual applications, it can also include updating the running environment configuration information corresponding to the application code file.
[0160] As described above, the user can log in to the application code file creation interface of the function calculation service system, complete the editing of the user's own application code file in the interface, and trigger a confirmation operation such as "save", "submit", etc. after the editing is completed to trigger the above-mentioned update operation. During the editing process, the above-mentioned selection of the first file format and the like is performed to store the file compressed by the first file format to the target storage space, wherein the target storage space is, for example, the storage space outside the server as exemplified above. The storage address corresponding to the compressed file in the first file format in the target storage space is provided to the management component, the management component can obtain the compressed file in the first file format, decompress it to obtain the original application code file, and then perform the conversion processing of the second file format. The conversion processing of the second file format is described in the foregoing embodiments and will not be described here. Then, the management component can store the file in the second file format to the target storage space for use in the subsequent process of creating a target container. The creation and startup of the target container are described in the foregoing embodiments and will not be described here.
[0161] As described above, the user can log in to the application code file creation interface of the function calculation service system, complete the editing of the user's own application code file in the interface, and trigger a confirmation operation such as "save", "submit", etc. after the editing is completed to trigger the above-mentioned update operation. During the editing process, the above-mentioned selection of the first file format and the like is performed to store the file compressed by the first file format to the target storage space, wherein the target storage space is, for example, the storage space outside the server as exemplified above. The storage address corresponding to the compressed file in the first file format in the target storage space is provided to the management component, the management component can obtain the compressed file in the first file format, decompress it to obtain the original application code file, and then perform the conversion processing of the second file format. The conversion processing of the second file format is described in the foregoing embodiments and will not be described here. Then, the management component can store the file in the second file format to the target storage space for use in the subsequent process of creating a target container. The creation and startup of the target container are described in the foregoing embodiments and will not be described here.
[0162] The implementation process of this embodiment can be understood with reference to the related descriptions in the foregoing embodiments.
[0163] The container startup device of one or more embodiments of the present application will be described in detail below. Those skilled in the art can understand that these devices can be configured using commercially available hardware components through the steps taught by the present solution.
[0164] Figure 9 A structural schematic diagram of a container startup device provided for an embodiment of the present application is shown in FIG. 1, which includes an acquisition module 11, a creation module 12, and a startup module 13. Figure 9
[0165] The acquisition module 11 is configured to acquire the running environment configuration information of the application code file.
[0166] The creating module 12 is configured to create a target container for running the application code file in the server according to the running environment configuration information; and obtain the metadata file from a target storage space in which the metadata file corresponding to the application code file and the compressed data file are stored, and transmit the metadata file into the target container, wherein the metadata file stores directory index information of each data block in the data file.
[0167] The starting module 13 is configured to read corresponding starting data from the target storage space in response to a starting data reading request triggered by the target container according to the directory index information, and transmit the decompressed starting data to the target container, so that the target container runs the starting data to complete the starting of the target container.
[0168] Optionally, the creating module 12 is further configured to: determine second file path information to which the metadata file and the compressed data file are mapped on the server according to first file path information of the metadata file and the compressed data file in the target storage space; create a virtual machine in the server according to the running environment configuration information and the second file path information, and create the target container in the virtual machine; and the metadata file is further transmitted into the virtual machine.
[0169] Optionally, the server is associated with at least two storage spaces, and the at least two storage spaces include a first storage space located in the server and a second storage space not located in the server. Based on this, the creating module 12 is specifically configured to: if the metadata file and the compressed data file are stored in the first storage space, determine that the target storage space is the first storage space; and if the metadata file and the compressed data file are not stored in the first storage space and the metadata file and the compressed data file are stored in the second storage space, determine that the target storage space is the second storage space.
[0170] Optionally, the starting module 13 is further configured to: store the metadata file and the starting data read from the first storage space in the memory, so as to be used when another container corresponding to the application code file is created in the server.
[0171] Optionally, the second storage space is configured to store the metadata file and the compressed data file persistently. Based on this, the apparatus further comprises a switching control module configured to: if the metadata file and the compressed data file are not stored in the first storage space and the metadata file and the compressed data file are stored in the second storage space, download the metadata file and the compressed data file from the second storage space to the first storage space; and switch the target storage space to the first storage space after the metadata file and the compressed data file are downloaded to the first storage space.
[0172] Optionally, the at least two storage spaces comprise a third storage space not located in the server, and the third storage space has a read-write performance inferior to that of the second storage space, and the third storage space is configured to store the metadata file and the compressed data file persistently. Based on this, the switching control module is specifically configured to: if the metadata file and the compressed data file are not stored in the first storage space, download the metadata file and the compressed data file from the third storage space to the first storage space; and switch the target storage space to the first storage space after the metadata file and the compressed data file are downloaded to the first storage space; and if the metadata file and the compressed data file are not stored in the second storage space, download the metadata file and the compressed data file from the third storage space to the second storage space.
[0173] Optionally, the apparatus further comprises a garbage collection module configured to: if a first set data cleaning condition is met, clean the metadata file and the compressed data file stored in the first storage space; and if a second set data cleaning condition is met, clean the metadata file and the compressed data file stored in the second storage space.
[0174] Optionally, the starting module 13 is further configured to: if the metadata file and the compressed data file are not stored in the at least two storage spaces, download the compressed file in a first file format corresponding to the application code file from a storage space not located in the server to the first storage space located in the server, wherein a second file format corresponding to the metadata file and the compressed data file is different from the first file format; fully decompress the compressed file in the first storage space; and start the target container according to the fully decompressed application code file.
[0175] Optionally, the application code file comprises at least one of the following: user-written code, and user-referenced public layer function.
[0176] Figure 9 The apparatus can perform the steps performed by the server in the foregoing embodiments, and the detailed execution process and technical effects are described in the foregoing embodiments, which will not be described here.
[0177] In one possible design, the above Figure 9 The apparatus can perform the steps performed by the server in the foregoing embodiments, and the detailed execution process and technical effects are described in the foregoing embodiments, which will not be described here. Figure 10 The electronic device can include a processor 21, a memory 22, and a communication interface 23.
[0178] In addition, the embodiment of the present application provides a non-transitory machine readable storage medium, and the non-transitory machine readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor can at least implement the container starting method provided in the foregoing embodiments.
[0179] The apparatus embodiments described above are only schematic, and the units described as separate components can or can not be physically separate. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment. Those skilled in the art can understand and implement without creative labor.
[0180] From the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a general hardware platform, and of course can also be implemented by means of a combination of hardware and software. Based on such understanding, the above technical solutions can be embodied in the form of a computer program product, and the present application can be implemented in the form of a computer program product containing computer usable program codes in one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.).
[0181] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of starting a container, characterized by, Applied to a server, the method comprises: Obtaining running environment configuration information of an application code file; Creating a target container for running the application code file in the server according to the running environment configuration information; In the process of initially creating the target container, obtaining a metadata file from a target storage space storing the metadata file and compressed data file corresponding to the application code file, to transmit the metadata file into the target container, the metadata file storing directory index information of each data block in the data file; wherein when the application code file includes a plurality of common layer functions, the metadata files corresponding to the plurality of common layer functions are fused to transmit the fused metadata files into the target container, and the metadata files corresponding to the plurality of common layer functions are respectively transmitted into virtual machines; In response to a start data reading request triggered by the target container according to the directory index information, reading corresponding start data from the target storage space, and transmitting the decompressed start data to the target container, so that the target container runs the start data to complete the start of the target container.
2. The method of claim 1, wherein, The method further comprises: Determining second file path information to which the metadata file and the compressed data file are mapped on the server according to first file path information of the metadata file and the compressed data file in the target storage space; The creating of the target container for running the application code file in the server according to the running environment configuration information comprises: Creating a virtual machine in the server according to the running environment configuration information and the second file path information, and creating the target container in the virtual machine; the metadata file is also transmitted into the virtual machine.
3. The method of claim 1, wherein, The server is associated with at least two storage spaces, including a first storage space located in the server and a second storage space not located in the server; The method further comprises: If the metadata file and the compressed data file are stored in the first storage space, the target storage space is determined as the first storage space; If the metadata file and the compressed data file are not stored in the first storage space, and the metadata file and the compressed data file are stored in the second storage space, the target storage space is determined as the second storage space.
4. The method of claim 3, wherein, The method further comprises: Storing the metadata file and the start data read from the first storage space in the memory for use when another container corresponding to the application code file is created in the server.
5. The method of claim 3, wherein, The second storage space is used for persistent storage of the metadata file and the compressed data file; the method further comprises: If the metadata file and the compressed data file are not stored in the first storage space, and the metadata file and the compressed data file are stored in the second storage space, the metadata file and the compressed data file are downloaded from the second storage space to the first storage space. After the metadata file and the compressed data file are downloaded to the first storage space, the target storage space is switched to the first storage space.
6. The method of claim 3, wherein, The at least two storage spaces include a third storage space not located on the server, the read / write performance of the third storage space being inferior to that of the second storage space, and the third storage space being used for persistent storage of the metadata file and the compressed data file; The method further includes: If the metadata file and the compressed data file are not stored in the first storage space, then the metadata file and the compressed data file are downloaded from the third storage space to the first storage space and the second storage space. After the metadata file and the compressed data file are downloaded to the first storage space, the target storage space is switched to the first storage space; If the metadata file and the compressed data file are not stored in the second storage space, then the metadata file and the compressed data file will be downloaded from the third storage space to the second storage space.
7. The method of claim 6, wherein, The method further includes: If the first set data clearing condition is met, then the metadata file and the compressed data file stored in the first storage space are cleared; If the second set data clearing condition is met, then the metadata file and the compressed data file stored in the second storage space are cleared.
8. The method according to any one of claims 3 to 7, characterized in that, The method further includes: If neither of the at least two storage spaces contains the metadata file and the compressed data file, then the compressed file in the first file format corresponding to the application code file is downloaded from the storage space not located on the server to the first storage space located on the server; wherein the second file format corresponding to the metadata file and the compressed data file is different from the first file format; Fully decompress the compressed files in the first storage space; The target container is started based on the application code file after full decompression.
9. The method according to any one of claims 1 to 7, characterized in that, The application code file includes at least one of the following: user-written code, or user-referenced public layer functions.
10. An electronic device, comprising: include: The device includes a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the container startup method as described in any one of claims 1 to 9.
11. A non-transitory machine-readable storage medium, comprising: The non-transitory machine-readable storage medium stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the container startup method as described in any one of claims 1 to 9.
12. A function computing service system, characterized by, include: Control and management components, multiple servers, and multiple storage spaces associated with the multiple servers; The plurality of storage spaces include storage spaces located in the plurality of servers and storage spaces not located in the plurality of servers; The management and control component is configured to receive a running request triggered by a user terminal for an application code file, determine whether a created container corresponding to the application code file is available according to locally stored container running state information corresponding to the application code file, and trigger a container creation request corresponding to the application code file to a target server in the plurality of servers if it is determined that the created container corresponding to the application code file is not available. The target server is configured to perform the container starting method according to any one of claims 1 to 9. The plurality of storage spaces are configured to store a metadata file and a compressed data file corresponding to the application code file.
13. The system of claim 12, wherein, Further comprising: A file conversion component configured to convert a compressed file in a first file format corresponding to the application code file into a file in a second file format, wherein the file in the second file format includes the metadata file and the compressed data file.
Citation Information
Patent Citations
Code loading method, device and system under Serverless architecture and storage medium
CN113282377A
System platform architecture, function publishing method and device, platform and storage medium
CN114816445A