Guidelines for Production Ready AWS Lambda

Posted By : Abhishek Gupta | 30-Aug-2022

AWS Lambda Best Practices

Guidelines for Production Ready AWS Lambda

Best Practices of AWS Lambda which you can consider while building Production Ready Lambda's.

1. Provisioned Concurrency

Initializes a requested number of Lambdas, ready to serve requests 

Fix Cold Start issues

You can implement auto-scaling with Provisioned Concurrency also:

  • During Day time, 10 instances
  • During night, 2 instances

Note that configuring provisioned concurrency leads to incurs charges to your AWS account.

2. Avoid Spring Boot

Two main reasons:

  • Spring Boot start-up times
  • Un-necessary libraries that Spring Boot adds

If using Spring For DI(dependency injection)

  • Use Dagger/Guice DI libraries 

3. Avoid Lambda Chaining

Lambda Chaining happens when you call one lambda function from another so this a very famous anti-pattern even listed in aws official Documents.

Problem with this Flow :

  • Cost
  • Error Handling 
  • Tight Coupling
  • Scaling

How to Avoid :

  • Step Function
  • SQS

4. Artifact Size

Minimize deployment package size

Deployment size matter because of two reasons 

  • Limitation of the platform 

Direct Upload(zip/jar) : 50MB

Unzipped(including layers) :250MB

  • Cold Start


  • Don’t load the entire AWS SDK, Only use the dependencies that are required. Eg DynamoDB, S3
  • Only use the required dependencies 

5. Build an Idempotent Lambda

Idempotent :  “The property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application” impotence is a very important aspect of serverless.

How to achieve :

  • Use DynamoDB Upsert 
  • PowerTools Idempotency


6. Monitor all important metrics with CloudWatch metrics

serverless applications produce a set of standard metrics that will help you understand the performance and availability of your system

  • Throttles
  • Errors
  • Invocations
  • Duration


About Author

Author Image
Abhishek Gupta

Abhishek is working as a Java developer he has experience in developing web-based applications in java with the latest frameworks. He is always willing to learn new technology.

Request for Proposal

Name is required

Comment is required

Sending message..