How Lambda works
A Lambda function is code that runs in response to an event. The event could be an HTTP request through API Gateway, a file uploaded to S3, a message arriving in an SQS queue, a record appearing in a DynamoDB stream, or a scheduled time via EventBridge. When the event fires, Lambda provisions a runtime environment, loads your function, executes it, and tears down the environment when done.
Lambda functions have hard limits you need to know. Maximum execution timeout is 15 minutes. If your function needs to run longer, Lambda is the wrong tool: use EC2, ECS, or Batch instead. Memory allocation ranges from 128 MB to 10 GB. CPU scales proportionally with memory, so allocating more memory also gives you more CPU. Maximum package size is 50 MB compressed, or 250 MB uncompressed. For larger dependencies, Lambda Layers let you separate large libraries from your function code and share them across functions.
Invocation types matter for the exam. Synchronous invocation means the caller waits for the function to return a result: API Gateway always invokes Lambda synchronously. Asynchronous invocation means Lambda queues the event and returns immediately: S3 event notifications trigger Lambda asynchronously. Event source mapping is how Lambda polls services like SQS, Kinesis, and DynamoDB Streams and invokes functions in batches.
Cold starts, concurrency, and serverless patterns
Cold starts are the latency cost of spinning up a new Lambda execution environment. When no warm environment is available, Lambda has to initialize the runtime, load your code, and run your initialization code before handling the actual request. For Python or Node.js functions, this might add 100-500 ms. For Java or .NET functions with large frameworks, cold starts can exceed a second. Provisioned Concurrency solves this by keeping a specified number of environments initialized and ready, eliminating cold starts for that concurrency level at an additional cost.
Concurrency is the number of function instances running simultaneously. By default, Lambda scales to match incoming requests automatically, up to the regional account limit. Reserved Concurrency sets a maximum for a specific function, preventing it from consuming all available concurrency and starving other functions. It also guarantees that concurrency is always available for that function.
Step Functions orchestrates multiple Lambda functions into workflows. Instead of chaining functions by having one function call another directly, Step Functions uses a state machine to define the sequence, handle errors, add wait states, and execute branches in parallel. This keeps Lambda functions simple and single-purpose while the workflow logic lives in the state machine definition.
How to choose the correct answer
Lambda maximum timeout: 15 minutes. If a task takes longer, use EC2, ECS Fargate, or AWS Batch.
Synchronous triggers: API Gateway, Application Load Balancer, Cognito, Lex. The caller waits.
Asynchronous triggers: S3 events, SNS notifications, EventBridge rules. Lambda queues the event.
Event source mapping (Lambda polls): SQS, Kinesis Data Streams, DynamoDB Streams. Batch processing.
Cold start mitigation: Provisioned Concurrency. Cost reduction: Reserved Concurrency caps usage.
Multi-function workflows: Step Functions state machines rather than Lambda calling Lambda directly.
Lambda Layers: shared dependencies across functions. Lambda@Edge: run functions at CloudFront edge locations.