Interview Prep/Python for DevOps/boto3 & AWS automation

How do botocore retry modes work, and how do you configure them?

AdvancedConceptboto3 & AWS automation
Answer

botocore retries transient errors (throttling, 5xx, connection errors) automatically.

  • legacy: the long-standing boto3 default if you configure nothing; 5 total attempts for most services.
  • standard: 3 attempts by default, consistent jittered exponential backoff, broader set of retryable errors. The mode AWS recommends.
  • adaptive: standard plus client-side rate limiting that slows down when throttled; good for bulk scanners.
from botocore.config import Config
cfg = Config(retries={"max_attempts": 10, "mode": "adaptive"},
             connect_timeout=5, read_timeout=30, max_pool_connections=50)
ec2 = boto3.client("ec2", config=cfg)

Can also be set via AWS_RETRY_MODE and AWS_MAX_ATTEMPTS.

All Python for DevOps questions Roadmap: Python for automation

More on boto3 & AWS automation