Lambda
AWS Lambda runs a function in response to an event. There is no server to provision, no capacity to plan, and no charge when nothing is happening: you supply code and a configuration, and AWS creates and destroys execution environments to match demand.
Functions are best kept small and single-purpose. Anything that needs a long warm-up, holds state between calls, or runs at sustained high volume at a predictable rate is usually better on containers or AWS Batch.
Networking
Section titled “Networking”By default a function runs outside your VPC with internet access. Attach it to a VPC — subnets and security groups — to reach private resources such as an RDS instance or an internal load balancer. A VPC-attached function reaches the internet only through a NAT gateway or a VPC endpoint, which is the usual cause of a function that suddenly cannot call a public API.
Pricing
Section titled “Pricing”Charged per request and per GB-second of duration, with the free tier covering one million requests and 400,000 GB-seconds per month. Provisioned concurrency is charged separately and is not covered by the free tier.
Because duration is billed in GB-seconds, more memory is not automatically more expensive: a function that runs twice as fast at double the memory costs the same and returns sooner. Tune memory by measurement, not by assumption.
Configuration
Section titled “Configuration”Memory and CPU. 128 MB to 10,240 MB, in 1 MB increments. CPU is allocated in proportion: one vCPU at 1,769 MB, up to roughly six vCPUs at the maximum. A function that is single-threaded stops getting faster past one vCPU.
Execution time. 900 seconds (15 minutes) by default. Functions using AWS Lambda Managed Instances allow up to 5,400 seconds (90 minutes) for asynchronous invocations and for event source mappings, except Amazon MQ and Amazon DocumentDB. For anything longer, or anything that needs a host, use ECS, AWS Batch or EC2.
Runtimes. Managed runtimes for Node.js, Python, Java, .NET and Ruby, each pinned to a major language version and each with a published deprecation date. Go and Rust run on the OS-only runtime. All supported runtimes run on both x86-64 and arm64 (Graviton), and arm64 is usually cheaper. Check the supported runtimes table before pinning a version — a deprecated runtime eventually blocks function creation and then function updates.
Packaging. A .zip archive, optionally with layers, or a container image up to 10 GB.
Triggers
Section titled “Triggers”- Scheduled events through Amazon EventBridge
- HTTP requests through API Gateway, an Application Load Balancer, or a Lambda function URL
- Object events in Amazon S3
- Messages from Amazon SQS, Amazon SNS or Amazon Kinesis
- Streams from Amazon DynamoDB
- Many other AWS services, directly or through EventBridge
Monitoring
Section titled “Monitoring”CloudWatch Logs for output, CloudWatch metrics for invocations, duration, errors, throttles and concurrency, and AWS X-Ray for traces across the services a function calls.
Storage
Section titled “Storage”Each execution environment has a /tmp directory sized between 512 MB and 10,240 MB. It survives between invocations that reuse the same environment, which makes it useful as a cache, and disappears when the environment is reclaimed — so never treat it as durable. For anything larger or shared, use Amazon S3 or mount an Amazon EFS file system (which requires a VPC configuration).
Quotas and limits
Section titled “Quotas and limits”Compute and storage
- 1,000 concurrent executions by default per Region, increasable on request
- 128 MB – 10,240 MB memory, in 1 MB increments
- 512 MB – 10,240 MB of
/tmpstorage - 4 KB total for all environment variables
- Concurrency scaling rate: 1,000 additional execution environments every 10 seconds, per function
Execution
- 900 seconds maximum, or 5,400 seconds for Managed Instances functions invoked asynchronously or through an event source mapping (except Amazon MQ and DocumentDB)
- 625 Mbps network bandwidth per execution environment by default
Deployment and payloads
- Zipped
.zippackage ≤ 50 MB when uploaded through the API or console; use S3 for larger - Unzipped package, including layers, ≤ 250 MB
- Container image ≤ 10 GB uncompressed
- 5 layers per function
- Request and response payload ≤ 6 MB each, synchronous
- Streamed response ≤ 200 MB, synchronous — uncapped bandwidth for the first 6 MB, then 2 MB/s
- Asynchronous invocation payload ≤ 1 MB
New accounts start with reduced concurrency and memory quotas that AWS raises automatically as usage grows. Confirm the numbers that apply to your account in the Service Quotas console rather than assuming the defaults.
Further reading
Section titled “Further reading”- Lambda architecture patterns — fan-out, state management, SAM and EventBridge
- Scaling and concurrency — reserved and provisioned concurrency, cold starts, memory tuning