Triggers, concurrency and runtime lifecycle
Three ways work reaches Lambda
A synchronous caller waits for the function response and handles invocation failures. An asynchronous caller submits an event to Lambda for later processing; acceptance is not evidence that the handler succeeded. For supported queues and streams, an event source mapping polls records and invokes the function with batches. Each source has its own acknowledgment, ordering and retry behavior. For example, an interactive price lookup can be synchronous, a background notification asynchronous, and a queue of order jobs polled.
Estimate concurrent work
Concurrency counts invocations in progress. For a steady arrival rate of 40 requests/second and average duration 0.25 seconds, the average is 10 concurrent invocations (40 × 0.25). Bursts, cold starts, quotas and request-rate limits mean this is not a sizing guarantee. Reserved concurrency allocates capacity from the account pool to the function and caps its concurrency; it does not prewarm environments. Provisioned concurrency keeps configured capacity initialized for a version or alias and costs money even during idle periods. It does not impose a universal cap; excess requests may use other available capacity.
Memory, timeout and runtime maintenance
Memory configuration affects CPU allocation as well as available memory. Measure duration and memory use with representative bounded inputs rather than assuming more memory always saves money. A timeout ends an invocation; an external write may already have succeeded. Set downstream timeouts shorter than the function deadline and leave time for cleanup. Choose a supported runtime, track its deprecation schedule and test dependency and runtime updates before switching versions. Do not assume the runtime identifier alone pins every patch.
An offline cost comparison
For a simplified on-demand example, 1,000 invocations at 512 MiB and 0.2 billed seconds each consume 100 GB-seconds using the 1024 MiB per configured GB convention. With fictional rates of $0.20 per million requests and $0.000020 per GB-second, request cost is $0.0002 and compute cost $0.002, totaling $0.0022. This excludes credits, tiers, additional storage, logs, transfer, downstream services and provisioned capacity. Actual billing depends on configuration, region, architecture and current price terms. No actual usage is generated.
Protect downstream capacity
If a database safely handles only 20 concurrent requests, unlimited function scaling can overwhelm it. Start with a conservative concurrency bound, queue buffering where appropriate, short connection timeouts and monitoring of throttles, errors, duration and queue backlog. Monitor before changing limits; a cap can move waiting work upstream. Never run load tests against shared production infrastructure without explicit approval.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Triggers, concurrency and runtime lifecycle — knowledge check
Reason about fictional Lambda workloads without an AWS account.
A synchronous price lookup needs the result immediately. Which invocation fits?
At 80 requests/s and 0.5 seconds average duration, what is average concurrency?
Which setting both reserves capacity and caps function concurrency without prewarming?
A queue sends a batch to a handler. Which determines retries?
How many GB-seconds do 1000 invocations at 512 MiB and 0.2 billed seconds use?