Lesson 1 of 3 AWS Lambda and Amazon SQS Operations

Managing Lambda Concurrency and Throttling

This lesson explains how concurrency limits, reserved concurrency and provisioned concurrency control Lambda scaling, a frequent source of throttling questions.

Learning outcomes

After completing this lesson, you will be able to:

  • Calculate concurrency.
  • Use reserved and provisioned concurrency.
  • Stop one function starving others.

How Lambda scales

Concurrency is the number of requests a function is handling at the same time; approximately invocations per second multiplied by average duration in seconds. Each account has a Regional concurrency quota, 1,000 by default and raisable, shared by all functions. Each function can scale up by 1,000 additional concurrent executions every 10 seconds until the quota is reached. When no concurrency is available, synchronous callers receive a 429 TooManyRequestsException (the Throttles metric), while asynchronous invocations are queued and retried.

1,000

Additional concurrent executions per function every 10 seconds

Fill in the value

Estimating concurrency

Exam skills 2.1.1

Estimate the concurrency a workload needs.

Log in to try this activity Interactive activities are free with an account.

Reserved and provisioned concurrency

Reserved concurrency sets aside part of the account's concurrency for one function and also caps that function at the reserved value. It protects critical functions from being starved by others and protects downstream systems, such as a database that can handle only 50 connections, from too many parallel executions. Setting it to 0 stops a function from running at all, which is a quick way to halt a runaway function. Reserved concurrency has no extra charge.

Provisioned concurrency keeps a number of execution environments initialised and ready on a published version or alias, removing cold start latency for that many concurrent requests; it is charged while configured and can be scheduled or scaled with Application Auto Scaling on utilisation. SnapStart (Java, Python and .NET) reduces start-up time differently, by restoring from a cached snapshot. The following table compares the settings.

SettingPurposeCost
Account concurrency quotaRegional limit shared by all functionsNone; raise with Service Quotas
Reserved concurrencyGuarantee and cap concurrency for one functionNo charge
Provisioned concurrencyPre-initialised environments, no cold startsCharged per configured environment
SnapStartFaster cold starts from snapshotsSnapshot caching and restore charges for some runtimes

The following diagram shows reserved concurrency dividing the account's concurrency.

Reserved and provisioned concurrency. Reserved concurrency sets aside part of the account's concurrency for a function and caps it there, protecting a database that can take only 50 connections; setting it to 0 stops a runaway function. Provisioned concurrency keeps environments initialised on a version or alias to remove cold starts.
The function names and values are illustrative.
Sort into groups

Which concurrency setting?

Exam skills 2.1.1 · 1.3.1

Choose the Lambda setting for each requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

One function starving others

A nightly reprocessing function scales to 950 concurrent executions and the customer-facing API functions in the same account start returning 429 errors. The account quota is 1,000. The operator sets reserved concurrency of 200 on the reprocessing function, which caps it, and reserved concurrency of 300 on the API function, which guarantees it capacity. They also request a quota increase and add an alarm on the account-level ConcurrentExecutions metric at 80% of the quota.

Check yourself

Which setting removes cold starts?

Show answer

Provisioned concurrency, which is charged while it is configured.

Exam Tips

Remember for the exam

  • Default Regional concurrency quota is 1,000, shared by all functions.
  • Reserved concurrency guarantees and caps a function; 0 stops it.
  • Provisioned concurrency removes cold starts and is charged while configured.
  • Synchronous throttles return 429; asynchronous events are retried.