Menu
AWS Lambda
Developer Guide

Lambda Function Concurrent Executions

Concurrent executions refers to the number of executions of your function code that are happening at any given time. You can estimate the concurrent execution count, but the concurrent execution count will differ depending on whether or not your Lambda function is processing events from a stream-based event source.

  • Stream-based event sources – If you create a Lambda function that processes events from stream-based services (Amazon Kinesis Streams or DynamoDB streams), the number of shards per stream is the unit of concurrency. If your stream has 100 active shards, there will be at most 100 Lambda function invocations running concurrently. Then, each Lambda function processes events on a shard in the order that they arrive.

  • Event sources that aren't stream-based – If you create a Lambda function to process events from event sources that aren't stream-based (for example, Amazon S3 or API Gateway), each published event is a unit of work. Therefore, the number of events (or requests) these event sources publish influences the concurrency.

    You can use the following formula to estimate your concurrent Lambda function invocations:

    Copy
    events (or requests) per second * function duration

    For example, consider a Lambda function that processes Amazon S3 events. Suppose that the Lambda function takes on average three seconds and Amazon S3 publishes 10 events per second. Then, you will have 30 concurrent executions of your Lambda function.

Request Rate

Request rate refers to the rate at which your Lambda function is invoked. For all services except the stream-based services, the request rate is the rate at which the event sources generate the events. For stream-based services, AWS Lambda calculates the request rate as follow:

Copy
request rate = number of concurrent executions / function duration

For example, if there are five active shards on a stream (that is, you have five Lambda functions running in parallel) and your Lambda function takes about two seconds, the request rate is 2.5 requests/second.

Concurrent Execution Limit

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000. For instructions on how to increase that limit, see the following.

Any invocation that causes your function's concurrent execution to exceed the safety limit is throttled. In this case, the invocation doesn't execute your function. Each throttled invocation increases the Amazon CloudWatch Throttles metric for the function.

The throttled invocation is handled differently based on how your function is invoked:

  • Event sources that aren't stream-based – Some of these event sources invoke a Lambda function synchronously, and others invoke it asynchronously. Handling is different for each:

    • Synchronous invocation – If the function is invoked synchronously and is throttled, the invoking application receives a 429 error and the invoking application is responsible for retries. These event sources might have additional retries built into the integration. For example, CloudWatch Logs retries the failed batch up to five times with delays between retries. For a list of supported event sources and the invocation types that they use, see Supported Event Sources.

      If you invoke Lambda through Amazon API Gateway, make sure that you map Lambda response errors to API Gateway error codes. If you invoke the function directly, such as through the AWS SDKs using the RequestResponse invocation mode or through API Gateway, your client receives the 429 error and you can retry the invocation.

    • Asynchronous invocation – If your Lambda function is invoked asynchronously and is throttled, AWS Lambda automatically retries the throttled event for up to six hours, with delays between retries. Asynchronous events are queued before they are used to invoke the Lambda function.

  • Stream-based event sources – For stream-based event sources (Amazon Kinesis Streams and Amazon DynamoDB streams), AWS Lambda polls your stream and invokes your Lambda function. When your Lambda function is throttled, AWS Lambda attempts to process the throttled batch of records until the time the data expires. This time period can be up to seven days for Amazon Kinesis Streams. The throttled request is treated as blocking per shard, and Lambda doesn't read any new records from the shard until the throttled batch of records either expires or succeeds. If there is more than one shard in the stream, Lambda continues invoking on the nonthrottled shards until one gets through.

To request a limit increase for concurrent executions

  1. Open the AWS Support Center page, sign in if necessary, and then choose Create case.

  2. For Regarding, select Service Limit Increase.

  3. For Limit Type, choose Lambda, fill in the necessary fields in the form, and then choose the button at the bottom of the page for your preferred method of contact.

Note

AWS might automatically raise the concurrent execution limit for you so that your function can match the incoming event rate. An example is the case of when your function is triggered from an Amazon S3 bucket.

Scaling

AWS Lambda will dynamically scale capacity in response to increased traffic, subject to your account's Concurrent Execution Limit. To handle any burst in traffic, Lambda will immediately increase your concurrently executing functions by a predetermined amount, dependent on which region it's executed (see table below).

If the default Immediate Concurrency Increase value, as noted in the table below, is not sufficient to accommodate the traffic surge, Lambda will continue to increase the number of concurrent function executions by 500 per minute until your account safety limit has been reached or the number of concurrently executing functions is sufficient to successfully process the increased load.

Note

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 in the preceding section under To request a limit increase for concurrent executions.

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.

The table below outlines the immediate concurrency increase per region:

Region Immediate Concurrency Increase (function executions)
Asia Pacific (Tokyo) 1000
Asia Pacific (Seoul) 500
Asia Pacific (Mumbai) 500
Asia Pacific (Singapore) 500
Asia Pacific (Sydney) 500
Canada (Central) 500
EU (Frankfurt) 1000
EU (London) 500
EU (Ireland) 3000
AWS GovCloud (US) 500
US East (Ohio) 500
US West (N. California) 500
US West (Oregon) 3000
US East (N. Virginia) 3000
South America (São Paulo) 500

Suggested Reading

If you are new to AWS Lambda, we suggest you read through all of the topics in the How It Works section to familiarize yourself with Lambda. The next topic is Retries on Errors.

After you read all of the topics in the How it Works section, we recommend that you review Building Lambda Functions, try the Getting Started exercise, and then explore the Use Cases. Each use case provides step-by-step instructions for you to set up the end-to-end experience.