Designing Compute Solutions in AWS – Lambda

AWS Lambda is a serverless computing service that enables you to run custom functions in response to events or specific triggers. AWS Lambda provides compute processing power on demand, executing functions that you’ve either written or selected from a library of functions created by AWS. With AWS Lambda, you can create functions without the need to provision or maintain any infrastructure.

  • AWS Lambda charges you only for the time your code executes.
  • AWS Lambda functions can be triggered by a wide range of events, such as object changes in an Amazon S3 bucket or an Amazon DynamoDB table, or from an HTTP request to an Amazon API Gateway endpoint.
  • AWS Lambda can communicate with other AWS services.
  • AWS Lambda is compatible with code written in a variety of programming languages, including Node.js, Java, Python, and C#.

Lambda functions run in a specialized virtualization format called Firecracker hosted on EC2 instances. It was developed by Amazon and is used as the virtualization technology for AWS Lambda and AWS Fargate. Firecracker uses a microVM architecture, creating a lightweight VM for each function that is executed. Firecracker utilizes a small footprint of approximately 5 MB of RAM. Each Firecracker microVM is launched in less than 100 ms. To secure each AWS Lambda function during execution, each Firecracker VM runs in an isolated guest mode.

Once a Lambda function is created, the required amount of memory, ephemeral storage, and performance is allocated to your function. The maximum execution CPU time is 15 minutes, and the minimal execution time is 1 second. Memory can be requested at 64 MB increments from 128 to 10.24 GB. Each AWS Lambda function receives 500 MB of temporary disk space for use during execution. AWS Lambda monitors executing functions using real-time Amazon CloudWatch metrics.

AWS Lambda deployment package size limits

According to the documentation, a Lambda function with all its layers, source code and runtime must fit in the size limits below:

  • In the AWS Console Editor – 3MB
  • When zipped, for direct upload – 50MB
  • When unzipped including layers, using an S3 bucket – 250MB
  • Container image – 10GB

From starting of 2021, AWS Lambda began to support container images and we became able to deploy Lambda functions as container images up to 10GB.

To deal with the size limits, I strongly suggest you optimize the imports as much as possible, import only what you need and get rid of those unnecessary imports. Also, you can split your lambda function into layers.

Concurrency Limits

Although AWS Lambda is serverless, this doesn’t mean that you don’t have anything to manage on your end. If left unchecked, you’ll be surprised how each function execution can add to your monthly bill. Your other Lambda functions might not even execute properly if one of your functions is hogging all the compute resources available to you. As with everything that scales automatically, you should be placing hard limits on the scalability so it will not explode all over the place. In AWS Lambda, this limit is known as the concurrency limit. Concurrency is the number of requests that your function is serving at any given time. When your function is invoked, Lambda allocates an instance of it to process the event. By default, your AWS account has a default quota of 1000 concurrent Lambda executions per Region.

There are two types of concurrency:

  • Reserved concurrency: A pool of requests that can only be used by the function that reserved the capacity, and also prevents the function from using unreserved concurrency. A function cannot utilize another function’s reserved concurrency, so other functions can’t prevent your function from scaling.
  • Provisioned concurrency: Initializes a requested number of execution environments so that they are prepared to respond to your function’s invocations without any fluctuations.

Both of these concurrency plans can be used together, but your provisioned concurrency cannot exceed your
maximum reserved concurrency.


AWS Lambda fees per function:

  • Amount of requests that you send to your function
  • The duration it runs (rounded to the nearest 1ms)
  • Amount of compute power provisioned for your function

CloudAcademy – Designing Compute solutions in AWS
Mark Wilkins – AWS Certified Solutions Architect – Associate (SAA-C03) Cert Guide (Certification Guide)
Jon Bonso – AWS Certified Solutions Architect Associate SAA-C03-Tutorials Dojo