选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

增加现有 DynamoDB 表的热吞吐量

聚焦模式
增加现有 DynamoDB 表的热吞吐量 - Amazon DynamoDB

检查 DynamoDB 表的当前热吞吐量值后,就可以通过以下步骤对其进行更新:

要使用 DynamoDB 控制台检查 DynamoDB 表的热吞吐量值,请执行以下操作:

  1. 登录 AWS Management Console,并打开 DynamoDB 控制台:https://console.aws.amazon.com/dynamodb/

  2. 在左侧导航窗格中,选择 表。

  3. 页面上,选择所需的表。

  4. 热吞吐量字段中,选择编辑

  5. 编辑热吞吐量页面上,选择增加热吞吐量

  6. 调整每秒读取单位每秒写入单位。这两个设置定义了表可以立即处理的吞吐量。

  7. 选择保存

  8. 请求处理完毕后,将在热吞吐量字段中更新每秒读取单位每秒写入单位

    注意

    更新热吞吐量值是一项异步任务。更新完成后,Status 将从 UPDATING 变为 ACTIVE

要使用 DynamoDB 控制台检查 DynamoDB 表的热吞吐量值,请执行以下操作:

  1. 登录 AWS Management Console,并打开 DynamoDB 控制台:https://console.aws.amazon.com/dynamodb/

  2. 在左侧导航窗格中,选择 表。

  3. 页面上,选择所需的表。

  4. 热吞吐量字段中,选择编辑

  5. 编辑热吞吐量页面上,选择增加热吞吐量

  6. 调整每秒读取单位每秒写入单位。这两个设置定义了表可以立即处理的吞吐量。

  7. 选择保存

  8. 请求处理完毕后,将在热吞吐量字段中更新每秒读取单位每秒写入单位

    注意

    更新热吞吐量值是一项异步任务。更新完成后,Status 将从 UPDATING 变为 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 设置将显示为 ReadUnitsPerSecondWriteUnitsPerSecond。当热吞吐量值正在更新时,Status 将为 UPDATING,当设置了新的热吞吐量值时,则为 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" } } }

以下 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 设置将显示为 ReadUnitsPerSecondWriteUnitsPerSecond。当热吞吐量值正在更新时,Status 将为 UPDATING,当设置了新的热吞吐量值时,则为 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; } }

以下 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; } }
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!"); }
隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。