Provisioned Concurrency

AWS Lambda Provisioned Concurrency

Configuring a Lambda function to access resources in VPC

Connect your function to private subnets to access private resources. If your function needs internet access, use NAT. Connecting a function to public subnets does NOT give it internet access or a public IP address

When you connect to VPC, Lamda creats an Elastic Network Interface (ENI) Multiple functions connected to the same subnets share network interfaces

Permissions needed:

  • ec2:CreateNetworkInterface
  • ec2:DescribeNetworkInterfaces
  • ec2:DeleteNetworkInterface

These persmissions included in AWSLambdaVPCAccessExecutionRole managed policy.

Synchronous invocation

$ aws lambda invoke --function-name my-function --payload '{ }' response.json

lambda synchronous invocation

Asynchronous invocation

asynchronous invocation

$ aws lambda invoke --function-name my-function --invocation-type Event --payload '{"key": "value"}' response.json
{
  "StatusCode": 202
}

If your function returns an error, AWS will automatically retry the invoke twice, for a total of three invocations.

Dwell time how long your request spent in the service queue

Poll-Based Invocation

  • Amazon Kinesis
  • Amazon SQS
  • Amazon DynamoDB

invocation types

Function scaling

function scaling

Function scaling with Provisioned Concurrency

provisioned-concurrency

Autoscaling with Provisioned Concurrency

provisioned-concurrency