- Compiled languages (Java and .NET) Has the largest Cold-Start overhead, therefore, container's first invocation is known to be slow but shows best performance for subsequent invocations.
- Interpreted languages (Node.js and Python) The interpreted languages have very fast initial invocation times compared to the compiled languages, but can’t reach the same level of maximum performance as the compiled languages.
What is Cold Start?
“Cold start” in the serverless world means that serverless application is started and initialized to handle the request. In here, “serverless application” term represents both application and container itself where user code runs. Initialization adds extra latency to the execution of the request since they need to be done before handling the request.
Fortunately, this initialization doesn’t occur at every request as almost all the serverless platforms are smart to reuse containers as much as possible. However depending on the serverless platform itself, existing containers can be destroyed and new ones can be created at any time due to many internal (resource scheduling/sharing, fixes/patches on the host environment, etc …) or external (new application deploy, configuration change, etc …) reasons.
In AWS Lambda platform, the following causes trigger new container starts which results in cold starts:
- There is no container alive
- There are containers alive but none of them are available as all of them are busy with handling other requests This happens if your application use case has very spiky traffic.
- New application was deployed so new containers must start with the newer version of the application
- Configuration (env. variable, memory limit, etc …) are changed so new containers must start with new configurations
How to reduce cold start overhead?
- Sending periodic warmup requests
- AWS Lambda Custom Runtime support that bootstrapping the runtime AWS can optimize the runtime bootstrapping phase to start faster (for ex. at Java runtime, by tweaking JVM arguments) This happens if your application use case has very spiky traffic.
- Use latest AWS SDKs For example, AWS Java SDK 2 has 500–750 ms less initialization overhead than AWS Java SDK1.