Service quotas and throttling
The limits on every AWS account, how to raise them, and how to handle API calls that get throttled.
Not in the course slides
The exam guide lists "service quotas and throttling" under Task 2.2 (resilient architectures). The slides only mention quotas in passing for single services, so this page is written from the AWS documentation.
What it is
Every AWS account has limits on how much of each service it can use. AWS calls them service quotas; older documents call them limits. There are two kinds:
- Resource quotas: how many of something an account can have. Example: 5 VPCs per Region.
- Rate quotas: how many requests per second an account can make to an API. Going over is called throttling.
Quotas exist to protect the account owner and everyone else. They stop a bug or a stolen key from launching a thousand servers on the account's bill, and they stop one customer from using up shared capacity.
Example
A company's Lambda functions handle orders. On Black Friday, traffic jumps tenfold and calls start failing with throttling errors. The code is fine: the account hit its Lambda concurrency quota. Raising the quota weeks before the sale would have avoided it.
How quotas work
- Per account, per Region. Unless a quota says otherwise, it applies separately in each Region. Raising the EC2 quota in
us-east-1does nothing ineu-west-1. - Default value. Each quota starts at a default AWS sets. New accounts can start lower than the published default; AWS raises them as the account is used.
- Adjustable or not. Many quotas can be raised on request. Some are fixed, usually because of how the service is built (for example, the maximum size of one S3 object).
- Global quotas apply to the whole account (for example, some IAM quotas). Changes to them are requested in US East (N. Virginia).
Example default quotas
| Quota | Default | Adjustable |
|---|---|---|
| VPCs per Region | 5 | Yes |
| Elastic IP addresses per Region | 5 | Yes |
| Lambda concurrent executions per Region | 1,000 | Yes |
| EC2 On-Demand instances | Counted in vCPUs per instance family group, not number of instances | Yes |
Check the Service Quotas console for the current values in a given account: they can differ from the defaults.
Viewing and raising quotas
The Service Quotas console (search for "Service Quotas") shows every quota for each service, its default, the value applied to the account, and the current usage for many of them.
To raise a quota:
- Open the service in Service Quotas and select the quota.
- Choose Request increase at account level and enter the new value.
- AWS reviews the request. Small increases are often approved automatically; larger ones can take a few days.
The CLI does the same. Each quota has a code; L-1216C47A is the EC2 On-Demand standard instances quota, in vCPUs. Find any other code with aws service-quotas list-service-quotas --service-code <service>.
aws service-quotas request-service-quota-increase \
--service-code ec2 --quota-code L-1216C47A --desired-value 64A few services aren't in Service Quotas yet. For those, open a case in the AWS Support Center.
Watching usage
- CloudWatch alarms: for quotas that publish usage, a CloudWatch alarm can be created from the quota's page in Service Quotas. It sends a warning when usage passes a percentage of the quota, for example 80%.
- Trusted Advisor also has service limit checks that flag quotas close to their limit (see Trusted Advisor).
Quota request templates for many accounts
With AWS Organizations (all features turned on), a quota request template lists up to 10 quota increases. Every new account created in the organisation automatically requests those increases. Updating the template doesn't change accounts that already exist.
Throttling
Throttling is a rate quota in action: API requests arrive faster than the service allows, so it rejects some of them.
Many AWS services use a token bucket to decide. The bucket holds a fixed number of tokens and refills at a steady rate. Each request takes one token. A quiet period fills the bucket, so a short burst can go through. When the bucket is empty, extra requests fail until it refills.
For example, EC2's read-only API calls have a bucket of 100 tokens that refills at 20 per second.
When a call is throttled, it fails with an error such as RequestLimitExceeded (EC2), ThrottlingException (many other services) or HTTP status 429 Too Many Requests. The request didn't happen, so it's safe to try again, but not straight away.
Retry with exponential backoff and jitter
The same API call is tried four times, left to right. Calls 1 to 3 fail with a throttling error. Between them the client waits about 1 second, then about 2, then about 4: each wait doubles. Call 4 succeeds. Each wait also includes a small random amount (jitter).
This is exponential backoff:
- Exponential: each wait is longer than the last, so a busy service gets breathing room.
- Jitter: a little randomness in each wait, so a thousand clients that failed at the same moment don't all retry at the same moment too.
The AWS SDKs and the AWS CLI already do this automatically. A custom HTTP client, or a tool that calls AWS without retrying, must add it.
Other ways to avoid throttling
- Ask for a higher rate quota, when one exists for the API.
- Spread requests out instead of sending them all at once, for example by putting work in an SQS queue and processing it at a steady pace.
- Cache results that are read often instead of asking the API every time.
- Batch operations, such as sending ten SQS messages in one call instead of ten calls.
Quotas and disaster recovery
The exam guide mentions "how to configure the service quotas for a workload in a standby environment". The point: quotas are per Region, so a standby Region doesn't inherit the quotas of the main Region.
If the main Region runs 200 EC2 instances and the disaster recovery plan is to launch the same in a second Region, that second Region needs a quota for 200 instances' worth of vCPUs before the disaster. Raising quotas during an outage is slow, and everyone else is doing the same. Request the increases in the standby Region in advance, and test them.
Exam tips
- "
ThrottlingException", "RequestLimitExceeded", "429", "intermittent errors under load" → retry with exponential backoff and jitter; consider a quota increase. - "Failover to the DR Region failed because instances couldn't launch" → the DR Region's service quotas weren't raised in advance.
- "Be notified before reaching a limit" → a CloudWatch alarm on the quota's usage (from Service Quotas), or Trusted Advisor.
- "New accounts in the organisation need higher limits automatically" → Service Quotas request templates with AWS Organizations.
- "Lambda functions are throttled during peaks" → the concurrency quota: raise it, or use reserved or provisioned concurrency (see Lambda concurrency).
Common traps
- "Quotas apply to the whole account across all Regions." Most quotas are per Region. Raise them in each Region in use.
- "Retry immediately in a tight loop." That makes throttling worse. Back off exponentially, with jitter.
- "Throttling means the service is down." The service is fine; requests are arriving faster than the quota allows.
- "Every quota can be raised." Some are fixed by design. Check the Adjustable column in Service Quotas.
Hands-on lab: inspect your quotas
Goal: find your account's quotas for EC2 and Lambda, and see how to set up a quota alarm.
Costs money
Viewing quotas is free. The optional CloudWatch alarm in the last step costs about $0.10 per month while it exists. Delete it at the end if you don't want to keep it.
Before you start: sign in to the console in US East (N. Virginia).
Open Service Quotas
Search for Service Quotas and open it. Choose AWS services, then search for Amazon Elastic Compute Cloud (Amazon EC2).
Find the On-Demand vCPU quota
Search the list for Running On-Demand Standard. The quota Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances is measured in vCPUs. Note its Applied account-level quota value. A t3.micro uses 2 vCPUs, so divide by 2 to see how many you could run.
Check Lambda concurrency
Go back to AWS services and open AWS Lambda. Find Concurrent executions. Compare the applied value with the default of 1,000. New accounts often show less.
Do the same from CloudShell
aws service-quotas list-service-quotas --service-code lambda \
--query "Quotas[?QuotaName=='Concurrent executions'].[QuotaName,Value,Adjustable]" \
--output table
aws service-quotas get-aws-default-service-quota \
--service-code ec2 --quota-code L-1216C47A \
--query "Quota.[QuotaName,Value]" --output tableThe first command shows your account's value; the second shows AWS's default for the EC2 On-Demand standard vCPU quota.
Optional: create a quota alarm
Back on the EC2 quota page from step 2, open the Amazon CloudWatch alarms tab and choose Create. Set the threshold to 80%, name it saa-lab-ec2-vcpu-80, and create it. In a real account you'd add an SNS email notification in CloudWatch.
Expected result: you know your account's EC2 vCPU and Lambda concurrency quotas, and where to raise them. Don't submit an increase request unless you need one.
Clean up:
Delete the alarm, if you created it
Open CloudWatch, choose Alarms, select saa-lab-ec2-vcpu-80 and choose Actions → Delete.