创建具有更高热吞吐量的新 DynamoDB 表
在创建 DynamoDB 表时,您可以按照以下步骤调整热吞吐量值。这些步骤也适用于创建全局表或二级索引。
要通过控制台创建 DynamoDB 表并调整热吞吐量值,请执行以下操作:
登录 AWS 管理控制台,并打开 DynamoDB 控制台:https://console.aws.amazon.com/dynamodb/
。 -
选择创建表。
-
选择表名称、分区键和排序键(可选)。
-
对于表设置,选择自定义设置。
-
在热吞吐量字段中,选择增加热吞吐量。
-
调整每秒读取单位和每秒写入单位。这两个设置定义了表可以立即处理的最大吞吐量。
-
继续添加所有剩余的表详细信息,然后选择创建表。
以下 AWS CLI 示例显示了如何使用自定义的热吞吐量值创建 DynamoDB 表。
-
运行
create-table操作以创建以下 DynamoDB 表。aws dynamodb create-table \ --table-name GameScores \ --attribute-definitions AttributeName=UserId,AttributeType=S \ AttributeName=GameTitle,AttributeType=S \ AttributeName=TopScore,AttributeType=N \ --key-schema AttributeName=UserId,KeyType=HASH \ AttributeName=GameTitle,KeyType=RANGE \ --provisioned-throughput ReadCapacityUnits=20,WriteCapacityUnits=10 \ --global-secondary-indexes \ "[ { \"IndexName\": \"GameTitleIndex\", \"KeySchema\": [{\"AttributeName\":\"GameTitle\",\"KeyType\":\"HASH\"}, {\"AttributeName\":\"TopScore\",\"KeyType\":\"RANGE\"}], \"Projection\":{ \"ProjectionType\":\"INCLUDE\", \"NonKeyAttributes\":[\"UserId\"] }, \"ProvisionedThroughput\": { \"ReadCapacityUnits\": 50, \"WriteCapacityUnits\": 25 },\"WarmThroughput\": { \"ReadUnitsPerSecond\": 1987, \"WriteUnitsPerSecond\": 543 } } ]" \ --warm-throughput ReadUnitsPerSecond=12345,WriteUnitsPerSecond=4567 \ --region us-east-1 -
您将收到与以下内容类似的响应。您的
WarmThroughput设置将显示为ReadUnitsPerSecond和WriteUnitsPerSecond。当热吞吐量值正在更新时,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": "CREATING", "CreationDateTime": 1730241788.779, "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": "CREATING", "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": 1987, "WriteUnitsPerSecond": 543, "Status": "UPDATING" } } ], "DeletionProtectionEnabled": false, "WarmThroughput": { "ReadUnitsPerSecond": 12345, "WriteUnitsPerSecond": 4567, "Status": "UPDATING" } } }
以下 SDK 示例显示了如何通过自定义的热吞吐量值创建 DynamoDB 表。