Elad Hazan
Elad Hazan

Reputation: 391

Lambda was throttled while using the Lambda Execution Role to set up for the Lambda function

I use API GATEWAY with Lambda for my application. In one of my functions I suddenly get 502 with this error:

{ "Message": "Lambda was throttled while using the Lambda Execution Role to set up for the Lambda function. ", "Type": "User" }

I checked online and did not find anything related to that error.

I checked my ConcurrentExecutions and did not over the limit.

My lambdas use VPC in every lambda, and Maybe there is a connection?

Will be glad for any help. Thank you

Upvotes: 2

Views: 6084

Answers (2)

Niraj Sonawane
Niraj Sonawane

Reputation: 11055

To enable your Lambda function to access resources inside your private VPC, you must provide additional VPC-specific configuration information that includes VPC subnet IDs and security group IDs.

AWS Lambda uses this information to set up elastic network interfaces (ENIs) that enable your function to connect securely to other resources within your private VPC.

If your VPC does not have sufficient ENIs or subnet IPs, your Lambda function will not scale as requests increase, and you will see an increase in invocation errors with EC2 error types like EC2ThrottledException.

one of the option to avoid this exception is , You can Specifying Multiple subnets in each of the Availability Zones, your Lambda function can run in another Availability Zone if one goes down or runs out of IP addresses.

Upvotes: 9

Vishal
Vishal

Reputation: 706

This error means your request got throttled by EC2 rate limit while connecting to your VPC.

As per lambda documentation

"Because Lambda depends on Amazon EC2 to provide Elastic Network Interfaces for VPC-enabled Lambda functions, these functions are also subject to Amazon EC2's rate limits as they scale. If your Amazon EC2 rate limits prevent VPC-enabled functions from adding 500 concurrent invocations per minute, please request a limit increase by following the instructions on the AWS Lambda Limits page.

Beyond this rate (i.e. for applications taking advantage of the full Immediate concurrency increase), your application should handle Amazon EC2 throttling (502 EC2ThrottledException) through client-side retry and backoff. For more details, see Error Retries and Exponential Backoff in AWS."

Ref : https://docs.aws.amazon.com/lambda/latest/dg/scaling.html#scaling-behavior

Upvotes: 1

Related Questions