Effectively running Java on ServerlessUtilize initialization phase1 min

On-demand Lambda functions use a full vCPU (non-throttled) but is limited to 10 seconds during its initialization phase. Therefore, objects that are expected to be reused across multiple invocations should move their respective initialization code to either a static initializer or constructor instead of creating them inside the Lambda handler method. Initializing them inside the Lambda handler method will create those resources on every Lambda invocation that unnecessarily adds up to the Lambda duration.

For provisioned concurrency, there is no cpu burst and goes directly to using proportional vCPU based on the memory allocation.

Init

Also, when using the AWS SDK, pre-configure specific items during client initialization. For example, region, the credential provider, and endpoint, if you know these values. Providing these values during client creation saves time for the SDK to run additional code to figure out which region it is running currently, etc.


Created by:

Dhiraj Mahapatro
Dhiraj MahapatroPrincipal Specialist SA, Serverless, AWS.