AWS Lambda
AWS Lambda
Overview
AWS Lambda runs code without managing any servers. Functions are invoked by events (HTTP requests, file uploads, queue messages, schedules) and scale automatically. Billing covers only invocation count and duration proportional to allocated memory — no idle cost. Focus entirely on business logic while AWS handles infrastructure provisioning, patching, and scaling.
Key Concepts
Event-Driven and Triggers
Lambda is invoked by a wide range of AWS services: API Gateway (HTTP), S3 object creation, DynamoDB Streams, SQS/SNS, and EventBridge schedules. Push-type invocations (the caller triggers Lambda) and pull-type/polling (Lambda reads from a stream or queue) have different retry and error behavior — understand the distinction.
Runtime and Limits
Allocate memory to a function; CPU scales proportionally. Maximum execution time is 15 minutes — unsuitable for long-running or persistent processes. Ephemeral disk space (/tmp) is available. Deployment packages can be ZIP archives or container images. For processes exceeding 15 minutes, use Step Functions or switch to ECS/Fargate.
Cold Starts and Concurrency
When a function hasn't run recently or needs to scale out, initialization time (cold start) adds latency. For latency-sensitive workloads, use Provisioned Concurrency to keep environments warm. Account-level concurrency limits apply; per-function reserved and maximum concurrency settings isolate functions from each other.
IAM Roles and Permissions
Each Lambda function has an execution role defining what AWS services it can access (e.g., write to S3). Policies controlling who can invoke the function are on the resource-based side. Always use roles — never embed credentials in code.
VPC Connectivity and Dependencies
Attaching a function to a VPC enables access to private resources like RDS. Internet outbound from a VPC-attached function requires NAT. Use RDS Proxy to pool and reuse database connections (Lambda creates many ephemeral connections). Design functions to be stateless and retry-safe.
Typical Use Cases
- Serverless REST/HTTP API backends combined with API Gateway
- Image processing, thumbnail generation, or file conversion triggered by S3 uploads
- Asynchronous and event-driven pipelines with SQS/SNS or EventBridge
- Scheduled lightweight maintenance and batch-style jobs using EventBridge cron
- Real-time data transformation from DynamoDB Streams or Kinesis
Exam Relevance
Lambda is central to DVA and appears frequently in SAA and SAP as the engine for serverless design. 'Eliminate server management,' 'event-driven auto-scaling,' 'no idle cost' — these requirements almost always make Lambda a candidate. The 15-minute limit is a critical constraint: longer jobs go to Step Functions or Fargate. DVA tests cold start mitigation (Provisioned Concurrency), concurrency control, execution role design, environment variables vs. Secrets Manager, and VPC connectivity with NAT. VPC-attached Lambda needing internet access through NAT, and DB connection exhaustion mitigated by RDS Proxy, are common exam pitfalls.
Related Services
References
Last updated: 2026-06-24
This page is created from AWS official documentation and reviewed/edited by the operator. See our editorial & quality policy for details.