Instance starting acceleration method and related device
By obtaining and utilizing snapshots and templates of microservice instances, and directly filling the required data in the memory, the problem of microservice startup delay is solved, and the efficiency and elastic scalability of cloud deployment are improved.
Patent Information
- Application Number
- CN202410194686.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-02-28
- Filing Date
- 2024-02-21
- Publication Date
- 2024-09-06
AI Technical Summary
When microservices are deployed on the cloud, instance startup delays are long, which limits elastic scaling capabilities. Especially for Java microservices, the startup time is too long due to the complex framework and class loading process.
By obtaining snapshots and templates of launched instances, recording and describing their runtime data and storage methods, and directly filling the required data in memory to skip the initialization process, the instance state can be quickly restored and tedious initialization steps can be avoided.
It significantly reduces instance startup time, improves the elastic scalability of microservices deployed on the cloud, and reduces user access latency.
Smart Images

Figure CN118605960A
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the State Intellectual Property Office on February 28, 2023, with application number 202310224118.1 and invention name “A startup acceleration method and related device of an example”, the entire contents of which are incorporated by reference in this application. Technical Field
[0002] The present application relates to the field of computer technology, and more particularly to a startup acceleration method and related devices of an example. Background Art
[0003] Microservices is an architectural and organizational approach to software development that enables software to be composed of multiple small, independent services that can be managed by small, independent teams. Microservice architecture can make applications easier to scale and faster to develop, thereby accelerating innovation and shortening the time to market for new application features.
[0004] Currently, microservices are deployed in a multi-instance manner to support high-concurrency user access. In addition, the services in these microservice architectures are generally run on the cloud to take advantage of the dynamic scalability of cloud resources.
[0005] However, for most microservices, such as Java microservices, since microservices themselves often use more components and the startup process is more complicated, the startup delay of the instances in the microservices is longer, which greatly limits the elastic scaling of microservices when deployed on the cloud. Summary of the invention
[0006] The present application provides a method for accelerating the startup of an instance, which can accelerate the startup process of the instance and reduce the startup delay of the instance.
[0007] The first aspect of the present application provides a method for accelerating the startup of an instance, which can be applied to accelerating the startup of instances such as processes, threads or hyperthreading. In this method, an instance snapshot and an instance template are first obtained. Among them, the instance snapshot is obtained based on the first instance that has been started, and the instance snapshot is used to indicate the data generated by the first instance during operation (including all data generated by the first instance during the startup phase). Specifically, the instance snapshot records the runtime memory state of the first instance (that is, the data corresponding to the first instance in the memory under a certain instantaneous state), that is, the instance snapshot records the data on which the running of the first instance depends. The instance template can be created based on the instance snapshot, and is used to indicate how the data is stored in the memory during the startup of the first instance. That is, the instance template describes how the data generated by the first instance during operation is specifically stored in the memory.
[0008] Then, based on the instance template, the data indicated in the instance snapshot is stored in the first memory, so that the memory is filled with the data required in the instance startup process.
[0009] Finally, after the data indicated by the instance snapshot is stored in the first memory in a specified manner, it means that all data required to start the second instance has been prepared, so the second instance can be resumed based on the data stored in the first memory.
[0010] In this solution, by obtaining the instance snapshot created based on the started instance and the instance template created based on the instance snapshot, the data generated by the started instance during operation can be obtained and the storage method of this data in the memory can be known. Then, the data indicated by the instance snapshot is filled into the corresponding position of the current node memory with reference to the storage method indicated by the instance template, so as to restore the running instance based on the data stored in the memory, avoid the instance initialization process with a long execution delay (that is, the process of code compilation and execution), and improve the speed of instance startup.
[0011] In one possible implementation, the first memory is a shared memory, and different instances on the same electronic device can share the data in the first memory, so the data stored in the first memory can be used to restore one or more instances of the same type. Among them, multiple instances of the same type refer to instances restored based on the same data. For example, in the case where the instance is a process, multiple processes of the same type may refer to multiple different processes pulled up based on the same executable code in the first memory. In this way, when multiple instances of the same type are started on the same electronic device, the shared data in the shared memory can be used to quickly start the instance, avoiding the process of storing the data indicated in the instance snapshot in the memory again, thereby increasing the speed of instance startup.
[0012] In a possible implementation, the above instance template is also used to indicate the running state of the first instance at the creation time of the instance snapshot, that is, the specific state of the first instance when the instance snapshot is created. In this way, when the second instance is resumed based on the data stored in the first memory, the instruction in the first address of the first memory can be jumped to and executed based on the running state indicated by the instance template. Among them, the instruction in the first address belongs to the data stored in the first memory, and the instruction in the first address corresponds to the instruction executed by the first instance in the running state. In this way, when the instruction in the first address of the first memory is executed, the running state of the second instance is the same as the running state of the first instance at the creation time of the instance snapshot. For example, in the actual application process, according to the address space pointer of the first instance indicated by the second type of data in the instance template, the "jump" instruction of the assembler is called to jump to the state of the first instance executed to the creation time of the instance snapshot, so as to resume the running of the second instance.
[0013] In this solution, by indicating the running status of the first instance at the creation time node of the instance snapshot in the instance template, after restoring the data required for the instance operation to the first memory, it is possible to jump back to the corresponding instance running status to achieve the recovery of the second instance, thereby eliminating the need to execute the tedious process required to execute the instance during the initial startup (such as the business initialization phase introduced above), effectively improving the startup speed of the instance.
[0014] In a possible implementation, the instance template is specifically used to indicate the size of the memory area occupied by the data indicated in the instance snapshot, that is, the size of the memory area that the data generated by the first instance needs to occupy. In this way, when storing the data indicated in the instance snapshot in the first memory based on the instance template, it can be first determined based on the size of the memory area to store the first area in the first memory; and then the data indicated in the instance snapshot is stored in the first area in the first memory. The size of the first area is consistent with the size of the memory area indicated in the instance template, that is, the first area is greater than or equal to the size of the memory area indicated in the instance template.
[0015] In this solution, by determining a memory area of a size that meets the requirements in the first memory based on the instructions of the instance template to store the data indicated in the instance snapshot, it can be ensured that the data required to run the second instance can be stored in a continuous memory area, avoiding memory pollution and affecting the normal operation of the second instance.
[0016] In one possible implementation, the instance template is also specifically used to indicate the data structure of the data indicated in the instance snapshot. In this way, when the data indicated in the instance snapshot is stored in the first memory based on the instance template, the instance snapshot can be first parsed based on the data structure indicated by the instance template to obtain the data indicated in the instance snapshot.
[0017] For example, when the instance snapshot is obtained by serializing data generated by the first instance, the instance snapshot can be deserialized based on the data structure indicated by the instance template, thereby restoring the data actually indicated in the instance snapshot.
[0018] In one possible implementation, the instance template is specifically used to indicate one or more of the following: the running status of the first instance at the creation time of the instance snapshot, the size of the memory area occupied by the data indicated in the instance snapshot, and the data structure of the data indicated in the instance snapshot.
[0019] In a possible implementation, the operating environment of the second instance is a virtual machine, a container, or a container group.
[0020] In a possible implementation, the second instance is used to access the Backend as a Service (BaaS) through a proxy component, and the BaaS is used to provide data services for the operation of the second instance, such as cloud data / file storage, account management, message push, social media integration and other services. In addition, during the process of resuming the operation of the second instance, the proxy component maintains a connection with the BaaS. The proxy component is pre-established, and the proxy component is used to maintain a connection with the BaaS so as to proxy the access behavior of the second instance to the BaaS at any time.
[0021] In a possible implementation, the connection between the proxy component and the BaaS may be obtained. After the second instance resumes operation, the connection between the proxy component and the BaaS is returned to the second instance, so that the second instance can access the BaaS by accessing the proxy component.
[0022] In this solution, a pre-established proxy component is used to maintain the connection with BaaS, and the proxy component is used to proxy the instance's access behavior to BaaS. This allows the instance to not need to re-establish a connection with BaaS during startup, reducing the time spent on establishing a connection and improving the startup speed of the instance.
[0023] In a possible implementation, the instance snapshot and the instance template are obtained from the running node of the first instance through the network. That is, the running node of the first instance creates the instance snapshot and the instance template based on the running first instance in advance, and then transmits the instance snapshot and the instance template to the running node of the second instance, so as to restore the running of the second instance based on the instance snapshot and the instance template.
[0024] In a possible implementation, the first instance and the second instance are processes, threads, or hyperthreads.
[0025] In a possible implementation, the first instance and the second instance are instances in a microservice architecture. In a microservice architecture, an application is composed of many loosely coupled and independently deployable smaller services, and the first instance and the second instance can be instances of one of the services, which can implement a set of independent features or functions.
[0026] The second aspect of the present application provides an instance startup acceleration device, including: an acquisition module, used to acquire an instance snapshot and an instance template, the instance snapshot is obtained based on a started first instance, the instance snapshot is used to indicate the data generated by the first instance during operation, and the instance template is used to indicate the storage method of the data in the memory during the startup of the first instance; a processing module, used to store the data indicated in the instance snapshot in the first memory based on the instance template; the processing module is also used to resume the operation of the second instance based on the data stored in the first memory.
[0027] In a possible implementation, the first memory is a shared memory, and the data stored in the first memory is used to restore one or more instances of the same type.
[0028] In one possible implementation, the instance template is also used to indicate the running status of the first instance at the creation time of the instance snapshot; the processing module is also used to: based on the running status indicated by the instance template, jump to the instruction in the first address of the first memory and execute the instruction, wherein, when executing the instruction, the running status of the second instance is the same as the running status of the first instance at the creation time of the instance snapshot.
[0029] In one possible implementation, the instance template is specifically used to indicate the size of the memory area occupied by the data indicated in the instance snapshot; the processing module is also used to: determine a first area in the first memory for storing data based on the size of the memory area; and store the data indicated in the instance snapshot in the first area in the first memory.
[0030] In a possible implementation, the instance template is further used to indicate the data structure of the data indicated in the instance snapshot; the processing module is further used to: parse the instance snapshot based on the data structure indicated by the instance template to obtain the data indicated in the instance snapshot.
[0031] In one possible implementation, the instance template is specifically used to indicate one or more of the following: the running status of the first instance at the creation time of the instance snapshot, the size of the memory area occupied by the data indicated in the instance snapshot, and the data structure of the data indicated in the instance snapshot.
[0032] In a possible implementation, the second instance is used to access the backend as a service BaaS through a proxy component, and BaaS is used to provide data services for the operation of the second instance; during the process of resuming the operation of the second instance, the proxy component maintains a connection with the BaaS.
[0033] In a possible implementation, the acquisition module is further used to acquire the connection between the proxy component and the BaaS; the processing module is further used to return the connection to the second instance after the second instance resumes operation.
[0034] In a possible implementation manner, the instance snapshot and the instance template are obtained from a running node of the first instance through a network.
[0035] In a possible implementation, the first instance and the second instance are processes, threads, or hyperthreads.
[0036] In a possible implementation, the first instance and the second instance are instances under a microservice architecture.
[0037] The third aspect of the present application provides an example startup acceleration device, which includes: a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the example startup acceleration device executes a method as implemented in any one of the first aspect or the second aspect.
[0038] A fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, the computer executes a method as implemented in any one of the first or second aspects.
[0039] A fifth aspect of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute a method as in any one of the implementation modes of the first aspect or the second aspect.
[0040] In a sixth aspect, the present application provides a chip, comprising one or more processors, wherein some or all of the processors are used to read and execute a computer program stored in a memory to execute the method in any one of the implementations of the first or second aspect.
[0041] Optionally, the chip includes a memory, and the memory is connected to the processor through a circuit or wire. Optionally, the chip also includes a communication interface, and the processor is connected to the communication interface. The communication interface is used to receive data and / or information to be processed, and the processor obtains the data and / or information from the communication interface, processes the data and / or information, and outputs the processing results through the communication interface. The communication interface can be an input and output interface. The method provided in the present application can be implemented by one chip, or by multiple chips in collaboration.
[0042] Among them, the technical effects brought about by any design method in the second to sixth aspects can refer to the technical effects brought about by different implementation methods in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a schematic diagram of the startup delay of a Java microservice;
[0044] Figure 2 A schematic diagram of the structure of an electronic device 101 provided in an embodiment of the present application;
[0045] Figure 3 A schematic diagram of a process flow of a startup acceleration method provided in an example of an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a process flow for accelerating the startup of a process based on a process snapshot provided in an embodiment of the present application;
[0047] Figure 5 A schematic diagram of a process of creating multiple processes on node 2 provided in an embodiment of the present application;
[0048] Figure 6 A schematic diagram for comparing the process of starting a process on different nodes provided in an embodiment of the present application;
[0049] Figure 7 A schematic diagram for comparing the process of starting a process based on different methods provided in an embodiment of the present application;
[0050] Figure 8 A schematic diagram of the structure of a starting acceleration device according to an example of an embodiment of the present application;
[0051] Fig. 9 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0052] Fig.10 A schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0054] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0055] To facilitate understanding, some technical terms involved in the embodiments of the present application are first introduced below.
[0056] (1) Microservices
[0057] Microservices is a software development technology - a variation of the service-oriented architecture style. It advocates dividing a single application into a group of small services, which coordinate and cooperate with each other to provide ultimate value to users. Each service runs in its own independent process, and services communicate with each other using lightweight communication mechanisms. Each service is built around a specific business and can be independently deployed to a production environment, a production-like environment, etc.
[0058] In simple terms, microservices are a cloud-native architecture that allows a single application to consist of many loosely coupled and independently deployable smaller components or services, that is, to split a single monolithic application into smaller projects and associated independent services. Among them, a service usually implements a set of independent features or functions, including its own business logic and adapters. The association between each microservice is achieved by exposing APIs. These independent microservices do not need to be deployed in the same virtual machine, the same system, and the same application server.
[0059] (2) Java
[0060] Java is a programming language that is specifically designed for the distributed environment of the Internet. Java has a "look and feel" similar to the C++ language, but it is easier to use than the C++ language and adopts a completely "object-oriented" approach to programming. Applications written in Java can run on a single computer or be distributed on a network of servers and clients.
[0061] Java microservices refer to microservices written in Java.
[0062] (3) Examples
[0063] An instance refers to an entity of an application during its operation. In this embodiment, an instance may be, for example, a process, a thread, or a hyperthread.
[0064] (4) Process
[0065] A process is a running activity of a program in a computer on a certain data set. It is the basic unit for resource allocation in the system and the foundation of the operating system structure. In the early computer structure designed for processes, processes are the basic execution entities of programs; in the contemporary computer structure designed for threads, processes are the containers of threads. A program is a description of instructions, data and their organizational forms, and a process is the entity of a program.
[0066] (5)Thread
[0067] A thread is the smallest unit that an operating system can schedule operations on. A thread is usually contained in a process and is the actual operating unit in the process. A thread refers to a single sequential control flow in a process. A process can have multiple threads running concurrently, and each thread executes different tasks in parallel.
[0068] (6) Hyperthreading
[0069] Hyperthreading refers to simulating the two logical cores inside a multi-threaded processor into two physical chips, allowing a single processor to use thread-level parallel computing and thus be compatible with multi-threaded operating systems and software. In simple terms, hyperthreading refers to two logical threads processed simultaneously by a single processor.
[0070] (7) Snapshot
[0071] A snapshot is a usable copy of a specified data set, which includes an image of the corresponding data at a certain point in time (the time point when the copy starts). Specifically, a snapshot can be a copy of the data it represents, or a replica of the data.
[0072] (8) Instance snapshot
[0073] An instance snapshot is a snapshot of the instantaneous state of the contents of a started instance. Specifically, an instance snapshot includes all data generated by the started instance during its operation.
[0074] (9) Shared Memory
[0075] Shared memory refers to a large amount of memory that can be accessed by different central processing units (CPUs) in a multi-processor computer system.
[0076] (10) Copy-on-write (COW)
[0077] Copy-on-write is an optimization strategy in the field of computer programming. The core idea of copy-on-write is that if multiple callers request the same resource (such as data stored in memory or disk) at the same time, they will jointly obtain the same pointer to the same resource. Until a caller tries to modify the content of the resource, the system will actually copy a private copy to the caller, while the original resource seen by other callers remains unchanged. This process is transparent to other callers.
[0078] The main advantage of copy-on-write is that if the caller does not modify the resource, no copy (private copy) is created, so multiple callers can share the same resource when they are just reading.
[0079] (11) Virtual Machine
[0080] A virtual machine is a highly isolated software container that can run its own operating system and applications as if it were a physical computer. A virtual machine behaves exactly like a physical computer and contains its own virtual CPU, internal memory, and network interface card. A virtual machine consists entirely of software and does not contain any hardware components.
[0081] (12) Container
[0082] A container is an independent operating environment, similar to a virtual machine, that isolates applications and their dependencies, allowing for efficient use of computer resources and improved energy efficiency and cost effectiveness. The main difference between containers and virtual machines is the location of the virtualization layer and how operating system resources are used.
[0083] (13)Pod
[0084] Pod is essentially the smallest scheduling unit in Kubernetes. It is an environment that includes resources such as containers, storage space, and network ports. Generally speaking, a node is the host where a Pod actually runs. A node can be a physical machine or a virtual machine. Multiple Pods can run on a node, and each Pod can contain multiple containers. Therefore, a Pod is also called a container group.
[0085] Among them, Kubernetes is used to manage containerized applications on multiple hosts in the cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient.
[0086] (14) Backend as a Service (BaaS)
[0087] BaaS refers to the edge service that integrates the cloud backend for mobile application developers. Specifically, BaaS is a new type of cloud service that aims to provide backend cloud services for applications, including cloud data / file storage, account management, message push, social media integration, etc.
[0088] (15) Remote Procedure Call (RPC)
[0089] RPC is a protocol that requests services from a remote computer over the network without having to understand the underlying network technology. Specifically, for server A and server B, an application is deployed on server A and wants to call the function / method provided by the application on server B. Since they are not in the same memory space, they cannot call directly. Therefore, the semantics of the call and the data of the call need to be expressed over the network. RPC provides a way to obtain services from remote servers over the network.
[0090] (16) Remote Direct Memory Access (RDMA)
[0091] RDMA technology was created to solve the delay of server-side data processing in network transmission. RDMA transmits data directly to the computer's storage area through the network, quickly moving data from one system to the remote system memory without any impact on the operating system, so that not much computer processing power is required. It eliminates the overhead of external memory copying and context switching, thereby freeing up memory bandwidth and CPU cycles to improve application system performance.
[0092] (17) Data Structure
[0093] Data structure is the way computers store and organize data. Specifically, a data structure refers to a collection of data elements that have one or more specific relationships with each other. Usually, a carefully selected data structure can bring higher operating efficiency or storage efficiency.
[0094] (18) Metadata
[0095] Metadata, also known as intermediary data or relay data, is data about data. It is mainly information that describes the attributes of data and is used to support functions such as indicating storage location, historical data, resource search, and file records.
[0096] Currently, for most microservices, such as Java microservices, since microservices themselves often use more components and the startup process is more complicated, the startup delay of the instances in the microservices is long, which greatly limits the elastic scaling of microservices when deployed on the cloud.
[0097] For example, see Figure 1 , Figure 1 This is a schematic diagram of the startup delay of a Java microservice. Figure 1 As shown in the figure, by disassembling the startup delay of Java microservices, we can know the time consumption distribution of each stage in the startup process of Java microservices. Specifically, in the case of cold start, the startup time of Java microservices is mainly divided into two parts, one part is the platform side time consumption, and the other part is the service side time consumption.
[0098] The time consumed on the platform side mainly includes preparation work such as creating the execution environment (such as starting the container) and initializing the execution environment (such as downloading and deploying code packages). This stage can only respond in seconds at most, and accounts for a very low proportion of the overall cold start time, usually less than 5%. Generally speaking, the platform side also supports some optimization methods to further compress the time consumption to milliseconds.
[0099] The time consumed on the service side mainly includes microservice framework startup, business initialization (such as business data initialization) and other actions. This stage is generally time-consuming. Figure 1 In the example shown, the microservice framework startup time accounts for about 30%, and the business initialization time accounts for about 65%. It can be inferred that the actions performed in this phase are the core of the slow startup of Java microservices.
[0100] Taking Java microservices as an example, the main reasons why Java microservices start slowly at the service side stage include the following two points: 1. The framework of Java microservices is complex. As an enterprise-level framework, Java microservices have a large amount of configurable and initialization logic to support a wide range of application requirements, and use complex design patterns to support this flexibility. In many cases, the number of class files that an ordinary Java microservice depends on may be very large. 2. In addition, when Java microservices perform class loading during startup, the overhead of searching and verifying classes will increase with the complexity of the application; at the same time, when the Java microservice is just started, the Just In Time (JIT) optimization is often not triggered, and the hot bytecode still needs to be interpreted and executed. Therefore, most of the cases remain in the interpreted execution, which affects the startup speed of the Java microservice.
[0101] In general, when Java microservices are latency-sensitive microservices deployed on the cloud, when Java microservices are cold started under burst traffic, the user experience may be degraded due to the long startup delay.
[0102] In view of this, an embodiment of the present application provides a method for accelerating the startup of an instance. By obtaining an instance snapshot created based on a started instance and an instance template created based on the instance snapshot, the data generated by the started instance during operation can be obtained and the storage method of this part of data in the memory can be known. Then, the part of data indicated by the instance snapshot is filled into the corresponding position of the current node memory with reference to the storage method indicated by the instance template, so as to realize the recovery of the running instance based on the data stored in the memory, avoid the instance initialization process with a long execution delay (that is, the process of code compilation and execution), and improve the speed of instance startup.
[0103] The startup acceleration method of the example provided in the embodiment of the present application can be applied to electronic devices. Exemplarily, the electronic device can be, for example, a server, a smart phone, a personal computer (PC), a laptop, a tablet computer, a smart TV, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless communication device in industrial control (industrial control), a wireless communication device in a smart grid (smart grid), a wireless communication device in transportation safety (transportation safety), a wireless communication device in a smart city (smart city), a wireless communication device in a smart home (smart home), a router, a switch, a firewall, a hub and other physical devices. In addition, the electronic device can also be a virtualized device such as a virtual machine.
[0104] See also Figure 2 , Figure 2 Schematic diagram of the structure of an electronic device 101 provided in an embodiment of the present application. Figure 2 As shown, the electronic device 101 includes a processor 103, which is coupled to a system bus 105. The processor 103 may be one or more processors, each of which may include one or more processor cores. A display adapter (video adapter) 107, which may drive a display 109, which is coupled to the system bus 105. The system bus 105 is coupled to an input / output (I / O) bus via a bus bridge 111. An I / O interface 115 is coupled to the I / O bus. The I / O interface 115 communicates with a variety of I / O devices, such as an input device 117 (such as a touch screen, etc.), an external memory 121 (for example, a hard disk, a floppy disk, an optical disk or a USB flash drive), a multimedia interface, etc.). A transceiver 123 (which may send and / or receive radio communication signals), a camera 155 (which may capture static and dynamic digital video images), and an external USB port 125. Optionally, the interface connected to the I / O interface 115 may be a USB interface.
[0105] The processor 103 may be any conventional processor, including a reduced instruction set computing (RISC) processor, a complex instruction set computing (CISC) processor, or a combination thereof. Alternatively, the processor may be a dedicated device such as an ASIC.
[0106] The electronic device 101 can communicate with the software deployment server 149 through the network interface 129. Exemplarily, the network interface 129 is a hardware network interface, such as a network card. The network 127 can be an external network, such as the Internet, or an internal network, such as Ethernet or a virtual private network (VPN). Optionally, the network 127 can also be a wireless network, such as a WiFi network, a cellular network, etc.
[0107] The hard disk drive interface 131 is coupled to the system bus 105. The hard disk drive interface is connected to the hard disk drive 133. The internal memory 135 is coupled to the system bus 105. The data running in the internal memory 135 may include an operating system (OS) 137 of the electronic device 101, an application 143, and a scheduler.
[0108] The operating system includes a shell 139 and a kernel 141. Shell 139 is an interface between the user and the kernel of the operating system. The shell is the outermost layer of the operating system. The shell manages the interaction between the user and the operating system: waiting for user input, interpreting user input to the operating system, and processing various operating system output results.
[0109] The kernel 141 consists of those parts of the operating system that manage memory, files, peripherals, and system resources. The kernel 141 interacts directly with the hardware. The operating system kernel usually runs processes and provides communication between processes, provides CPU time slice management, interrupts, memory management, IO management, etc.
[0110] The above describes the application scenarios and execution devices of the method provided in the embodiment of the present application. The following describes the specific execution process of the method provided in the embodiment of the present application. Figure 3 , Figure 3 The following is a flow chart of a startup acceleration method according to an example provided in the present application. Figure 3 As shown, the startup acceleration method of this example includes the following steps 301-304.
[0111] Step 301, obtain an instance snapshot and an instance template. The instance snapshot is obtained based on the started first instance. The instance snapshot is used to indicate the data generated by the first instance during operation. The instance template is used to indicate how the data is stored in the memory during the startup of the first instance.
[0112] In this embodiment, when it is necessary to start an instance, the electronic device can pre-acquire an instance snapshot and an instance template for accelerating the startup of the instance. Among them, the instance snapshot is created after starting the first instance, and the instance snapshot is essentially the instantaneous state of all the contents contained in the started first instance, so the instance snapshot actually records all the data generated by the first instance during operation (including all the data generated by the first instance during the startup phase). In essence, the instance snapshot records the runtime memory state of the first instance (that is, the data corresponding to the first instance in the memory under a certain instantaneous state), that is, the instance snapshot records the data on which the running of the first instance depends. For example, the instance snapshot records the files, sockets, signals used by the first instance during operation, and information about other instances or functions that the first instance needs to call during operation.
[0113] Exemplarily, the instance snapshot may include multiple image files, each image file is used to indicate the unique data generated by the first instance during operation. In addition, different image files can be used to indicate different types of data. For example, the multiple image files in the instance snapshot can be used to indicate the following data: 1. The file opened by the first instance; 2. The register information of the first instance; 3. The pipe symbol of the first instance; 4. The memory address used by the first instance; 5. The memory page used by the first instance; 6. The process and sub-process information scheduled by the first instance. In addition to the above data, the multiple image files in the instance snapshot can also indicate other data according to the actual operation of the instance, which is not specifically limited in this embodiment.
[0114] The first instance is an entity of the application during operation, such as a process, a thread or a hyperthread. This embodiment does not limit the specific structure of the first instance.
[0115] An instance template can be created based on an instance snapshot. Specifically, an instance template can be understood as metadata of an instance snapshot, describing how the data indicated in the instance snapshot is stored in memory. That is, the instance template describes how the data generated by the first instance during operation is stored in memory.
[0116] In a possible example, the instance snapshot and the instance template may be pre-stored in the storage space of the electronic device, and the electronic device obtains the instance snapshot from the local storage space. For example, after the electronic device starts the first instance, the electronic device may create an instance snapshot based on all data generated during the operation of the first instance, and store the instance snapshot in a pre-defined storage space. In this way, even after the first instance is closed, the electronic device can still obtain the instance snapshot obtained based on the first instance started in advance from the storage space.
[0117] In another possible example, the electronic device may also obtain the instance snapshot and the instance template from other places through the network. For example, the electronic device may obtain the instance snapshot and the instance template from other devices (such as physical machines or virtual machines) through the network. The instance snapshot is created by other devices based on the content of the first instance after starting the first instance; the instance template is created by other devices based on the instance snapshot after creating the instance snapshot.
[0118] For example, in the case where multiple servers provide cloud microservices, the electronic device may be server 1. When server 1 needs to start an instance, it may obtain an instance snapshot and an instance template from server 2 through the network, so that server 1 can accelerate the startup of the instance based on the instance snapshot and the instance template. The instance snapshot and the instance template may be created and saved by server 2 after starting the first instance.
[0119] Optionally, when the electronic device obtains the instance snapshot through the network, the electronic device may specifically obtain the instance snapshot from a shared data storage system through the network. The shared data storage system may be a data storage system shared by multiple devices. Multiple devices in the shared data storage system may quickly access data in the data storage system through the network, for example, by quickly reading data in the data storage system through RDMA.
[0120] That is to say, by using a shared data storage system to store instance snapshots and instance templates, electronic devices can quickly obtain instance snapshots from other devices during the execution of an instance cold start, and reduce the transmission delay of the instance snapshot, thereby increasing the speed of subsequent instance startup by the electronic device.
[0121] Step 302: based on the instance template, store the data indicated in the instance snapshot into the first memory.
[0122] In this embodiment, since the instance snapshot records the data generated during the operation of the first instance, the data generated during the operation of the first instance can be restored based on the instance snapshot. In addition, since the instance template indicates how the data generated during the operation of the first instance is stored in the memory, the data restored from the instance snapshot can be stored in the memory of the current node based on the memory storage method indicated by the instance template, thereby filling the memory with the data required during the instance startup process.
[0123] Step 303: Resume the second instance based on the data stored in the first memory.
[0124] After the data indicated by the instance snapshot is stored in the first memory in a specified manner, it means that all data required for the electronic device to start the second instance has been prepared, so the electronic device can start the second instance based on the data stored in the memory. During the startup process of the second instance, the second instance can specifically be running in a virtual machine, a container, or a container group (Pod), that is, the specific operating environment of the second instance is a virtual machine, a container, or a Pod.
[0125] In this embodiment, the first instance and the second instance are instances of the same type (for example, both the first instance and the second instance are processes, threads, or hyperthreads), and can provide the same instance services. The difference is that the first instance and the second instance are running in different operating environments. For example, the first instance and the second instance are running on different physical machines, or on different virtual machines, or on different containers or Pods.
[0126] In this solution, by obtaining the instance snapshot created based on the started instance and the instance template created based on the instance snapshot, the data generated by the started instance during operation can be obtained and the storage method of this data in the memory can be known. Then, the data indicated by the instance snapshot is filled into the corresponding position of the current node memory with reference to the storage method indicated by the instance template, so as to restore the running instance based on the data stored in the memory, avoid the instance initialization process with a long execution delay (that is, the process of code compilation and execution), and improve the speed of instance startup.
[0127] Optionally, the first instance and the second instance may be instances in a microservice architecture. In a microservice architecture, an application is composed of many loosely coupled and independently deployable smaller services, and the first instance and the second instance may be instances of one of the services, capable of implementing a set of independent features or functions.
[0128] The above introduces the process of quickly starting an instance based on an instance snapshot by an electronic device. However, in some scenarios, multiple instances of the same type may need to be started on the same electronic device (for example, the same physical machine or virtual machine) to support high-concurrency user access requirements. In this case, in order to ensure the independent operation of instances of the same type, it is often necessary to isolate different instances through containers or Pods. Based on this, in the scenario of starting multiple identical instances on the same physical machine or virtual machine, this embodiment also provides an implementation method for further accelerating the subsequent instance startup process.
[0129] Exemplarily, in the above step 302, the first memory may be a shared memory, and the data stored in the first memory may be used to restore one or more instances of the same type. The shared memory as the first memory is a memory in an electronic device, and different instances running on the electronic device may share data in the shared memory.
[0130] In this way, when multiple instances of the same type are started on the same electronic device, the shared data in the shared memory can be used to quickly start the instance, avoiding the process of storing the data indicated in the instance snapshot in the memory again, thereby improving the speed of instance startup.
[0131] For ease of understanding, the following will introduce the process of quickly restoring the second instance in combination with the specific contents indicated in the instance snapshot and the instance template.
[0132] First, with respect to the obtained instance snapshot, the instance snapshot may specifically be a plurality of image files obtained by serializing the data generated by the first instance during operation in accordance with a specific specification, and each image file is used to indicate the specific data generated by the first instance during operation. For example, the plurality of image files in the instance snapshot may be used to indicate the following data: 1. the files opened by the first instance; 2. the register information of the first instance; 3. the pipe symbol of the first instance; 4. the memory address used by the first instance; 5. the memory page used by the first instance; 6. the process and subprocess information scheduled by the first instance.
[0133] For instance templates, the instance templates are specifically used to describe the attributes of the data indicated in the instance snapshot, so that the electronic device can store the data indicated in the instance snapshot in the memory of the current electronic device in the same way as the first instance stores this data during operation, ensuring that the data required for instance startup can be correctly stored in the memory.
[0134] Specifically, the data in the instance template may include three types of data. The first type of data is used to describe the data structure of the data indicated in the instance snapshot; the second type of data is used to describe the running status of the first instance at the time of creating the instance snapshot; the third type of data is used to describe the storage status of the data indicated in the instance snapshot in the memory. The following will introduce the specific contents of each type of data.
[0135] The first type of data is actually a data structure that describes data, which may include but is not limited to the following parts: 1. The data structure of metadata information of multiple image files corresponding to the instance snapshot; 2. The data structure description of the files used by the first instance; 3. The data structure description of the register information used by the first instance; 4. The data structure description of the process address space used by the first instance; 5. The data structure of the memory page information of the first instance; 6. The data structure of the first instance and child process information.
[0136] The second type of data indicates the actual running state of the first instance at the time when the instance snapshot is created. The second type of data may specifically include but is not limited to the following multiple parts: 1. The freezing time of the first instance; 2. The address space pointer of the first instance (i.e., the specific location of the first instance); 3. The number of memory pages that the first instance can perform memory copy operations based on the copy-on-write method; 4. The memory page cache size of the first instance; 5. Whether the memory pages of the first instance are lazy loaded.
[0137] The third type of data indicates the storage status of the data indicated in the instance snapshot in the memory. The third type of data may specifically include but is not limited to the following parts: 1. The size information of the memory page used by the first instance, that is, the size of the memory area occupied by the data required to run the first instance. Among them, the size information of the memory page used by the first instance can be described by the page mapping file of the first instance. These page mapping files include which virtual areas corresponding to the first instance need to be filled with data, that is, they record the mapping status of the private virtual pages of the first instance to the physical pages, so that the size information of the memory pages actually used by the first instance can be determined. 2. The actual data that needs to be stored in the memory page in the instance snapshot, that is, which data indicated in the instance snapshot needs to be stored in the memory.
[0138] In the above step 302, the following steps 3021-3023 may be specifically included.
[0139] Step 3021: parse the instance snapshot based on the data structure indicated by the instance template to obtain the data indicated in the instance snapshot.
[0140] Since the first type of data in the instance template is used to describe the data structure of the data indicated in the instance snapshot, the instance snapshot can be parsed based on the first type of data in the instance template, thereby restoring the data indicated in the instance snapshot. Specifically, in the case where the multiple image files corresponding to the instance snapshot are obtained by serializing the data generated by the first instance, the multiple image files corresponding to the instance snapshot can be deserialized based on the data structure indicated by the instance template, thereby restoring the data actually indicated in the instance snapshot.
[0141] Step 3022: Determine a first area in the first memory for storing data based on the size of the memory area.
[0142] In addition, the third type of data in the instance template indicates the size of the memory area that the data generated by the first instance needs to occupy, so based on the size of the memory area, a first area for storing the data generated by the first instance can be determined in the first memory. The size of the first area is consistent with the size of the memory area indicated in the instance template, that is, the first area is greater than or equal to the size of the memory area indicated in the instance template.
[0143] In addition, in the process of determining the first area in the first memory, the three parts of the second type of data mentioned above can also be combined: the number of memory pages on which the first instance can perform memory copy operations based on the copy-on-write method; the memory page cache size of the first instance; whether the memory pages of the first instance are lazy loaded, so as to determine the first area that can effectively implement data storage.
[0144] The first area determined in the first memory may be a continuous memory area, so as to ensure that data required for running the second instance can be stored in a continuous memory area, thereby avoiding memory pollution and affecting the normal operation of the second instance.
[0145] Step 3023: Store the data indicated in the instance snapshot into the first area in the first memory.
[0146] From the above introduction to the instance template, it can be seen that the third type of data in the instance template indicates which data indicated in the instance snapshot needs to be stored in the first memory. Therefore, based on the indication of the instance template, the data indicated in the instance snapshot can be stored in the first area in the first memory, thereby filling the first memory with all the data required to run the second instance, ensuring that the second instance can be restored and run normally later.
[0147] In addition, it should be noted that in order to ensure that the second instance can resume operation smoothly, the external data on which the second instance depends also needs to be consistent with the operating environment of the first instance on the current electronic device. For example, on the current electronic device, the file name and file path of the file required to run the second instance need to be consistent with the file name and file path of the file required to run the first instance. In short, the operating environment of the second instance needs to be consistent with the operating environment of the first instance, so that after restoring the data indicated by the instance snapshot in the memory of the electronic device currently running the second instance, the second instance can be successfully resumed.
[0148] In the above step 303, in the process of resuming the operation of the second instance based on the data stored in the first memory, it can be based on the operation state indicated by the instance template, jump to the instruction in the first address of the first memory and execute the instruction, wherein the instruction in the first address belongs to the data stored in the first memory, and the instruction in the first address corresponds to the instruction executed by the first instance in the operation state. In this way, when the instruction in the first address of the first memory is executed, the operation state of the second instance is the same as the operation state of the first instance at the creation time point of the instance snapshot. For example, in the actual application process, according to the address space pointer of the first instance indicated by the second type of data in the instance template, the "jump" instruction of the assembler is called to jump to the state of the first instance executed at the creation time point of the instance snapshot, thereby resuming the operation of the second instance.
[0149] In this solution, by indicating the running status of the first instance at the creation time node of the instance snapshot in the instance template, after restoring the data required for the instance operation to the first memory, it is possible to jump back to the corresponding instance running status to achieve the recovery of the second instance, thereby eliminating the need to execute the tedious process required to execute the instance during the initial startup (such as the business initialization phase introduced above), effectively improving the startup speed of the instance.
[0150] The following describes a process in which the electronic device continues to start other instances of the same type based on the data stored in the first memory.
[0151] Specifically, after the electronic device resumes running the second instance based on the data stored in the first memory, the new instance can be resumed in the same Pod or other Pods by sharing the data stored in the first memory, thereby enabling the startup of multiple instances based on the same portion of data shared in the first memory. Exemplarily, when the second instance is a process, the recovery of multiple processes of the same type is achieved by sharing physical memory pages (i.e., sharing the first area of data stored in the first memory) by parent-child processes, without having to restore new memory resources from scratch.
[0152] In general, in this solution, when multiple instances of the same type are started on the same electronic device, each instance can be quickly started with the help of the shared instance data in the shared memory, avoiding the process of storing the data indicated by the instance snapshot in the memory again, thereby improving the speed of instance startup.
[0153] Optionally, for most instances, they often need to connect to BaaS during normal operation to obtain the data services provided by BaaS to ensure their normal operation. Therefore, the startup process of most instances also includes the process of establishing a connection with BaaS, such as establishing a Transmission Control Protocol (TCP) connection. Generally, when establishing a TCP connection with BaaS, the instance usually needs to use the three-way handshake protocol to establish a connection, which is slow, further extending the startup delay of the instance.
[0154] Based on this, in this embodiment, a proxy component is pre-established to maintain the connection with BaaS, so that the instance can directly access BaaS through the proxy component, avoiding the need for the instance to establish a connection with BaaS during the startup process, eliminating the delay in connection establishment and improving the startup speed of the instance.
[0155] Exemplarily, after the second instance is started, the second instance can access BaaS through a proxy component to obtain data services provided by BaaS. BaaS is used to provide data services for the operation of the second instance, such as cloud data / file storage, account management, message push, social media integration and other services, and the types of services provided by BaaS are not limited here. In addition, the proxy component is pre-established, and the proxy component is used to maintain a continuous connection with BaaS, so as to proxy the second instance's access behavior to BaaS at any time.
[0156] That is, the second instance is used to access the BaaS through the proxy component, and the BaaS is used to provide data services for the operation of the second instance. In addition, during the process of resuming the operation of the second instance, the proxy component maintains a connection with the BaaS.
[0157] Optionally, before the second instance resumes operation, the connection between the proxy component and BaaS can be obtained in advance. After the second instance resumes operation, the connection between the proxy component and BaaS is returned to the second instance, so that the second instance can access BaaS by accessing the proxy component. In addition, since the proxy component always maintains a connection with BaaS, and the proxy component can proxy the access behavior between the second instance and BaaS, when the second instance accesses the proxy component through RPC, the proxy component can act as an intermediary to convey the access behavior of the second instance to BaaS, and the second instance returns the data service provided by BaaS. That is, the proxy component implements the access behavior of the second instance to BaaS by maintaining a connection with BaaS, and for the second instance, the second instance does not feel the proxy behavior of the proxy component, and the second instance is equivalent to being able to directly obtain the data service provided by BaaS.
[0158] In this solution, a pre-established proxy component is used to maintain the connection with BaaS, and the proxy component is used to proxy the instance's access behavior to BaaS. This allows the instance to not need to re-establish a connection with BaaS during startup, reducing the time spent on establishing a connection and improving the startup speed of the instance.
[0159] The above describes the execution process of the startup acceleration method of the example provided in the embodiment of the present application. For ease of understanding, the specific process of starting the example based on the method provided in this embodiment will be described in detail below with reference to specific examples.
[0160] Specifically, the process of accelerating the startup process will be described in detail below by taking the instance to be started as a process.
[0161] See also Figure 4 , Figure 4 A schematic diagram of a process flow for accelerating the startup of a process based on a process snapshot provided in an embodiment of the present application. Figure 4 As shown, node 1 includes runtime management module (Runtime Manager) 1, snapshot creation module, process template management module 1, and distributed memory data system worker (Worker) 1; node 2 includes runtime management module 2, process template client (Client), distributed memory data system Client, distributed memory data system Worker 2, process template management module 2, shared memory 1, shared memory 2, and proxy components. In addition, in addition to node 1 and node 2, it also includes a distributed memory data system manager (Master) and BaaS.
[0162] Among them, the runtime management module is deployed in the container and is responsible for preparing the operating environment of the application process. The user process snapshot creation module is deployed in the container and is responsible for creating and restoring application snapshots. The distributed memory data system Worker is deployed on the node and is responsible for managing the shared memory on the node. The distributed memory data system Client is deployed in the container and is responsible for the read and write interaction between the Pod and the shared memory on the node. The distributed memory data system Master is responsible for global data management, that is, data management on all nodes. The process template management module is deployed on the node and is responsible for interacting with the snapshot creation module to create a process template. The process template Client is deployed in the container and is responsible for creating the process in the container based on the process template and process snapshot. The proxy component is deployed separately on the node and is responsible for proxying the BaaS connection.
[0163] Specifically, in Figure 4 In the example, the process of accelerating the startup of a process by node 2 based on the process snapshot and process template created by node 1 includes the following steps A1-A4, B1-B7 and C1-C2. Among them, steps A1-A4 are to create a process snapshot and a process template for the already created process A; steps B1-B7 are to restore the process across nodes based on the process snapshot and process instance; steps C1-C3 are to reuse the connection with the backend service through the proxy component.
[0164] Step A1, the runtime management module 1 in the Pod 1 of the node 1 notifies the snapshot creation module 1 to create a process snapshot. In addition, the connection with the BaaS is maintained through the proxy component, so that the process can access the BaaS by accessing the proxy component.
[0165] Specifically, a process A may be pre-created in Pod1. During the creation of the process A, it is often necessary to complete the execution environment initialization (eg, Java virtual machine initialization), framework initialization, and business initialization.
[0166] After the user sends a cold start instruction to the runtime management module 1 , the runtime management module 1 initiates a process of creating a process snapshot and a process template, that is, notifies the snapshot creation module 1 to create a process snapshot.
[0167] In this solution, the ServiceBridge Manager component can be used to manage one or more proxy components. Each proxy component can establish a connection with a different BaaS, and the proxy component always maintains a connection with the BaaS. In this way, when a process needs to access the BaaS, the ServiceBridge Manager component can return the connection between the proxy component and the BaaS to the process, so that the process can access the BaaS through the proxy component without the need for the process to establish a connection with the BaaS.
[0168] Step A2: The snapshot creation module of node 1 creates a process snapshot based on the started process A.
[0169] When process A has been started, the snapshot creation module may kill process A and create a process snapshot based on all data generated by process A during startup and operation, that is, the process snapshot includes all data content of process A at a certain instant during operation. The process snapshot described in this embodiment corresponds to the instance snapshot introduced in the above embodiment.
[0170] The process snapshot may include multiple image files, each of which corresponds to part of the specific information describing process A. For details, please refer to the above introduction.
[0171] Step A3: the process template management module 1 deployed on the node 1 creates a process template according to the process snapshot of the process A.
[0172] The process template corresponds to the instance template introduced in the above embodiment.
[0173] In step A4, the distributed memory data system Client deployed on node 1 synchronizes the process snapshot and process template of process A to the distributed memory data system Master through the distributed memory data system Worker, and the distributed memory data system Master synchronizes the process snapshot and process template to the distributed memory data system Workers on some nodes.
[0174] In short, in this embodiment, the transmission and sharing of process snapshots and process templates on each node are realized through the distributed memory data system Master and the distributed memory data system Worker on each node.
[0175] Step B1, the runtime management module 2 deployed on the Pod 2 of the node 2 sends an instruction to the process template management module 2 to restore the process A across nodes.
[0176] Step B2: the process template management module 2 on the node 2 searches for the process snapshot and process template corresponding to the process A on the distributed memory data system Worker 2 of the node 2.
[0177] Step B3, if the process template management module 2 does not find the process snapshot and process template corresponding to process A on the distributed memory data system Worker 2 of node 2, the distributed memory data system Worker 2 pulls the process snapshot and process template corresponding to process A from the distributed memory data system Master.
[0178] Step B4, the distributed memory data system Worker 2 of node 2 maps an area on shared memory 1 for storing process snapshots and process templates, and stores the area of process snapshots and process templates in shared memory 1; the distributed memory data system Client in Pod 2 of node 2 reads the starting address of the process snapshot and process template in shared memory 1 from the distributed memory data system Worker 2.
[0179] For example, the distributed memory data system Worker 2 may map an area on the shared memory 1 through the mmap() function. The distributed memory data system Client in the Pod 2 of the node 2 may read the starting address of the process snapshot and the process template in the shared memory 1 from the distributed memory data system Worker 2 through an inter-process communication mechanism (such as a UNIX domain socket).
[0180] The shared memory 1 may implement memory copying by copying on write, instead of network transmission, which can accelerate the reading and writing efficiency of process snapshots and process templates.
[0181] Step B5, the process template management module 2 in node 2 notifies the process template Client in Pod 2, so that the process template Client reads the process snapshot and process template corresponding to process A from the shared memory 1 through the distributed memory data system Client in a write-time copy manner.
[0182] The shared memory 1 may be a memory shared by multiple different containers. Therefore, when different containers need to restore the same type of process, they can read the corresponding process snapshot and process template from the shared memory 1 by copying on write, thereby improving the efficiency of reading process snapshots and process templates between different containers.
[0183] In step B6, the process template Client in Pod 2 of node 2 recovers the data in the process snapshot by deserialization based on the indication of the first type of data in the process template, and obtains the data generated by process A during the running. Moreover, the process template Client finds the memory area (i.e., the first area of the above embodiment) in shared memory 2 for storing the data recovered in the process snapshot based on the memory page size information and memory mapping information in the third type of data in the process template, and stores the data recovered in the process snapshot in the found memory area, so as to store the data required for the recovery process in shared memory 2.
[0184] It should be noted that shared memory 2 can be memory shared by the same or different Pods in the same container. Therefore, when multiple processes of the same type need to be restored in the same container, the recovery of multiple processes can be achieved based on the process data stored in shared memory 2, without the need to re-store the data required for the recovery process into the memory (i.e., there is no need to execute step B6).
[0185] Step B7, the process template management module 2 calls the assembler's "jump" instruction according to the address space pointer in the second type of data of the process template to return to the state where the original process A was executed to the process snapshot creation time point, and completes the recovery of process A1.
[0186] In addition, when Pod2 needs to restore multiple processes of the same type, the process template Client can restore and run process A1 and process A2 based on the data stored in shared memory 2.
[0187] In step C1, the proxy component in node 2 establishes a connection with BaaS in advance, and the proxy component always maintains the connection with BaaS.
[0188] In step C2, after process A1 and process A2 are started, there is no need to create a new connection, but to access BaaS through the proxy component.
[0189] Specifically, after process A1 and process A2 are started, the ServiceBridge Manager component can return the connection between the proxy component and BaaS to process A1 and process A2, so that process A1 and process A2 reuse the connection between the proxy component and BaaS, that is, access to BaaS is achieved by accessing the proxy component.
[0190] In this way, process A1 and process A2 do not need to re-establish a new connection with BaaS, but the proxy component is responsible for the interaction between process A1 and process A2 and BaaS. Specifically, process 2 can access the proxy component through RPC, and the proxy component is responsible for the access behavior of process A1 and process A2 to BaaS.
[0191] The above describes the process of accelerating the startup of a process by node 2 based on the process snapshot created in node 1 with reference to a specific example. The following describes the process of quickly starting multiple processes based on the same process snapshot on the same node.
[0192] See also Figure 5 , Figure 5 A schematic diagram of a process of creating multiple processes on node 2 provided in an embodiment of the present application. Figure 5As shown, in node 2, process template Client 1 in Pod 2 reads the process snapshot and process template corresponding to process A from shared memory 1, and based on the instruction of the process template, stores the data restored based on the process snapshot (hereinafter referred to as process data) in a specified manner in shared memory 2. In this way, process template Client 1 can restore process A1 based on the process data stored in shared memory 2.
[0193] For Pod 3 in Node 2, Pod 3 and Pod 2 are in the same container and can share the data in shared memory 2. Therefore, after Pod 2 stores the process data corresponding to process A in shared memory 2, the process template Client 2 in Pod 3 can resume running process A3 based on the process data already stored in shared memory 2, without having to perform the steps of restoring process data in shared memory based on process snapshots and process templates, thereby improving the speed of starting multiple processes of the same type on the same node.
[0194] In general, different Pods on the same node can obtain the process data stored in shared memory 2, and further resume the corresponding process in the Pod based on the process data, thereby accelerating the startup of the process. Similarly, in the same Pod, multiple processes of the same type can be resumed based on the process data stored in shared memory 2, thereby improving the startup speed of the process.
[0195] See also Figure 6 , Figure 6 A schematic diagram of the process of starting a process on different nodes provided in an embodiment of the present application is provided. Figure 6 As shown, the process startup is executed on node 1 according to the original process startup process, and the corresponding process snapshot and process template are generated based on the started process. Specifically, the process of node 1 starting the process includes four steps: creating the operating environment, initializing the operating environment, starting the framework, and initializing the business. The framework startup and business initialization require a long delay.
[0196] After node 1 generates a process snapshot, node 2 can obtain the process snapshot and process template from node 1, and store the process snapshot in shared memory 1 of node 2. In this way, when node 2 actually starts a process, it only needs to perform the following two steps: restore the process data to shared memory 2 based on the process snapshot and process template, and resume running the process based on the process data in shared memory 2.
[0197] Depend on Figure 6 It can be seen that compared with node 1, node 2 no longer needs to execute processes such as framework startup and business initialization, which effectively reduces the startup delay of the process.
[0198] For example, see Figure 7 , Figure 7 This is a schematic diagram of the process comparison based on different ways of starting a process provided by the embodiment of the present application. Figure 7 As shown, the original startup process of the process includes four steps: creating the operating environment, initializing the operating environment, starting the framework, and initializing the business. The framework startup and business initialization require a relatively long delay.
[0199] After the process startup is accelerated by transferring the process snapshot between nodes, the process startup process only includes two steps: creating a process template based on the process snapshot and starting the process based on the process template.
[0200] Furthermore, when more processes are started on the same node, since the process data has been restored to the shared memory 2, the process can be started more quickly on the same node. Specifically, after the process is started more quickly on the same node, the process start step only includes starting the process based on the process data.
[0201] Depend on Figure 7 By comparison, it can be seen that the startup acceleration method provided by this solution can effectively avoid the two time-consuming steps of executing framework startup and business initialization. Instead, the process is started by restoring process data to shared memory based on process templates and process snapshots, effectively reducing the process startup delay.
[0202] The above embodiments introduce the startup acceleration method of the example provided in the embodiments of the present application. The following will introduce the device for executing the startup acceleration method of the above example.
[0203] See also Figure 8 , Figure 8 This is a schematic diagram of the structure of a startup acceleration device according to an example of the present application. Figure 8 As shown, the startup acceleration device of the instance includes: an acquisition module 801, which is used to acquire an instance snapshot and an instance template, the instance snapshot is obtained based on the started first instance, the instance snapshot is used to indicate the data generated by the first instance during operation, and the instance template is used to indicate the storage method of the data in the memory during the startup of the first instance; a processing module 802, which is used to store the data indicated in the instance snapshot into the first memory based on the instance template; the processing module 802 is also used to resume the operation of the second instance based on the data stored in the first memory.
[0204] In a possible implementation, the first memory is a shared memory, and the data stored in the first memory is used to restore one or more instances of the same type.
[0205] In one possible implementation, the instance template is also used to indicate the running status of the first instance at the creation time of the instance snapshot; the processing module 802 is also used to: based on the running status indicated by the instance template, jump to the instruction in the first address of the first memory and execute the instruction, wherein, when executing the instruction, the running status of the second instance is the same as the running status of the first instance at the creation time of the instance snapshot.
[0206] In one possible implementation, the instance template is specifically used to indicate the size of the memory area occupied by the data indicated in the instance snapshot; the processing module 802 is also used to: determine a first area in the first memory for storing data based on the size of the memory area; and store the data indicated in the instance snapshot in the first area in the first memory.
[0207] In a possible implementation, the instance template is further used to indicate the data structure of the data indicated in the instance snapshot; the processing module 802 is further used to: parse the instance snapshot based on the data structure indicated by the instance template to obtain the data indicated in the instance snapshot.
[0208] In one possible implementation, the instance template is specifically used to indicate one or more of the following: the running status of the first instance at the creation time of the instance snapshot, the size of the memory area occupied by the data indicated in the instance snapshot, and the data structure of the data indicated in the instance snapshot.
[0209] In a possible implementation, the second instance is used to access the backend as a service BaaS through a proxy component, and BaaS is used to provide data services for the operation of the second instance; during the process of resuming the operation of the second instance, the proxy component maintains a connection with the BaaS.
[0210] In a possible implementation, the acquisition module is further used to acquire the connection between the proxy component and the BaaS; the processing module is further used to return the connection to the second instance after the second instance resumes operation.
[0211] In a possible implementation manner, the instance snapshot and the instance template are obtained from a running node of the first instance through a network.
[0212] In a possible implementation, the first instance and the second instance are processes, threads, or hyperthreads.
[0213] In a possible implementation, the first instance and the second instance are instances under a microservice architecture.
[0214] Next, an execution device provided by an embodiment of the present application is introduced. Fig. 9 , Fig. 9This is a schematic diagram of the structure of an execution device provided in an embodiment of the present application. The execution device 900 can be specifically a mobile phone, a tablet, a laptop, a smart wearable device, a server, etc., which is not limited here. Specifically, the execution device 900 includes: a receiver 901, a transmitter 902, a processor 903 and a memory 904 (wherein the number of processors 903 in the execution device 900 can be one or more, Fig. 9 In the example of FIG. 9 , the processor 903 may include an application processor 9031 and a communication processor 9032. In some embodiments of the present application, the receiver 901, the transmitter 902, the processor 903 and the memory 904 may be connected via a bus or other means.
[0215] The memory 904 may include a read-only memory and a random access memory, and provides instructions and data to the processor 903. A portion of the memory 904 may also include a non-volatile random access memory (NVRAM). The memory 904 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0216] The processor 903 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0217] The method disclosed in the above embodiment of the present application can be applied to the processor 903, or implemented by the processor 903. The processor 903 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 903. The above processor 903 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 903 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined and executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 904, and the processor 903 reads the information in the memory 904 and completes the steps of the above method in combination with its hardware.
[0218] The receiver 901 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 902 can be used to output digital or character information through the first interface; the transmitter 902 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 902 can also include a display device such as a display screen.
[0219] In one embodiment of the present application, the processor 903 is configured to execute Figure 3 The method in the corresponding embodiment.
[0220] The electronic device provided in the embodiment of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute computer execution instructions stored in the storage unit so that the chip in the execution device executes the rendering method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0221] See also Fig.10 , Fig.10 This is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. The present application also provides a computer-readable storage medium. In some embodiments, the above Figure 3 The disclosed methods may be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or articles of manufacture.
[0222] Fig.10 Schematically illustrates a conceptual partial view of an example computer-readable storage medium including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.
[0223] In one embodiment, the computer readable storage medium 1000 is provided using a signal bearing medium 1001. The signal bearing medium 1001 may include one or more program instructions 1002, which when executed by one or more processors may provide the above-mentioned Figure 3 The functions or parts of the functions described. In addition, Fig.10 Program instructions 1002 in also describe example instructions.
[0224] In some examples, signal bearing medium 1001 may include computer readable medium 1003 such as, but not limited to, a hard drive, a compact disk (CD), a digital video disk (DVD), a digital tape, memory, ROM or RAM, and the like.
[0225] In some embodiments, the signal bearing medium 1001 may include a computer recordable medium 1004, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, etc. In some embodiments, the signal bearing medium 1001 may include a communication medium 1005, such as, but not limited to, a digital and / or analog communication medium (e.g., a fiber optic cable, a waveguide, a wired communication link, a wireless communication link, etc.). Thus, for example, the signal bearing medium 1001 may be communicated by a wireless form of the communication medium 1005 (e.g., a wireless communication medium complying with the IEEE 802 standard or other transmission protocol).
[0226] The one or more program instructions 1002 may be, for example, computer executable instructions or logic implementation instructions. In some examples, the computing device of the computing device may be configured to provide various operations, functions, or actions in response to the program instructions 1002 communicated to the computing device via one or more of the computer readable medium 1003, the computer recordable medium 1004, and / or the communication medium 1005.
[0227] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0228] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0229] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0230] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0231] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0232] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0233] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0234] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An accelerated startup method of an example, characterized in that: include: Obtaining an instance snapshot and an instance template, wherein the instance snapshot is obtained based on the started first instance, the instance snapshot is used to indicate data generated by the first instance during operation, and the instance template is used to indicate a storage method of the data in a memory during startup of the first instance; Based on the instance template, storing the data indicated in the instance snapshot in a first memory; The second instance is resumed based on the data stored in the first memory.
2. The method according to claim 1, characterized in that: The first memory is a shared memory, and the data stored in the first memory is used to restore one or more instances of the same type.
3. The method according to claim 1 or 2, characterized in that: The instance template is specifically used to indicate the size of the memory area occupied by the data indicated in the instance snapshot; Based on the instance template, storing the data indicated in the instance snapshot in the first memory includes: Based on the size of the memory area, determining a first area in the first memory for storing the data; The data indicated in the instance snapshot is stored in the first area in the first memory.
4. The method according to claim 3, characterized in that The instance template is further specifically used to indicate a data structure of the data indicated in the instance snapshot; The storing, based on the instance template, the data indicated in the instance snapshot into the first memory further includes: Based on the data structure indicated by the instance template, the instance snapshot is parsed to obtain the data indicated in the instance snapshot.
5. The method according to any one of claims 1 to 4, characterized in that: The instance template is also used to indicate the running state of the first instance at the creation time point of the instance snapshot; The resuming the operation of the second instance based on the data stored in the first memory includes: Based on the running status indicated by the instance template, jump to the instruction in the first address of the first memory and execute the instruction, wherein, when executing the instruction, the running status of the second instance is the same as the running status of the first instance at the creation time point of the instance snapshot.
6. The method according to any one of claims 1 to 5, characterized in that: The instance template is specifically used to indicate one or more of the following: The running state of the first instance at the creation time of the instance snapshot, the size of the memory area occupied by the data indicated in the instance snapshot, and the data structure of the data indicated in the instance snapshot.
7. The method according to any one of claims 1 to 6, characterized in that: The second instance is used to access the backend as a service BaaS through a proxy component, and the BaaS is used to provide data services for the operation of the second instance; During the process of resuming the operation of the second instance, the proxy component maintains the connection with the BaaS.
8. The method according to claim 7, characterized in that The method further comprises: Acquire a connection between the proxy component and the BaaS; After the second instance resumes operation, the connection is returned to the second instance.
9. The method according to any one of claims 1 to 8, characterized in that: The instance snapshot and the instance template are obtained from the running node of the first instance through a network.
10. The method according to any one of claims 1 to 9, characterized in that: The first instance and the second instance are processes, threads, or hyperthreads.
11. The method according to any one of claims 1 to 10, characterized in that: The first instance and the second instance are instances under a microservice architecture.
12. An accelerated starting device according to an embodiment, characterized in that: include: an acquisition module, configured to acquire an instance snapshot and an instance template, wherein the instance snapshot is obtained based on a started first instance, the instance snapshot is used to indicate data generated by the first instance during operation, and the instance template is used to indicate a storage method of the data in a memory during startup of the first instance; A processing module, configured to store the data indicated in the instance snapshot into a first memory based on the instance template; The processing module is further used to resume running the second instance based on the data stored in the first memory.
13. The device according to claim 12, characterized in that The first memory is a shared memory, and the data stored in the first memory is used to restore one or more instances of the same type.
14. The device according to claim 12 or 13, characterized in that The instance template is specifically used to indicate the size of the memory area occupied by the data indicated in the instance snapshot; The processing module is further used for: Based on the size of the memory area, determining a first area in the first memory for storing the data; The data indicated in the instance snapshot is stored in the first area in the first memory.
15. The device according to claim 14, characterized in that The instance template is further specifically used to indicate a data structure of the data indicated in the instance snapshot; The processing module is further used for: Based on the data structure indicated by the instance template, the instance snapshot is parsed to obtain the data indicated in the instance snapshot.
16. The device according to any one of claims 12 to 15, characterized in that: The instance template is also used to indicate the running state of the first instance at the creation time point of the instance snapshot; The processing module is further used for: Based on the running status indicated by the instance template, jump to the instruction in the first address of the first memory and execute the instruction, wherein, when executing the instruction, the running status of the second instance is the same as the running status of the first instance at the creation time point of the instance snapshot.
17. The device according to any one of claims 12 to 16, characterized in that: The instance template is specifically used to indicate one or more of the following: The running state of the first instance at the creation time of the instance snapshot, the size of the memory area occupied by the data indicated in the instance snapshot, and the data structure of the data indicated in the instance snapshot.
18. The device according to any one of claims 12 to 17, characterized in that: The second instance is used to access the backend as a service BaaS through a proxy component, and the BaaS is used to provide data services for the operation of the second instance; During the process of resuming the operation of the second instance, the proxy component maintains the connection with the BaaS.
19. The device according to claim 18, characterized in that The acquisition module is further used to acquire the connection between the proxy component and the BaaS; The processing module is further configured to return the connection to the second instance after the second instance resumes operation.
20. The device according to any one of claims 12 to 19, characterized in that: The instance snapshot and the instance template are obtained from the running node of the first instance through a network.
21. The device according to any one of claims 12 to 20, characterized in that: The first instance and the second instance are processes, threads, or hyperthreads.
22. The device according to any one of claims 12 to 21, characterized in that The first instance and the second instance are instances under a microservice architecture.
23. A starting acceleration device according to an embodiment, characterized in that: The device comprises a memory and a processor; the memory stores codes, the processor is configured to execute the codes, and when the codes are executed, the device executes the method according to any one of claims 1 to 11.
24. A computer storage medium, characterized in that The computer storage medium stores instructions, which, when executed by a computer, cause the computer to implement the method of any one of claims 1 to 11.
25. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, cause the computer to implement the method according to any one of claims 1 to 11.
Citation Information
Cited By
Microservice instance starting method and device, electronic equipment and storage medium
CN119759450A
Instance starting method and device of microservice, electronic equipment and storage medium
CN119759450B
Instance startup acceleration method and related apparatus
EP4660794A1
