AWS Lambda Limit and Features Everyone Should Know
Tags: aws, serverless, beginners, programming
Published: 2023-03-08 07:00:00

AWS Lambda is a great serverless computing resource for a lot of different use cases. It could be used for a small project, for example, a cron job, or with other AWS Services to build something massive and complicated.

But it does have some limitation for users as well, here are some limitations (how to bypass the limitations as well) and some tips to use AWS Lambda properly.

![](https://miro.medium.com/v2/resize:fit:1400/0*tn9BVCn9xr0bKYml)

JavaScript Codes

# Limits of AWS Lambda

## 1. Payload Limit: 6 MB

A self-hosted Express service, by default it is **100 kB**, but it could have **unlimited** size of the payload.

> _Note: that some browsers and servers may have their own limits on the size of request and response bodies, so you may need to configure those as well._

6 MB, in most cases it should be more than enough. But if the requirements for the payload is big, or your product is data heavy, then AWS Lambda probably is not a good option.

If you have to use AWS Lambda and the Payload is so big, consider read about this about [**how to use AWS S3 pre-signed URL**](https://stackoverflow.com/questions/60010366/how-to-deal-with-6-megabytes-limit-in-aws-lambda-services) to solve this issue.



## How to deal with 6 megabytes limit in AWS lambda services?

- [I have a three-tier app running in AWS. The midware was written in Python Flask and stored on a Linux machine. However…stackoverflow.com](https://stackoverflow.com/questions/60010366/how-to-deal-with-6-megabytes-limit-in-aws-lambda-services)

## 2. Package Size: 50 MB

Since the deployment ZIP package for AWS Lambda, it always includes the dependency, no matter what language it is, Python, JavaScript, Dot Net … The packages size may be easier to reach 50 MB, besides optimise your dependency, for example in NodeJS project,

`npm install --production`

It could omit all dev dependencies to significantly reduce the package size.

There are other ways to solve the deployment package size limit issue, this article below is a good start to know more about it.

[3 Ways to Overcome AWS Lambda Deployment Size Limit — Part 1 Overcome Lambda Deployment Size Limit medium.com](https://medium.com/geekculture/3-ways-to-overcome-aws-lambda-deployment-size-limit-part-1-f2eb2170b75b)

## 3. AWS Function Time-out: 900 seconds

**_900 seconds === 15 minutes_**

If you really have a work takes longer than 15 minutes to complete, consider using AWS SQS to build an asynchronous event-driven architecture.

Know more about SQS:



## Event-driven architecture with Amazon SQS and AWS Lambda

[SQS to Lambda, event-driven architecture is a queue and made easier now that Amazon SQS can trigger AWS Lambda…acloudguru.com](https://acloudguru.com/blog/engineering/event-driven-architecture-with-sqs-and-aws-lambda)

More practical article from Enlear Academy.



## Event Driven Architecture with AWS SQS

[Cloud-native Queue Service in Microservice Architecture enlear.academy](https://enlear.academy/event-driven-architecture-with-aws-sqs-d277851442c6)

If you don’t have to be sticky on AWS Lambda, there are other services as well.

-   AWS Batch: AWS Batch is a service that allows you to run batch computing workloads on the AWS Cloud. You can use AWS Batch to execute long-running tasks that cannot be completed within the 15-minute limit of Lambda.
-   AWS Fargate: AWS Fargate is a serverless compute engine that allows you to run containers on the AWS Cloud without managing the underlying infrastructure. You can use Fargate to run long-running tasks that cannot be completed within the 15-minute limit of Lambda.

## 4. AWS Lambda Supports 7 programming languages Natively

[Node.js](http://docs.aws.amazon.com/lambda/latest/dg/authoring-function-in-nodejs.html), [Python](http://docs.aws.amazon.com/lambda/latest/dg/python-lambda.html), [Java](http://docs.aws.amazon.com/lambda/latest/dg/java-lambda.html), [Ruby](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html), [C#](http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html), [Go](https://docs.aws.amazon.com/lambda/latest/dg/go-programming-model.html), and [PowerShell](https://docs.aws.amazon.com/lambda/latest/dg/powershell-programming-model.html).

This could be bypassed in 2 ways.

-   Use AWS Lambda [Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html)
-   Use [Lambda Container](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html)

![](https://miro.medium.com/v2/resize:fit:1400/0*r94QqRrjb4KL09yH)

AWS Lambda Bridge

# Some useful Tips

## 128 MB Ram is not Always the Cheapest Option

When people started to use AWS Lambda, 128MB is always the defaul RAM to choose, since it is supposed to be cheaper. In fact, this statement is not always accurate.

> In general, the cost of running a Lambda function with 128MB of memory allocated is relatively low compared to functions with higher memory allocations. This is because Lambda charges you based on the amount of memory used and the duration of the function execution.
> 
> When you allocate more memory to a Lambda function, it gets more CPU power and network bandwidth, which can help it complete its task faster. However, you will be charged more for the additional memory usage. On the other hand, if your function doesn’t require a lot of memory or CPU power, allocating 128MB of memory can be a cost-effective option.

Dashbird offers a free calculator to help to estimate the cost of AWS Lambda.



## AWS Lambda Cost Calculator - Dashbird

[Request costs: $0/month Execution costs: $0/month Total AWS Lambda costs: $0/month AWS Lambda uses a pay-as-you-use dashbird.io](https://dashbird.io/lambda-cost-calculator/)

So for saving the cost of AWS Lambda computing cost, try tuning it finely, the result may be surprising in the end.

## Don’t Forget to Use VPCs

If your function requires access to resources in a private network, such as a database or cache, you can configure your function to run in a Virtual Private Cloud (VPC). This allows your function to access these resources securely without exposing them to the public internet. For example, if Aurora DB is used, you don’t have to expose the Aurora DB or other data storage tier publicly, VPC could be used here to build better security.

## Try AWS SAM

AWS Console offers an interface for users to interact or try AWS Lambda, including deployment and testing. But SAM can simplify this for you locally.

SAM allows you to define your function’s resources and dependencies in a YAML file and deploy them using the AWS CLI. SAM can simplify your deployment process and make it easier to manage your function’s resources.

# References

**Others Interesting Articles of using AWS Lambda:**

-   [Run WordPress in AWS Lambda](https://keita.blog/2019/06/27/serverless-wordpress-on-aws-lambda/) WordPress is a PHP based popular CMS, when it was born, there was no cloud technoloy at all.
-   [Run WordPress on AWS Lambda (EFS Edition)](https://keita.blog/2020/06/29/wordpress-on-aws-lambda-efs-edition/)
-   [Run container in AWS Lambda](https://earthly.dev/blog/aws-lambda-docker/) to remove the language restriction
-   [Building a simple serverless application status page](https://medium.com/tixel-dev/building-a-simple-serverless-application-status-page-974db757aa5e) a simple project to build on AWS Lambda

**References:**

-   [AWS Doc Lambda Get Started](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)
-   [Lambda performance and Limit](https://lumigo.io/aws-lambda-performance-optimization/aws-lambda-limits/)