Cold Start Optimization: a Solution for Developers to Reduce the Impact of Cold Start

Cold start optimization Introduction:

Cold start optimization: a solution for developers to reduce the impact of cold start

Cold start optimization.Code package optimization

FaaS platforms of various cloud vendors , there are restrictions on the size of the code package. Abandoning the cloud vendor's restrictions on the code package, it is possible to simply talk about the impact of the code package specifications. You can see through the cold start process of the function. arrive:

Cold start optimization.In the process of function startup, there is a process of loading code, then when the uploaded code package is too large, or the decompression speed is too slow due to too many files, it will directly lead to the process of loading the code becoming longer, and further directly lead to Cold start time becomes longer.

Cold start optimization.It can be imagined that when there are two compressed packages, one is a code compressed package of only 100KB, and the other is a code compressed package of 200MB, both of which are idealized at the same time under the gigabit intranet bandwidth (that is, regardless of the storage speed of the disk) etc.) download, even if the maximum speed can reach 125MB/S, the download speed of the former is less than 0.01

Cold start optimization.Seconds, and the latter takes 1.6 seconds. In addition to the download time, there is also the decompression time of the file, so the cold start time of the two Maybe 2 seconds difference. Under normal circumstances, if a traditional web interface needs a response time of more than 2 seconds, it is actually unacceptable for many businesses, so when packaging the code, it is necessary to reduce the compressed package size as much as possible. Taking the Node.js project as an example, when packaging the code package, you can use Webpack and other methods to compress the size of the dependency package, further reduce the overall code package size, and improve the cold start efficiency of the function.

Cold start optimization.Reasonable reuse of instances

FaaS platforms of various cloud vendors , in order to better solve the problem of cold start and use resources more reasonably, there is a situation of "instance" reuse. The so-called instance reuse means that when an instance completes a request, it will not be released, but will enter a "silent" state. Within a certain time range, if a new request is allocated, it will directly call the corresponding This method greatly reduces the occurrence of cold start of functions. For verification, two functions can be created:

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00