Interview Prep/AWS/Route 53, CloudFront, API Gateway and Messaging

Kinesis consumers fall behind: `GetRecords.IteratorAgeMilliseconds` keeps rising, and producers see `ProvisionedThroughputExceededException`.

AdvancedTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer

Likely causes → Shards are saturated (1 MB/s or 1,000 records/s in, 2 MB/s out per shard), often because of a hot partition key. Too many consumers share the 5 reads/s per shard limit. Or the consumer is slow (a Lambda batch that keeps failing and retrying blocks the shard).

Diagnose →

aws kinesis describe-stream-summary --stream-name clicks --query 'StreamDescriptionSummary.[StreamModeDetails,OpenShardCount]'
aws cloudwatch get-metric-statistics --namespace AWS/Kinesis --metric-name WriteProvisionedThroughputExceeded \
  --dimensions Name=StreamName,Value=clicks --statistics Sum --period 60 \
  --start-time $(date -u -d '-1 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ)
aws lambda list-event-source-mappings --function-name clicks-consumer --query 'EventSourceMappings[].[BatchSize,ParallelizationFactor,BisectBatchOnFunctionError]'

Fix →

  1. Switch to on-demand mode, or reshard: aws kinesis update-shard-count --stream-name clicks --target-shard-count 8 --scaling-type UNIFORM_SCALING
  2. Use a high-cardinality partition key
  3. Use enhanced fan-out for multiple consumers
  4. On the Lambda mapping, set ParallelizationFactor, BisectBatchOnFunctionError, MaximumRetryAttempts and an on-failure destination

Prevent → Alarm on iterator age, and turn on shard-level metrics to spot hot shards.

aws All AWS questions Roadmap: AWS core services

More on Route 53, CloudFront, API Gateway and Messaging