Volume 4 · Chapter 10 — Compute and Containers

Lambda in Depth

Goutham Mayaluri 4 min read AWSCloudLambdaContainers

10.1 Introduction

The serverless chapter covered when to use Lambda; the exam wants the operational depth - the execution and concurrency model, reserved versus provisioned concurrency, cold-start mitigation, versions and aliases, layers, how event sources connect, VPC integration, and the hard limits. These determine performance, cost, and correct integration.

10.2 Execution, Limits, and Pricing

Lambda runs your function in a managed execution environment, charging for the number of requests and theGB-secondsof compute (memory × duration) - you set memory (128 MB to 10 GB), and CPU scales with memory, so more memory can mean faster and sometimes cheaper execution. Key limits the exam tests: a maximum15-minutetimeout (so long-running jobs belong on containers/Batch), up to 10 GB memory, a deployment package size limit (larger via container images up to 10 GB), and/tmpephemeral storage up to 10 GB. Because idle costs nothing, Lambda is ideal for event-driven and spiky work, but the 15-minute ceiling and cold starts bound where it fits.

10.3 Concurrency: Reserved and Provisioned

Lambda scales by running concurrent execution environments, up to an account concurrency limit.Reserved concurrencyguarantees (and caps) a set number of concurrent executions for a function - protecting downstream resources (like a database with limited connections) from being overwhelmed and ensuring a critical function always has capacity.Provisioned concurrencykeeps a number of environmentspre-initialized and warm, eliminating cold-start latency for latency-sensitive functions.SnapStart(for supported runtimes) reduces cold starts by snapshotting an initialized environment. The exam mapping: reserved concurrency to cap/guarantee and protect downstreams; provisioned concurrency (or SnapStart) to remove cold-start latency where it matters.

flowchart TB
  Concern{Concurrency concern?} -->|Protect a limited downstream / guarantee capacity| RC[Reserved concurrency - cap & reserve]
  Concern -->|Remove cold-start latency| PC[Provisioned concurrency - pre-warmed]
  Concern -->|Cheaper cold-start reduction| SS[SnapStart - snapshot init]

10.4 Versions, Aliases, and Layers

Versionsare immutable published snapshots of a function;aliasesare named pointers to versions (likeprodorstaging) that let you shift traffic - includingweightedaliases for canary deployments (send 10% to the new version). This is how you deploy Lambda safely and roll back by repointing the alias.Layerspackage shared libraries or dependencies separately so multiple functions reuse them and deployment packages stay small.Lambda extensionsintegrate monitoring/security tools into the execution environment. These features make Lambda deployable and maintainable at scale, mirroring the safe-deployment patterns used elsewhere.

10.5 Event Sources, Destinations, and VPC

Lambda is triggered two ways. Some sourcespushevents directly (API Gateway, S3, SNS) - synchronous or asynchronous invocation. For stream and queue sources (SQS, Kinesis, DynamoDB Streams), anevent source mappingis a Lambda-managed poller that reads batches and invokes the function - you configure batch size, and for streams the ordering/parallelism per shard. Asynchronous invocations supportdestinations(on success/failure, route to SQS/SNS/EventBridge/another Lambda) and a dead-letter queue for failures.Lambda in a VPCattaches ENIs so the function can reach private resources (like an RDS database) - now efficient via shared ENIs, but note a VPC-attached function reaches the internet only through a NAT gateway (or uses VPC endpoints for AWS services). Knowing push vs event-source- mapping, destinations, and VPC networking is core to integrating Lambda correctly.

10.6 Banking Production Scenario

A bank uses Lambda for event-driven work: S3 uploads trigger document processing (push), and an event source mapping polls an SQS queue of transactions with a tuned batch size. Reserved concurrency caps the transaction function so it never exhausts the RDS connection pool, while a latency-sensitive customer-facing function uses provisioned concurrency to eliminate cold starts. Deployments publish versions and shift aprodalias with weighted routing for canary releases, rolling back by repointing the alias. Shared crypto and validation libraries are packaged as layers. Asynchronous invocations use on-failure destinations to an SQS DLQ for investigation. Functions needing the database run in the VPC with endpoints for AWS services to avoid NAT costs. This precise Lambda operational design is the professional-level serverless competence the exam targets.

10.7 Chapter Revision Notes

  • Charged by requests + GB-seconds (memory × duration; CPU scales with memory); limits: 15-min timeout, 10 GB memory, 10 GB /tmp, package/container size - long jobs go to containers/Batch.
  • Reserved concurrency caps/guarantees executions (protect downstreams); provisioned concurrency (or SnapStart) removes cold-start latency.
  • Versions (immutable) + aliases (pointers, weighted for canary) enable safe deploy/rollback; layers share dependencies.
  • Push sources (API GW, S3, SNS) invoke directly; SQS/Kinesis/DynamoDB Streams use an event source mapping (poller, batching); async supports destinations + DLQ.
  • Lambda-in-VPC attaches ENIs for private access; reaches the internet only via NAT, or uses VPC endpoints for AWS services.