AWS

Throttling - Throttling Exception

Hitting a **Throttling** error means AWS is rate-limiting your requests—you're making too many API calls too quickly, exceeding service quotas, or exhausting burst capacity. This client-side error (4xx) happens when AWS enforces rate limits to protect service stability. Most common when DynamoDB, S3, or EC2 APIs are called too rapidly, but also appears when Service Quotas are exceeded, burst capacity is exhausted, or account-level throttling is active.

#Common Causes

  • Identity: IAM user/role making too many requests. Service Control Policy (SCP) enforces rate limits. Account-level throttling active.
  • Network: VPC endpoint throttling. Cross-region request limits. API Gateway rate limits.
  • Limits: DynamoDB read/write capacity exceeded. S3 request rate limit (3500 PUT/COPY/POST/DELETE per prefix per second). EC2 API rate limits. Service Quota (soft limit) exceeded. Burst capacity exhausted.

Solutions

  1. 1Step 1: Diagnose - Check which service is throttling: Review error message for service name. Check CloudWatch metrics: aws cloudwatch get-metric-statistics --namespace AWS/DynamoDB --metric-name ThrottledRequests.
  2. 2Step 2: Diagnose - Check Service Quotas: aws service-quotas get-service-quota --service-code dynamodb --quota-code L-xxxxx. List quotas: aws service-quotas list-service-quotas --service-code SERVICE_CODE.
  3. 3Step 3: Diagnose - Review request patterns: Check CloudWatch Logs for request frequency. Monitor API call rates. Identify burst patterns.
  4. 4Step 4: Fix - Implement exponential backoff with jitter: Retry with delays: 1s, 2s, 4s, 8s, 16s. Use AWS SDK automatic retries. Add jitter to prevent thundering herd.
  5. 5Step 5: Fix - Reduce request rate: Batch operations. Use pagination. Distribute requests over time. Request quota increase: aws service-quotas request-service-quota-increase --service-code SERVICE --quota-code QUOTA_CODE --desired-value NEW_VALUE.

</>Code Examples

Check Service Quotas and Throttling Metrics
1#!/bin/bash
2# Check DynamoDB throttling metrics
3echo "=== DynamoDB Throttling Metrics ==="
4aws cloudwatch get-metric-statistics \
5  --namespace AWS/DynamoDB \
6  --metric-name ThrottledRequests \
7  --dimensions Name=TableName,Value=MyTable \
8  --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \
9  --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
10  --period 300 \
11  --statistics Sum \
12  --output table
13
14# Check Service Quotas for DynamoDB
15echo "\n=== DynamoDB Service Quotas ==="
16aws service-quotas list-service-quotas \
17  --service-code dynamodb \
18  --query 'Quotas[?QuotaName==`Provisioned read capacity units`].[QuotaName,Value,Adjustable]' \
19  --output table
20
21# Get specific quota
22QUOTA_CODE="L-xxxxx"  # Replace with actual quota code
23echo "\n=== Specific Quota Details ==="
24aws service-quotas get-service-quota \
25  --service-code dynamodb \
26  --quota-code ${QUOTA_CODE} \
27  --query '[QuotaName,Value,Adjustable]' \
28  --output table
Request Service Quota Increase
1#!/bin/bash
2# Request quota increase for DynamoDB
3SERVICE_CODE="dynamodb"
4QUOTA_CODE="L-xxxxx"  # Replace with actual quota code
5CURRENT_VALUE=1000
6DESIRED_VALUE=5000
7
8echo "=== Requesting Quota Increase ==="
9echo "Service: ${SERVICE_CODE}"
10echo "Quota Code: ${QUOTA_CODE}"
11echo "Current Value: ${CURRENT_VALUE}"
12echo "Desired Value: ${DESIRED_VALUE}"
13
14aws service-quotas request-service-quota-increase \
15  --service-code ${SERVICE_CODE} \
16  --quota-code ${QUOTA_CODE} \
17  --desired-value ${DESIRED_VALUE}
18
19# Check request status
20echo "\n=== Quota Increase Requests ==="
21aws service-quotas list-requested-service-quota-change-history \
22  --service-code ${SERVICE_CODE} \
23  --query 'RequestedQuotas[*].[QuotaName,DesiredValue,Status]' \
24  --output table
Implement Exponential Backoff with Retry
1#!/bin/bash
2# Function to retry AWS CLI commands with exponential backoff
3retry_aws_command() {
4  local max_retries=5
5  local attempt=0
6  local delay=1
7  
8  while [ $attempt -lt ${max_retries} ]; do
9    if "$@"; then
10      return 0
11    fi
12    
13    local exit_code=$?
14    if [ $exit_code -ne 0 ]; then
15      # Check if error is throttling
16      if echo "$*" | grep -q "Throttling\|ThrottledException"; then
17        attempt=$((attempt + 1))
18        if [ $attempt -lt ${max_retries} ]; then
19          # Exponential backoff with jitter
20          delay=$((2 ** attempt + RANDOM % 1000 / 1000))
21          echo "Throttled, retrying in ${delay}s (attempt ${attempt}/${max_retries})..."
22          sleep ${delay}
23          continue
24        fi
25      fi
26      return $exit_code
27    fi
28  done
29  
30  return 1
31}
32
33# Example usage
34echo "=== Retrying DynamoDB GetItem with Backoff ==="
35retry_aws_command aws dynamodb get-item \
36  --table-name MyTable \
37  --key '{"id":{"S":"123"}}' \
38  --output json

Related Errors

Provider Information

This error code is specific to AWS services. For more information, refer to the official AWS documentation.

Throttling - Throttling Exception | AWS Error Reference | Error Code Reference