CN113934435A - Function cold start method and device - Google Patents

Function cold start method and device Download PDF

Info

Publication number
CN113934435A
CN113934435A CN202111152871.1A CN202111152871A CN113934435A CN 113934435 A CN113934435 A CN 113934435A CN 202111152871 A CN202111152871 A CN 202111152871A CN 113934435 A CN113934435 A CN 113934435A
Authority
CN
China
Prior art keywords
function
class
instance
instances
function instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111152871.1A
Other languages
Chinese (zh)
Inventor
亢占雷
严雅芳
吴宗远
孙庆玲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Everbright Technology Co ltd
Original Assignee
Everbright Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Everbright Technology Co ltd filed Critical Everbright Technology Co ltd
Priority to CN202111152871.1A priority Critical patent/CN113934435A/en
Publication of CN113934435A publication Critical patent/CN113934435A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44557Code layout in executable memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a function cold start method and a function cold start device, wherein the method comprises the following steps: analyzing the name of the function to be operated from the acquired target request message; loading the code of the function into a memory according to the name of the function; selecting a first type function instance in a standby state from a pre-established running environment pool; the code of the function is injected into the selected first-class function instance to provide service for the outside, the problems that the function without a server in the related technology has long cold start time and is not suitable for time-sensitive scenes can be solved, the function is started in a pooling mode by separating the function from the function running, and the function is started in a mode of dynamically injecting the function code into the first-class function instance, so that the start time of the function is shortened to the millisecond level, the time delay of cold start is greatly shortened, the application scene is expanded to a plurality of time-delay-sensitive areas, and the use scenes of the platform are enriched.

Description

