Skip to content

DynamoDB — alert on throttled-request rate

DynamoDB starts throttling (hot key or low write capacity) — your app gets ProvisionedThroughputExceededException, but AWS alarms only fire on a 5-minute aggregate.

Recipe

bash
#!/usr/bin/env bash
# /etc/cron.d/ddb-throttle
# */1 * * * * root /opt/ddb-throttle.sh

TABLE=${DDB_TABLE}
REGION=${AWS_REGION:-us-east-1}
THRESH=${THRESH:-50}                # throttled events / 60 s

# Last 60 s of ThrottledRequests
COUNT=$(aws cloudwatch get-metric-statistics \
  --region "$REGION" \
  --namespace AWS/DynamoDB \
  --metric-name ThrottledRequests \
  --dimensions Name=TableName,Value="$TABLE" \
  --statistics Sum \
  --start-time "$(date -u -d '60 seconds ago' --iso-8601=seconds)" \
  --end-time   "$(date -u --iso-8601=seconds)" \
  --period 60 \
  --output text --query 'Datapoints[0].Sum')

COUNT=${COUNT:-0}
COUNT=${COUNT%.*}

if [ "$COUNT" -gt "$THRESH" ]; then
  curl -fsS "$HEARTBEAT_URL" --data "throttled=$COUNT,table=$TABLE"
  exit 2
fi
echo "OK ($COUNT throttled / 60s)"

Same thing in Enterno.io

Replace the CloudWatch alarm → SNS → email route with an Enterno heartbeat on a 1-minute schedule — 60-s reaction time instead of 5-min, history inline with the rest of your services.

Set up API monitor → ← All recipes

Related recipes