 | |  |
 | Dreaded Cold Start One of the most common performance issues when working in a serverless environment is long cold starts. But what is a cold start? Unfortunately this term has a lot of ambiguity and is often misunderstood. But generally it describes the environment in which a serverless function is instantiated and the time it takes to execute its code when the function handles its first request. there are some specific things to remember about cold starts. They are essentially unavoidable after the function is still not ready to handle the request. The virtual environment is ready with all the code in place but no code has yet been processed by the runtime. The application must be initialized as described in the next step before calling the handler. Note that the launch details of these functions are not configurable and are handled by your cloud provider. You don't have much say in how it works. Step 1: Start the application Typically application code exists in two different scopes Code outside the handler function Code within the handler function .
In this step your cloud provider will exe photo editing servies cute the code outside the handler. The code inside the handler will be executed in the next step. When running the above function the following is logged so you can see how the outside is executing even before the actual content is logged. If there are any import constructor calls or other code it will also be executed at this time. This line will no longer be logged when a warm start request is made to the function. Code outside the handler is only executed once during a cold start. The third step is to execute the application code to execute the processing function in the last part of the startup process. It receives the incoming request i.e. request header body etc and runs the logic you have implemented. The log from the previous step continues so that the cold start of the function is completed and the execution environment is ready to handle further requests. Also log the time spent executing the code within the handler as the step in which this occurs.
It is both the startup of the environment and the startup of the application so the steps and. How to Facilitate Cold Start After understanding what cold start is and the steps taken to initialize a serverless function we will now understand the role it plays in startup time. is a module that lives outside the function code so it takes time and resources to load it into the execution environment's memory. The entire function archive needs to be downloaded from some storage and then extracted to a file in the system. This is true for all modules but it does increase cold starts and increasing the dependencies used in the project is one of them. Once the code is loaded into memory it must be imported into the handler's file and must be interpreted by the interpreter. For the client this usually means that when using client instantiation the query engine must be loaded and things like input .
| |
 | |  |