Starting next August, Amazon will begin charging for the AWS Lambda initialization phase for managed runtimes. While the company frames this change as a billing standardization to align with existing behavior, and many in the community view it as a step toward more predictable and unified billing, others see it as a price increase by AWS.
Lambda charges are based on the number of requests and the millisecond duration. While functions using custom runtimes, provisioned concurrency, or OCI container images already include the INIT phase in the billed duration, the INIT phase was previously excluded for all other AWS Lambda functions.
The new change affects only on-demand invocations of Lambda functions packaged as ZIP files using managed runtimes, where the INIT phase duration was previously not billed. Shubham Gupta, principal product manager at AWS, and Jeff Gebhart, senior specialist technical account manager at AWS, write:
Most users will see minimal impact on their overall Lambda bill from this change (…) According to an analysis of production Lambda workloads, INITs (cold starts) typically occur in under 1% of invocations—meaning code in the INIT phase may execute just once per hundred invocations.
Until now, only the INVOKE phase was billed for supported managed runtimes. Going forward, the INIT phase will be billed in the same way.
The Lambda function execution lifecycle consists of three distinct phases: INIT, INVOKE, and SHUTDOWN. The INIT phase occurs during a cold start, when Lambda creates a new execution environment in response to an invocation or to scale the environment. Next is the INVOKE phase, where the function processes the request. Finally, in the SHUTDOWN phase, the execution environment is terminated.
Source: AWS blog
Common uses of the INIT phase include downloading libraries or dependencies, establishing client connections to other AWS services, creating database connections to be shared across invocations, or retrieving application parameters or secrets. Developers can monitor the time spent in the INIT phase of function invocations using the InitDuration
CloudWatch metric. AJ Stuyvenberg, staff engineer at Datadog and AWS Hero, comments:
AWS should have done this years ago (..) I’m glad that people can finally make objective decisions about whether to use a container image vs zip based function without having to consider the cost difference. I believe the cost was always marginal but it’s just added friction in the decision making process.
The new shift emphasizes the importance of optimizing INIT phase execution for cost efficiency. In a popular Reddit thread, user TheBrianiac writes:
It makes sense with the “pay for what you use” model though, right now paying Lambda customers are subsidizing free compute for other customers.
While many in the community view the change as a way to prevent abuse of the up to 10-second unbilled INIT phase, used for activities such as crypto mining or website scraping, AWS did not acknowledge this in its announcement. Corey Quinn, chief cloud economist at The Duckbill Group, writes in his newsletter:
This is how AWS raises prices–not by jacking up hourly charges, but by subtly shifting pricing dimensions. This one is fair; the docs have always said this is how it worked, they just had an implementation bug they got around to closing.
Depending on the workload and runtime environment, Lambda SnapStart and Provisioned Concurrency are strategies that can eliminate the performance impact of the INIT phase, reducing both cold start latency and INIT phase costs.