Interview Prep/AWS/RDS, Aurora and DynamoDB

RDS `CPUUtilization` is pinned at 100% and the API is timing out.

AdvancedTroubleshootingRDS, Aurora and DynamoDB
Answer

Likely causes → One or a few bad queries: a missing index after a deploy, a plan regression from stale statistics, a runaway report, or lock contention that shows up as CPU spin.

Diagnose →

aws pi get-resource-metrics --service-type RDS --identifier db-ABCDEFGH123 \
  --metric-queries '[{"Metric":"db.load.avg","GroupBy":{"Group":"db.sql_tokenized","Limit":5}}]' \
  --start-time $(date -u -d '-1 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ) --period-in-seconds 300
psql -c "select pid, now()-query_start dur, state, left(query,80) from pg_stat_activity where state<>'idle' order by dur desc limit 10;"

Fix →

  1. Kill the runaway query: select pg_cancel_backend(<pid>);
  2. Add the missing index (CREATE INDEX CONCURRENTLY), and run ANALYZE on the affected tables
  3. Scale up only as a stopgap

Prevent → Keep Performance Insights and pg_stat_statements on, review query plans in CI for hot paths, and alarm on DB load above the vCPU count.

aws All AWS questions Roadmap: AWS core services

More on RDS, Aurora and DynamoDB