MeWrite Docs

DynamoDB: ProvisionedThroughputExceededException

DynamoDBスループット超過エラーの解決方法

概要

DynamoDBテーブルのプロビジョニングされたスループットを超えた場合に発生するエラーです。

エラーメッセージ

ProvisionedThroughputExceededException: The level of configured provisioned throughput for the table was exceeded.

原因

  1. 読み書き容量超過: RCU/WCUが不足
  2. ホットキー: 特定のパーティションに集中
  3. バーストキャパシティ枯渇: 一時的なスパイク
  4. GSI制限: セカンダリインデックスの容量不足

解決策

1. オンデマンドモードに変更

1
2
3
aws dynamodb update-table \
  --table-name MyTable \
  --billing-mode PAY_PER_REQUEST

2. Auto Scaling設定

1
2
3
4
5
6
7
8
9
# SAM/CloudFormation
ScalableTarget:
  Type: AWS::ApplicationAutoScaling::ScalableTarget
  Properties:
    MaxCapacity: 100
    MinCapacity: 5
    ResourceId: !Sub table/${MyTable}
    ScalableDimension: dynamodb:table:ReadCapacityUnits
    ServiceNamespace: dynamodb

3. エクスポネンシャルバックオフ

1
2
3
4
5
6
7
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB.DocumentClient({
  maxRetries: 5,
  retryDelayOptions: {
    base: 200
  }
});

4. パーティションキー設計見直し

1
2
3
4
5
6
// 悪い例:日付のみ
// partitionKey: "2025-01-01"

// 良い例:ランダムサフィックス追加
const suffix = Math.floor(Math.random() * 10);
const pk = `2025-01-01#${suffix}`;

よくある間違い

  • ホットパーティションの放置
  • GSIのキャパシティ設定忘れ

AWS の他のエラー

最終更新: 2025-12-09