AWS Bedrock Cross-Region Inference & Token Bucket Throttling: Surviving ThrottlingException Storms at US Enterprise Scale
The 9:00 AM EST ThrottlingException Storm
If you run production AI agents on AWS Bedrock in us-east-1, you know the pain of 9:00 AM EST Monday traffic spikes:
- Your account's Tokens-Per-Minute (TPM) quota in
us-east-1saturates instantly. - Bedrock returns
botocore.exceptions.ClientError: ThrottlingException (Too many tokens per minute). - 20 worker pods blindly enter exponential retry loops at the same time—creating a retry thundering herd that keeps the quota pinned at 100% for 15 minutes straight!
Two-Part Fix: Cross-Region Inference + Distributed Token Bucket
- Switch to Cross-Region Inference Profiles (
us.*prefix): Instead of pinning requests strictly tous-east-1, invoke theus.profile ID (e.g.,us.anthropic.claude-3-5-sonnet-20241022-v2:0). AWS automatically routes excess burst traffic acrossus-east-1,us-east-2, andus-west-2within US data residency boundaries—doubling or tripling effective TPM burst capacity at zero extra cost. - Pre-Flight Redis Token Bucket:
Smooth out multi-worker bursts before calling
converse_stream()so pods never trigger retry storms.
text[20 Agent Worker Pods] │ ▼ [Redis Atomic Lua Token Bucket (checks TPM + RPM budget)] ├── Budget OK ──► Bedrock Cross-Region (`us.anthropic...`) └── Near Cap ──► Jittered sleep (200-800ms) or failover to vLLM VPC
Python Redis Token-Bucket Guard for Bedrock
pythonimport asyncio import random import time import boto3 bedrock = boto3.client("bedrock-runtime", region_name="us-east-1") # Atomic Redis Lua script enforcing Tokens-Per-Minute ceiling TOKEN_BUCKET_LUA = ''' local key = KEYS[1] local capacity = tonumber(ARGV[1]) local refill_per_sec = tonumber(ARGV[2]) local requested = tonumber(ARGV[3]) local now = tonumber(ARGV[4]) local data = redis.call("HMGET", key, "tokens", "ts") local tokens = tonumber(data[1]) or capacity local last_ts = tonumber(data[2]) or now tokens = math.min(capacity, tokens + (now - last_ts) * refill_per_sec) if tokens < requested then return 0 end redis.call("HMSET", key, "tokens", tokens - requested, "ts", now) redis.call("EXPIRE", key, 120) return 1 ''' async def invoke_bedrock_throttled(redis, estimated_tokens: int, messages: list[dict]): tpm_limit = 400_000 for attempt in range(5): allowed = await redis.eval( TOKEN_BUCKET_LUA, 1, "bedrock:tpm:us_sonnet", tpm_limit, tpm_limit / 60.0, estimated_tokens, time.time(), ) if allowed: return bedrock.converse( modelId="us.anthropic.claude-3-5-sonnet-20241022-v2:0", messages=messages, ) # Full jitter backoff before re-checking bucket await asyncio.sleep(random.uniform(0.25, 1.0) * (attempt + 1)) raise TimeoutError("Bedrock TPM budget exhausted after 5 backoff attempts")
Combining us.* cross-region inference profiles with an atomic Redis token bucket eliminates 99% of production ThrottlingException cascades.