Function cold start method and device
Technical Field
The invention relates to the field of data processing, in particular to a function cold start method and a function cold start device.
Background
The current best open source solution known as "ktative" provides a solution for expanding and contracting functions from 0 to zero instances, and is widely popular. The basic operation principle comprises the following steps:
a user writes function codes and can select an excellent programming language;
packaging the user function into an executable mirror image through a construction process;
submitting the mirror image into kubernets, configuring relevant parameters during operation, and scheduling and operating the platform in due time;
when the function is accessed, judging whether a function instance exists in the current platform or not, if no instance exists, creating a new function instance, adding the current request into a queue for queuing, and replaying the request in the queue after the new function instance is deployed successfully so as to achieve the purpose of calling.
From the above operation process, it can be found that the function is actually operated from 0, and the required start-up time is long and is not suitable for time-sensitive scenes.
Aiming at the problems that the function cold start time without the server is long and is not suitable for time-sensitive scenes in the related technology, a solution is not provided.
Disclosure of Invention
The embodiment of the invention provides a function cold start method and a function cold start device, which are used for at least solving the problems that the function cold start time without a server is longer and is not suitable for time-sensitive scenes in the related art.
According to an embodiment of the present invention, there is provided a function cold start method including:
analyzing the name of the function to be operated from the acquired target request message;
loading the code of the function into a memory according to the name of the function;
selecting a first type function instance in a standby state from a pre-established running environment pool;
and injecting the codes of the functions into the selected first class of function examples to provide services for the outside.
Optionally, before selecting a first type of function instance in a standby state from a pre-created runtime environment pool, the method further includes:
packing the function operation into mirror image, and submitting the mirror image to an open source container arrangement system kubernets;
generating a plurality of first-class function instances for the mirror image, and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running;
maintaining the plurality of first-class function instances through a controller of kubernets in the running environment pool, and setting a label A for the plurality of first-class function instances, wherein the label A represents that the first-class function instances are in a standby state.
Optionally, after selecting a first type of function instance in a standby state from a pre-created runtime environment pool, the method further includes:
changing the label A of the selected first class function instance into a label B, wherein the label B represents an expropriation;
creating a new first-class function instance, and setting the label A for the created first-class function instance;
and adding the created first type function instances into the runtime environment pool, so that a preset number of first type function instances in a standby state are always stored in the runtime environment pool.
Optionally, the method further comprises:
if only one target function instance is imposed in the runtime environment pool and the target function instance receives a plurality of request messages, receiving the target request message through a first controller, selecting a first class function instance in a standby state from the runtime environment pool, and simultaneously triggering an automatic scaling mechanism to create a second class function instance, wherein the first class function instance and the second class function instance are maintained in the first controller, and the second class function instance is a function instance with automatic capacity expansion capability in runtime;
and after the second type function instance is successfully created, setting a pointer of a second controller to indicate that the second type function instance exists, wherein the second controller is an entry of external traffic, and the pointer is used for indicating whether the second type function instance exists.
Optionally, the method further comprises:
processing part of message requests in the plurality of message requests through the selected first class function instance during the period from the receiving of the target request message to the successful creation of the second class function instance;
after the second type function instance is successfully created, processing other message requests except the partial message in the plurality of request messages through the second type function.
According to another embodiment of the present invention, there is also provided a function cold start apparatus including:
the analysis module is used for analyzing the name of the function to be operated from the acquired target request message;
the loading module is used for loading the codes of the functions into the memory according to the names of the functions;
the selection module is used for selecting a first type of function example in a standby state from a pre-established running environment pool;
and the injection module is used for injecting the codes of the functions into the selected first class of function examples to provide services for the outside.
Optionally, the apparatus further comprises:
the packaging module is used for packaging the function operation into a mirror image and submitting the mirror image to an open source container arrangement system kubernets;
the generating module is used for generating a plurality of first-class function instances for the mirror image and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running;
and the maintenance module is used for maintaining the plurality of first-class function instances in the running environment pool through a controller of kubernets and setting a label A for the plurality of first-class function instances, wherein the label A represents that the label A is in a standby state.
Optionally, the apparatus further comprises:
a changing module, configured to change the tag a of the selected first class function instance to a tag B, where the tag B indicates an imposed function;
the creating module is used for creating a new first type function instance and setting the label A for the created first type function instance;
and the adding module is used for adding the created first-class function instances into the runtime environment pool so as to enable a preset number of first-class function instances in a standby state to be always stored in the runtime environment pool.
Optionally, the apparatus further comprises:
a creating module, configured to receive the target request packet through a first controller if only one imposed target function instance is in the runtime environment pool and the target function instance receives multiple request packets, and trigger an automatic scaling mechanism to create a second class function instance while selecting a first class function instance in a standby state from the runtime environment pool, where the first class function instance and the second class function instance are maintained in the first controller, and the second class function instance is a function instance with an automatic capacity expansion capability during runtime;
and the setting module is used for setting a pointer of a second controller to indicate that the second type function instance exists after the second type function instance is successfully created, wherein the second controller is an inlet of external traffic, and the pointer is used for indicating whether the second type function instance exists.
Optionally, the apparatus further comprises:
the first processing module is used for processing part of the message requests in the plurality of message requests through the selected first class function instance during the period from the target request message to the successful creation of the second class function instance;
and the second processing module is used for processing other message requests except the partial messages in the plurality of request messages through the second class function after the second class function instance is successfully created.
According to a further embodiment of the present invention, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the above-described method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
By the method and the device, the name of the function needing to be operated is analyzed from the acquired target request message; loading the code of the function into a memory according to the name of the function; selecting a first type function instance in a standby state from a pre-established running environment pool; the code of the function is injected into the selected first-class function instance to provide service for the outside, the problems that the function without a server in the related technology has long cold start time and is not suitable for time-sensitive scenes can be solved, the function is started in a pooling mode by separating the function from the function running, and the function is started in a mode of dynamically injecting the function code into the first-class function instance, so that the start time of the function is shortened to the millisecond level, the time delay of cold start is greatly shortened, the application scene is expanded to a plurality of time-delay-sensitive areas, and the use scenes of the platform are enriched.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware configuration of a mobile terminal of a function cold start method according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method of function cold start according to an embodiment of the invention;
FIG. 3 is a diagram illustrating a reduction in cold start latency in a no service counter according to the present embodiment;
fig. 4 is a block diagram of a functional cold start apparatus according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Example 1
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking a mobile terminal as an example, fig. 1 is a hardware structure block diagram of a mobile terminal of the function cold start method according to the embodiment of the present invention, as shown in fig. 1, the mobile terminal may include one or more processors 102 (only one is shown in fig. 1) (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, and optionally, the mobile terminal may further include a transmission device 106 for a communication function and an input/output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the function cold start method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In this embodiment, a function cold-start method operating in the mobile terminal or the network architecture is provided, and fig. 2 is a flowchart of the function cold-start method according to the embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, analyzing the name of the function to be operated from the acquired target request message;
step S204, loading the code of the function into a memory according to the name of the function;
step S206, selecting a first type function instance in a standby state from a pre-created running environment pool;
and step S208, injecting the codes of the functions into the selected first-class function examples to provide services for the outside.
Through the steps S202 to S208, the problems that the function cold start time without a server is long and is not suitable for time-sensitive scenes in the related technology can be solved, the function running time is pooled by separating the function running time from the function running time, and the function is started in a mode of dynamically injecting function codes in the first class of function examples, so that the function start time is shortened to the millisecond level, the cold start time delay is greatly shortened, the application scenes are expanded to a plurality of time-delay-sensitive areas, and the use scenes of the platform are enriched.
In an alternative embodiment, before step S206, the function runtime is packaged as a mirror image and submitted to an open source container arrangement system kubernets; generating a plurality of first-class function instances for the mirror image, and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running; maintaining the plurality of first-class function instances through a controller of kubernets in the running environment pool, and setting a label A for the plurality of first-class function instances, wherein the label A represents that the first-class function instances are in a standby state.
In another optional embodiment, after the step S206, the label a of the selected first class function instance is changed to a label B, where the label B indicates that the application is imposed; creating a new first-class function instance, and setting the label A for the created first-class function instance; and adding the created first type function instances into the runtime environment pool, so that a preset number of first type function instances in a standby state are always stored in the runtime environment pool.
In an embodiment, if only one imposed target function instance is in the runtime environment pool and the target function instance receives multiple request messages, the first controller receives the target request message, and an automatic scaling mechanism is triggered to create a second class function instance while a first class function instance in a standby state is selected from the runtime environment pool, wherein the first class function instance and the second class function instance are maintained in the first controller, and the second class function instance is a function instance with automatic capacity expansion capability in runtime; and after the second type function instance is successfully created, setting a pointer of a second controller to indicate that the second type function instance exists, wherein the second controller is an entry of external traffic, and the pointer is used for indicating whether the second type function instance exists.
In another embodiment, during the period from the receiving of the target request message to the successful creation of the second-class function instance, processing a part of message requests in the plurality of message requests through the selected first-class function instance; after the second-class function instance is successfully created, processing other message requests except the partial message in the plurality of request messages through the second-class function, wherein the first-class function instance and the second-class function instance are different function instances.
According to the embodiment of the invention, the user function is separated from the function operation, the function written by the user is separated from the basic environment required by the function operation, and the function and the basic environment are not packaged into a mirror image. The function refers to code written by a user for processing business logic, and the 'runtime' of the function refers to context information on which the function needs to run, for example, in java, ordinary java code can be regarded as a function, and a java virtual machine is a runtime environment needed by the code.
After separating the function from the runtime, the file size after the function is packed becomes very small (does not include the runtime), and the information of the runtime environment basically does not change, so that the function can be shared and used, and finally 1: the relation of N, namely one function running time, can be shared and used by a plurality of functions.
The process of the whole function external service comprises the following steps:
1, a function is dispatched to a certain server node by a platform, and a function container is started at the current node;
2, when the function container is started, injecting information such as environment variables, keys, configuration and the like;
3, starting function runtime basic code, such as main function;
4, starting an http service port and monitoring a connection request;
5, acquiring request parameters, and analyzing the name of the function to be operated;
dynamically loading the function into a memory to generate a function instance;
7, forwarding the request to the function instance for calculation;
and 8, returning the calculation result.
Therefore, the function is universal in operation, and does not directly depend on the user function, but dynamically loads the user function in the operation process, and which function is loaded completely depends on the message content of the request. This greatly increases the dynamics of the function during operation.
The embodiment of the invention submits the user function to the function warehouse, assigns a unique ID to each function, and can download the function through the unique ID.
Packing the 'function runtime' into a mirror image, submitting the mirror image into kubernets (k8s), and generating a plurality of null instances for the mirror image in advance, wherein the null instances form a pool, which is called a runtime environment pool. The instance in the ambient pool, at startup, has completed the first 4 steps of operation and is on standby. The runtime environment pool always maintains a plurality of copies through a controller of kubernets, each copy is marked with a specific label A to indicate that the current environment is in a standby state, when a request is received, the platform first picks an instance from the standby environment and modifies the label A of the instance into a label B to indicate that the current instance is already imposed. The controller of the platform finds that the number of the instances in the runtime pool marked as A is reduced, further automatically creates a new runtime instance, marks the new instance as A, rejoins the runtime environment pool, and always stores a certain number of standby instances for standby. And the explicated runtime instance can directly inject the function code to serve outside because the runtime instance itself is already in a standby state (the previous 4 operation steps are completed).
Therefore, the cold start time of the function can be shortened to the time for downloading the function code, and the time for dynamically loading the function code to be ready in the memory is added, so that the cold start time can be shortened to the millisecond level through a certain cache optimization skill.
The embodiment of the invention can greatly reduce the cold start time of the function, solves the problem of longer cold start time of the server, improves the customer experience, achieves almost imperceptible delay, expands the application scene of the server to a plurality of areas sensitive to time delay and enriches the use scene of the platform.
The above pooling has a disadvantage that only one function instance is required, and when receiving a large amount of external requests for access, the instance can only process by itself, cannot dynamically create new copies to share traffic at the same time, and cannot cope with larger-scale access requests. Therefore, the invention combines KPA and HPA mechanisms provided by a knetive and integrates a pooling mechanism to jointly form a solution of cold start. Newly-increased 2 controllers: an Activator (corresponding to the first controller) and a ServerlessService (corresponding to the second controller). The serverlessService is an entry of external traffic, and includes a pointer, and by judging whether a ready "dynamically scalable function instance" exists in the current platform, if so, the traffic is directly called to the function instance, and if not, the traffic is called to the activator.
The Activator maintains two function instances, one from the above-mentioned function instance standing by in the runtime pool is called pinstname, and the other is the function instance with runtime automatic capacity expansion capability is called KInstance.
When the Activator receives the request, the Activator firstly obtains an instance from the PINstance pool, injects the function code and directly provides the service for the outside, the time consumption of the stage is very short, the waiting time of the user is reduced,
meanwhile, the Activator triggers a knative automatic scaling mechanism to create a KInstance instance, and after the KInstance instance is successfully created, a pointer in the Serverlessservice is switched to a KInstance mode. When the next flow comes, the flow can be directly guided into the instance of KInstance, and with the continuous increase of the flow, the requirement can be satisfied by the gradual expansion of KInstance. And Pinstance can also be destroyed after a period of time because of losing flow.
When the function instance in the platform is 0, the first flow triggers the spanning and creates the kinnstance at the same time, after the creation of the spanning, the flow is led into the spanning, and the spanning only needs to be responsible for flow processing in the time period, and the function can respond in millisecond level and process large-scale access requests, so that the optimization target of cold start is achieved.
Example 2
According to another embodiment of the present invention, there is also provided a function cold start apparatus, and fig. 4 is a block diagram of the function cold start apparatus according to the embodiment of the present invention, as shown in fig. 4, including:
the analysis module 42 is configured to analyze the name of the function to be run from the obtained target request packet;
a loading module 44, configured to load a code of the function into a memory according to the name of the function;
a selecting module 46, configured to select a first class function instance in a standby state from a pre-created operating environment pool;
and the injection module 48 is configured to inject the code of the function into the selected first class of function instance, so as to provide a service to the outside.
Optionally, the apparatus further comprises:
the packaging module is used for packaging the function operation into a mirror image and submitting the mirror image to an open source container arrangement system kubernets;
the generating module is used for generating a plurality of first-class function instances for the mirror image and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running;
and the maintenance module is used for maintaining the plurality of first-class function instances in the running environment pool through a controller of kubernets and setting a label A for the plurality of first-class function instances, wherein the label A represents that the label A is in a standby state.
Optionally, the apparatus further comprises:
a changing module, configured to change the tag a of the selected first class function instance to a tag B, where the tag B indicates an imposed function;
the creating module is used for creating a new first type function instance and setting the label A for the created first type function instance;
and the adding module is used for adding the created first-class function instances into the runtime environment pool so as to enable a preset number of first-class function instances in a standby state to be always stored in the runtime environment pool.
Optionally, the apparatus further comprises:
a creating module, configured to receive the target request packet through a first controller if only one imposed target function instance is in the runtime environment pool and the target function instance receives multiple request packets, and trigger an automatic scaling mechanism to create a second class function instance while selecting a first class function instance in a standby state from the runtime environment pool, where the first class function instance and the second class function instance are maintained in the first controller, and the second class function instance is a function instance with an automatic capacity expansion capability during runtime;
and the setting module is used for setting a pointer of a second controller to indicate that the second type function instance exists after the second type function instance is successfully created, wherein the second controller is an inlet of external traffic, and the pointer is used for indicating whether the second type function instance exists.
Optionally, the apparatus further comprises:
the first processing module is used for processing part of the message requests in the plurality of message requests through the selected first class function instance during the period from the target request message to the successful creation of the second class function instance;
and the second processing module is used for processing other message requests except the partial messages in the plurality of request messages through the second class function after the second class function instance is successfully created.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Example 3
Embodiments of the present invention also provide a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, analyzing the name of the function to be operated from the acquired target request message;
s2, loading the codes of the functions into a memory according to the names of the functions;
s3, selecting a first type function instance in a standby state from a pre-created running environment pool;
s4, injecting the code of the function into the selected first type of function instance, and providing service for the outside.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Example 4
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, analyzing the name of the function to be operated from the acquired target request message;
s2, loading the codes of the functions into a memory according to the names of the functions;
s3, selecting a first type function instance in a standby state from a pre-created running environment pool;
s4, injecting the code of the function into the selected first type of function instance, and providing service for the outside.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for cold starting a function, comprising:
analyzing the name of the function to be operated from the acquired target request message;
loading the code of the function into a memory according to the name of the function;
selecting a first type function instance in a standby state from a pre-established running environment pool;
and injecting the codes of the functions into the selected first class of function examples to provide services for the outside.
2. The method of claim 1, wherein prior to selecting a first class of function instances on standby from a pool of pre-created runtime environments, the method further comprises:
packing the function operation into mirror image, and submitting the mirror image to an open source container arrangement system kubernets;
generating a plurality of first-class function instances for the mirror image, and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running;
maintaining the plurality of first-class function instances through a controller of kubernets in the running environment pool, and setting a label A for the plurality of first-class function instances, wherein the label A represents that the first-class function instances are in a standby state.
3. The method of claim 2, wherein after selecting a first class of function instances on standby from a pool of pre-created runtime environments, the method further comprises:
changing the label A of the selected first class function instance into a label B, wherein the label B represents an expropriation;
creating a new first-class function instance, and setting the label A for the created first-class function instance;
and adding the created first type function instances into the runtime environment pool, so that a preset number of first type function instances in a standby state are always stored in the runtime environment pool.
4. The method of claim 3, further comprising:
if only one target function instance is imposed in the runtime environment pool and the target function instance receives a plurality of request messages, receiving the target request message through a first controller, selecting a first class function instance in a standby state from the runtime environment pool, and simultaneously triggering an automatic scaling mechanism to create a second class function instance, wherein the first class function instance and the second class function instance are maintained in the first controller, and the second class function instance is a function instance with automatic capacity expansion capability in runtime;
and after the second type function instance is successfully created, setting a pointer of a second controller to indicate that the second type function instance exists, wherein the second controller is an entry of external traffic, and the pointer is used for indicating whether the second type function instance exists.
5. The method of claim 4, further comprising:
processing part of message requests in the plurality of message requests through the selected first class function instance during the period from the receiving of the target request message to the successful creation of the second class function instance;
after the second type function instance is successfully created, processing other message requests except the partial message in the plurality of request messages through the second type function.
6. A function cold start apparatus, comprising:
the analysis module is used for analyzing the name of the function to be operated from the acquired target request message;
the loading module is used for loading the codes of the functions into the memory according to the names of the functions;
the selection module is used for selecting a first type of function example in a standby state from a pre-established running environment pool;
and the injection module is used for injecting the codes of the functions into the selected first class of function examples to provide services for the outside.
7. The apparatus of claim 6, further comprising:
the packaging module is used for packaging the function operation into a mirror image and submitting the mirror image to an open source container arrangement system kubernets;
the generating module is used for generating a plurality of first-class function instances for the mirror image and storing the first-class function instances into the running environment pool, wherein the first-class function instances are function instances which do not have automatic capacity expansion capability during running;
and the maintenance module is used for maintaining the plurality of first-class function instances in the running environment pool through a controller of kubernets and setting a label A for the plurality of first-class function instances, wherein the label A represents that the label A is in a standby state.
8. The apparatus of claim 7, further comprising:
a changing module, configured to change the tag a of the selected first class function instance to a tag B, where the tag B indicates an imposed function;
the creating module is used for creating a new first type function instance and setting the label A for the created first type function instance;
and the adding module is used for adding the created first-class function instances into the runtime environment pool so as to enable a preset number of first-class function instances in a standby state to be always stored in the runtime environment pool.
9. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method of any one of claims 1 to 5 when executed.
10. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 5.
CN202111152871.1A 2021-09-29 2021-09-29 Function cold start method and device Pending CN113934435A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111152871.1A CN113934435A (en) 2021-09-29 2021-09-29 Function cold start method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111152871.1A CN113934435A (en) 2021-09-29 2021-09-29 Function cold start method and device

Publications (1)

Publication Number Publication Date
CN113934435A true CN113934435A (en) 2022-01-14

Family

ID=79277375

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111152871.1A Pending CN113934435A (en) 2021-09-29 2021-09-29 Function cold start method and device

Country Status (1)

Country Link
CN (1) CN113934435A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023138453A1 (en) * 2022-01-19 2023-07-27 华为技术有限公司 Container loading method and apparatus

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023138453A1 (en) * 2022-01-19 2023-07-27 华为技术有限公司 Container loading method and apparatus

Similar Documents

Publication Publication Date Title
US7356680B2 (en) Method of loading information into a slave processor in a multi-processor system using an operating-system-friendly boot loader
CN112000348A (en) Control method and device for service gray release and computer equipment
JP7192103B2 (en) DATA PROCESSING METHOD AND APPARATUS, AND COMPUTING NODE
CN108062252B (en) Information interaction method, object management method, device and system
CN110221901A (en) Container asset creation method, apparatus, equipment and computer readable storage medium
CN115328663A (en) Method, device, equipment and storage medium for scheduling resources based on PaaS platform
CN112035228A (en) Resource scheduling method and device
WO2016151398A1 (en) System and method for configuring a platform instance at runtime
JPH06103481B2 (en) Program loading method
CN113190282A (en) Android operating environment construction method and device
US20020124244A1 (en) Method and device for downloading application data
CN113934435A (en) Function cold start method and device
CN104714839A (en) Method and device for controlling life cycle of processes
CN114546588A (en) Task deployment method and device, storage medium and electronic device
CN111930455A (en) Page updating method, device, terminal and storage medium
WO2023124657A1 (en) Micro-application running method and apparatus, device, storage medium, and program product
CN112688980B (en) Resource distribution method and device, and computer equipment
CN115390920A (en) Event stream processing method and device, computer equipment and storage medium
CN114860203A (en) Project creation method, project creation device, server and storage medium
CN114662102A (en) File processing method and device and storage medium
CN115794321A (en) Timing task processing method, device, medium and equipment
CN107220101B (en) Container creation method and device
CN111973991A (en) Control method and device for accelerating game loading through distributed loading resource files
CN109168079B (en) Bullet screen message distribution method, device, equipment and storage medium
US20090024996A1 (en) Blade server and service start method therefore

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination