Code for cold and warm containers

The performance of the lambda function is dictated by the logic that we code within it and the dependencies we call. So the best practice to code the lambda function would be to consider the cold and warm start of the containers.

For improved performance for warm starting the container, make sure that you store and reference any externalized configurations or dependencies that your code retrieves locally. Limit the reinitialization of the variables/objects on every invocation that uses global and static variables. Keep the HTTP and database connections alive.  

For better performance for cold starting the container, it is always better to use the default network environment, unless connectivity to a resource within a VPC via a private IP is required. Choose an interpreted runtime language over a complied language. Keep the function code package as small as possible, as this will reduce the time to download, unpack the code from the S3 bucket, and invoke it.