Skip to content

Lambda Lifecycle

Invoke Lifecyle Invoke Lifecyle

Init

In the Init phase, Lambda performs three tasks:

  • Start all extensions (Extension init)
  • Bootstrap the runtime (Runtime init)
  • Run the function's static code (Function init)

The Init phase ends when the runtime and all extensions signal that they are ready by sending a Next API request. The Init phase is limited to 10 seconds. If all three tasks do not complete within 10 seconds, Lambda retries the Init phase at the time of the first function invocation.

Invoke

When a Lambda function is invoked in response to a Next API request, Lambda sends an Invoke event to the runtime and to each extension.

The function's timeout setting limits the duration of the entire Invoke phase.

Shutdown

When Lambda is about to shut down the runtime, it sends a Shutdown event to the runtime and to each external extension. Extensions can use this time for final cleanup tasks. The Shutdown event is a response to a Next API request.

Duration: The entire Shutdown phase is capped at 2 seconds. If the runtime or any extension does not respond, Lambda terminates it via a signal (SIGKILL).

Documentation