Configuring AWS Lambda for Scale and Performance
Lambda scales automatically, but its configuration still decides how fast functions run, how many can run at once, how quickly they start and what they can reach. This lesson explains memory and CPU, timeouts and storage, concurrency and scaling rates, provisioned concurrency and SnapStart for start-up latency, VPC networking and how event source mappings scale.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how memory, architecture, timeout and ephemeral storage settings affect performance and cost.
- Explain Lambda concurrency, the scaling rate of functions, and how reserved and provisioned concurrency differ.
- Describe cold starts and how provisioned concurrency and SnapStart reduce them.
- Explain Lambda VPC networking and how SQS and stream event source mappings scale.
Memory, CPU and Other Settings
A function's memory setting, from 128 MB to 10,240 MB, also determines its CPU and network capacity: CPU is allocated in proportion to memory, reaching six vCPUs at the top of the range. A CPU-bound function often becomes both faster and cheaper when memory is increased, because duration falls more than the price per millisecond rises; AWS Lambda Power Tuning, an open-source Step Functions tool, measures this trade-off. Arm64 (Graviton) functions usually cost less per millisecond and perform as well or better for most runtimes. The timeout can be up to 15 minutes and should be set just above the expected maximum duration. Ephemeral storage in /tmp is configurable from 512 MB to 10,240 MB.
10,240MB
Maximum memory (CPU scales with memory)
15minutes
Maximum timeout
1,000executions
Default Regional concurrency quota
1,000per 10 s
Scaling rate per function
Concurrency and Scaling
Concurrency is the number of requests a function is handling at the same time; each concurrent request uses one execution environment. Concurrency is approximately requests per second multiplied by average duration in seconds, so a function receiving 500 requests per second that takes 200 ms needs about 100 concurrent executions. All functions in an account and Region share the Regional concurrency quota, 1,000 by default and raisable to tens of thousands.
Each function can scale by 1,000 concurrent executions every 10 seconds, independently of other functions, until the account quota is reached. Requests beyond available concurrency are throttled. Two settings control concurrency per function.
- Reserved concurrency sets both a maximum and a guaranteed allocation for a function. It protects critical functions from being starved by others and protects downstream systems, such as a database, from too many concurrent calls. It has no charge.
- Provisioned concurrency keeps a number of execution environments initialised and ready, so requests are served without cold starts. It is configured on a version or alias, is charged while configured, and can be scaled with Application Auto Scaling, using target tracking on provisioned concurrency utilisation or schedules for predictable peaks.
The comparison below contrasts the two settings.
The following diagram shows how reserved concurrency divides the account's quota.

Lambda concurrency
Cold Starts and SnapStart
A cold start happens when Lambda must create a new execution environment: download the code, start the runtime and run initialisation code outside the handler. It adds from tens of milliseconds to several seconds, depending on runtime, package size and initialisation work. Cold starts occur on scale-out and after periods of inactivity.
Mitigations include keeping deployment packages small, initialising SDK clients and connections outside the handler so later invocations reuse them, choosing runtimes with fast start-up, provisioned concurrency for strict latency requirements, and Lambda SnapStart. SnapStart, available for Java, Python and .NET runtimes, takes a snapshot of the initialised execution environment when a version is published and resumes new environments from the cached snapshot, which reduces start-up time substantially at low cost. Code that generates unique values or opens connections during initialisation must handle being restored from a snapshot, using runtime hooks.
Reserved, provisioned or SnapStart?
VPC Networking
By default, functions run in a Lambda-managed network with internet access but no access to private VPC resources. A function configured with VPC subnets and security groups can reach private resources such as RDS databases, ElastiCache clusters and internal services. Lambda creates shared Hyperplane network interfaces per subnet and security group combination, so VPC functions no longer suffer long cold starts from interface creation.
A VPC function has no internet access and no access to public AWS service endpoints unless its subnets route to a NAT gateway or VPC endpoints exist for the services it calls; as with CodeBuild, placing the function in a public subnet does not give it internet access. The execution role needs permissions to manage network interfaces, provided by the AWSLambdaVPCAccessExecutionRole managed policy. Connections from many concurrent functions to a relational database should go through RDS Proxy.
Scaling Event Source Mappings
Poll-based event sources scale differently from direct invocations. For Amazon SQS, Lambda increases the number of pollers as the queue backlog grows, and the maximum concurrency setting on the event source mapping limits how many concurrent invocations the queue can drive, which protects downstream systems without reserved concurrency throttling the queue's messages. Batch size and batching window trade latency for efficiency. Provisioned mode for SQS event source mappings offers faster scaling for spiky queues.
For Kinesis Data Streams and DynamoDB Streams, Lambda processes each shard in order, by default with one concurrent invocation per shard. The parallelisation factor (up to 10) processes several batches per shard concurrently while preserving order per partition key. Increasing shards or the parallelisation factor raises throughput; the IteratorAge metric shows whether processing is falling behind.
Tuning a Latency-Sensitive Function
A Java function behind an API has p99 latency of three seconds caused by cold starts during morning traffic ramps, occasionally exhausts database connections, and is throttled when another team's batch function runs.
-
Start-up
Enable SnapStart on the published version used by the alias, or provisioned concurrency scheduled for business hours if latency must be guaranteed.
-
Isolation
Set reserved concurrency for the API function, guaranteeing it capacity regardless of the batch function, and for the batch function to cap its share.
-
Database
Connect through RDS Proxy, with the client created during initialisation.
-
Right-sizing
Run Lambda Power Tuning to choose memory, and test Arm64.
An SQS-triggered function overloads a downstream API. The team sets reserved concurrency to 5, and many messages now end up in the dead-letter queue. What is a better control?
Show answer
Set the event source mapping's maximum concurrency to 5. Reserved concurrency throttles invocations, which return messages to the queue and increase their receive count until they move to the DLQ; maximum concurrency limits polling instead.
Exam Tips
Remember for the exam
- CPU scales with memory; more memory can reduce both duration and cost for CPU-bound functions; Arm64 is usually cheaper.
- Default Regional concurrency is 1,000; each function scales by 1,000 executions every 10 seconds.
- Reserved concurrency limits and guarantees capacity at no charge; provisioned concurrency removes cold starts and is charged; SnapStart reduces start-up for Java, Python and .NET.
- VPC functions need a NAT gateway or VPC endpoints for internet and AWS API access; use RDS Proxy for databases.
- Use SQS event source mapping maximum concurrency to protect downstream systems; use the parallelisation factor for streams.