AWS Lambda

AWS Lambda is a serverless computing service from Amazon Web Services that lets users run code as functions without provisioning or managing servers, handling server maintenance, logging, capacity provisioning, automatic scaling, and code monitoring on the user’s behalf.

AI Practitioner focus

  • Lambda commonly orchestrates AI requests, preprocesses input, validates output, invokes Bedrock or managed AI APIs, and fulfills Amazon Lex intents.
  • It is event-driven serverless compute, not a foundation-model host or large-model training platform; duration, memory, payload, and cold-start constraints still apply.

Key points

  • Lets users build serverless applications composed of Lambda functions triggered by events; deployment can be automated with AWS CodePipeline and AWS CodeBuild.
  • Supported managed runtimes: Java, Python, Node.js, Ruby, C#/.NET, and PowerShell (via .NET). Go no longer has a dedicated managed runtime — the standalone go1.x runtime was deprecated in January 2024 — and is now supported through the OS-only (provided.al2023) runtime instead.
  • Memory allocated ranges from 128MB (minimum) to 10,240MB/10GB (maximum), adjustable in increments of 1MB.
  • Default execution time is 3 seconds; maximum execution time is 15 minutes (900 seconds) (one comparison slide elsewhere cites a 300-second limit, but 900 seconds/15 minutes is the more precise figure).
  • Ephemeral storage (/tmp) defaults to 512 MB and can be configured independently of memory up to 10,240 MB.
  • Lambda SnapStart caches a pre-initialized snapshot of a function’s execution environment to cut cold-start latency to as low as sub-second. It’s supported for Java 11+, Python 3.12+, and .NET 8+ managed runtimes, but not for Node.js, Ruby, OS-only runtimes, or container image functions.
  • Delivers small, short-runtime computing units that maximize operational efficiency and minimize the cost of running the application.
  • Amazon EC2 vs. AWS Lambda:
    • EC2 instances are virtual servers; Lambda functions are virtual functions.
    • EC2 is limited by instance type (RAM and CPU); Lambda is limited by execution time.
    • EC2 runs continuously; Lambda runs on demand.
    • EC2 scaling is manual; Lambda scaling is automated.
  • Example flow: Amazon API Gateway triggers a Lambda function (assuming a Lambda IAM role), which processes logic and reads/writes Amazon DynamoDB.
  • Shared responsibility: AWS maintains the server/OS, language runtime, and automatic scaling; the customer is responsible for writing and updating the function code and its in-code security, and for granting the function IAM access to other services.
  • For orchestrating retries and timeouts across multiple functions without writing that logic into the code, use AWS Step Functions rather than handling it inside a single Lambda function.

Pricing

  • Charges are based on the number of requests to the functions and the time taken to execute the code.

Sources