既存の DynamoDB テーブルのウォームスループットを増やす - Amazon DynamoDB

既存の DynamoDB テーブルのウォームスループットを増やす

DynamoDB テーブルの現在のウォームスループット値を確認したら、次のステップで値を更新できます。

DynamoDB コンソールを使用して DynamoDB テーブルのウォームスループット値を確認するには:

  1. AWS Management Console にサインインして DynamoDB コンソール (https://console.aws.amazon.com/dynamodb/) を開きます。

  2. 左のナビゲーションペインで、[テーブル] を選択します。

  3. [テーブル] ページで、目的のテーブルを選択します。

  4. [ウォームスループット] フィールドで、[編集] を選択します。

  5. [ウォームスループットを編集] ページで、[ウォームスループットを増やす] を選択します。

  6. [1 秒あたりの読み取りユニット][1 秒あたりの書き込みユニット] を調整します。これら 2 つの設定は、テーブルが即座に処理できるスループットを定義します。

  7. [保存] を選択します。

  8. リクエストの処理が完了すると、[ウォームスループット] フィールドで [1 秒あたりの読み取りユニット][1 秒あたりの書き込みユニット] が更新されます。

    注記

    ウォームスループット値の更新は非同期タスクです。更新が完了すると、StatusUPDATING から ACTIVE に変わります。

次の AWS CLI の例は、DynamoDB テーブルのウォームスループット値を更新する方法を示しています。

  1. DynamoDB テーブルで update-table オペレーションを実行します。

    aws dynamodb update-table \ --table-name GameScores \ --warm-throughput ReadUnitsPerSecond=12345,WriteUnitsPerSecond=4567 \ --global-secondary-index-updates \ "[ { \"Update\": { \"IndexName\": \"GameTitleIndex\", \"WarmThroughput\": { \"ReadUnitsPerSecond\": 88, \"WriteUnitsPerSecond\": 77 } } } ]" \ --region us-east-1
  2. 次のようなレスポンスが表示されます。WarmThroughput 設定は、ReadUnitsPerSecond および WriteUnitsPerSecond として表示されます。ウォームスループット値が更新されている場合、StatusUPDATING になり、新しいウォームスループット値が設定されている場合は、ACTIVE になります。

    { "TableDescription": { "AttributeDefinitions": [ { "AttributeName": "GameTitle", "AttributeType": "S" }, { "AttributeName": "TopScore", "AttributeType": "N" }, { "AttributeName": "UserId", "AttributeType": "S" } ], "TableName": "GameScores", "KeySchema": [ { "AttributeName": "UserId", "KeyType": "HASH" }, { "AttributeName": "GameTitle", "KeyType": "RANGE" } ], "TableStatus": "ACTIVE", "CreationDateTime": 1730242189.965, "ProvisionedThroughput": { "NumberOfDecreasesToday": 0, "ReadCapacityUnits": 20, "WriteCapacityUnits": 10 }, "TableSizeBytes": 0, "ItemCount": 0, "TableArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores", "TableId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "GlobalSecondaryIndexes": [ { "IndexName": "GameTitleIndex", "KeySchema": [ { "AttributeName": "GameTitle", "KeyType": "HASH" }, { "AttributeName": "TopScore", "KeyType": "RANGE" } ], "Projection": { "ProjectionType": "INCLUDE", "NonKeyAttributes": [ "UserId" ] }, "IndexStatus": "ACTIVE", "ProvisionedThroughput": { "NumberOfDecreasesToday": 0, "ReadCapacityUnits": 50, "WriteCapacityUnits": 25 }, "IndexSizeBytes": 0, "ItemCount": 0, "IndexArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores/index/GameTitleIndex", "WarmThroughput": { "ReadUnitsPerSecond": 50, "WriteUnitsPerSecond": 25, "Status": "UPDATING" } } ], "DeletionProtectionEnabled": false, "WarmThroughput": { "ReadUnitsPerSecond": 12300, "WriteUnitsPerSecond": 4500, "Status": "UPDATING" } } }

次の SDK の例は、DynamoDB テーブルのウォームスループット値を更新する方法を示しています。

Java
import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndexUpdate; import software.amazon.awssdk.services.dynamodb.model.UpdateGlobalSecondaryIndexAction; import software.amazon.awssdk.services.dynamodb.model.UpdateTableRequest; import software.amazon.awssdk.services.dynamodb.model.WarmThroughput; ... public static WarmThroughput buildWarmThroughput(final Long readUnitsPerSecond, final Long writeUnitsPerSecond) { return WarmThroughput.builder() .readUnitsPerSecond(readUnitsPerSecond) .writeUnitsPerSecond(writeUnitsPerSecond) .build(); } public static void updateDynamoDBTable(DynamoDbClient ddb, String tableName, Long tableReadUnitsPerSecond, Long tableWriteUnitsPerSecond, String globalSecondaryIndexName, Long globalSecondaryIndexReadUnitsPerSecond, Long globalSecondaryIndexWriteUnitsPerSecond) { final WarmThroughput tableWarmThroughput = buildWarmThroughput(tableReadUnitsPerSecond, tableWriteUnitsPerSecond); final WarmThroughput gsiWarmThroughput = buildWarmThroughput(globalSecondaryIndexReadUnitsPerSecond, globalSecondaryIndexWriteUnitsPerSecond); final GlobalSecondaryIndexUpdate globalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate.builder() .update(UpdateGlobalSecondaryIndexAction.builder() .indexName(globalSecondaryIndexName) .warmThroughput(gsiWarmThroughput) .build() ).build(); final UpdateTableRequest request = UpdateTableRequest.builder() .tableName(tableName) .globalSecondaryIndexUpdates(globalSecondaryIndexUpdate) .warmThroughput(tableWarmThroughput) .build(); try { ddb.updateTable(request); } catch (DynamoDbException e) { System.err.println(e.getMessage()); System.exit(1); } System.out.println("Done!"); }
Python
from boto3 import resource from botocore.exceptions import ClientError def update_dynamodb_table_warm_throughput(table_name, table_read_units, table_write_units, gsi_name, gsi_read_units, gsi_write_units, region_name="us-east-1"): """ Updates the warm throughput of a DynamoDB table and a global secondary index. :param table_name: The name of the table to update. :param table_read_units: The new read units per second for the table's warm throughput. :param table_write_units: The new write units per second for the table's warm throughput. :param gsi_name: The name of the global secondary index to update. :param gsi_read_units: The new read units per second for the GSI's warm throughput. :param gsi_write_units: The new write units per second for the GSI's warm throughput. :param region_name: The AWS Region name to target. defaults to us-east-1 """ try: ddb = resource('dynamodb', region_name) # Update the table's warm throughput table_warm_throughput = { "ReadUnitsPerSecond": table_read_units, "WriteUnitsPerSecond": table_write_units } # Update the global secondary index's warm throughput gsi_warm_throughput = { "ReadUnitsPerSecond": gsi_read_units, "WriteUnitsPerSecond": gsi_write_units } # Construct the global secondary index update global_secondary_index_update = [ { "Update": { "IndexName": gsi_name, "WarmThroughput": gsi_warm_throughput } } ] # Construct the update table request update_table_request = { "TableName": table_name, "GlobalSecondaryIndexUpdates": global_secondary_index_update, "WarmThroughput": table_warm_throughput } # Update the table ddb.update_table(**update_table_request) print("Table updated successfully!") except ClientError as e: print(f"Error updating table: {e}") raise e
Javascript
import { DynamoDBClient, UpdateTableCommand } from "@aws-sdk/client-dynamodb"; async function updateDynamoDBTableWarmThroughput( tableName, tableReadUnits, tableWriteUnits, gsiName, gsiReadUnits, gsiWriteUnits, region = "us-east-1" ) { try { const ddbClient = new DynamoDBClient({ region: region }); // Construct the update table request const updateTableRequest = { TableName: tableName, GlobalSecondaryIndexUpdates: [ { Update: { IndexName: gsiName, WarmThroughput: { ReadUnitsPerSecond: gsiReadUnits, WriteUnitsPerSecond: gsiWriteUnits, }, }, }, ], WarmThroughput: { ReadUnitsPerSecond: tableReadUnits, WriteUnitsPerSecond: tableWriteUnits, }, }; const command = new UpdateTableCommand(updateTableRequest); const response = await ddbClient.send(command); console.log(`Table updated successfully! Response: ${response}`); } catch (error) { console.error(`Error updating table: ${error}`); throw error; } }