Concepts

AWS Lambda

AWS serverless compute service that runs code in response to events without provisioning or managing servers, automatically scaling from zero to thousands of concurrent executions.

seed#aws#lambda#serverless#faas#event-driven#cloud

What it is

AWS Lambda is Amazon's Functions as a Service (FaaS) offering. It lets you run code without provisioning servers — you upload your function, define what events trigger it, and AWS handles the rest: provisioning, scaling, high availability, and monitoring.

Execution model

  1. An event triggers the function (HTTP request, SQS message, S3 file, etc.)
  2. Lambda provisions an execution environment (or reuses an existing one)
  3. Your code executes
  4. Lambda charges by duration (ms) and allocated memory
  5. The environment may stay "warm" for subsequent requests

Key features

  • Runtimes: Node.js, Python, Java, Go, .NET, Ruby, or custom (container)
  • Memory: 128 MB to 10 GB (CPU scales proportionally)
  • Maximum duration: 15 minutes per invocation
  • Concurrency: up to 1,000 by default (expandable)
  • Layers: shared libraries across functions
  • Provisioned concurrency: eliminates cold starts for critical functions

Common triggers

TriggerUse case
API GatewayREST/HTTP APIs
S3File processing
DynamoDB StreamsReacting to data changes
SQSQueue processing
EventBridgeScheduled or service events
CognitoAuthentication hooks

Cold starts

A "cold start" occurs when Lambda must initialize a new environment:

  • Typically 100ms-1s for interpreted runtimes
  • Can be several seconds for Java/.NET
  • Mitigation: provisioned concurrency, keep functions small, SnapStart (Java)

Best practices

  • Keep functions small and focused
  • Reuse connections (DB, HTTP) outside the handler
  • Use environment variables for configuration
  • Implement idempotency for retries
  • Monitor with CloudWatch and X-Ray

Why it matters

Lambda changed the way we think about infrastructure: instead of provisioning servers, you define functions that execute in response to events. For workloads with variable traffic, the pay-per-execution model can reduce costs by orders of magnitude compared to always-on servers.

References

Concepts