本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
建立暖輸送量較高的新 DynamoDB 資料表
建立 DynamoDB 資料表時,可依下列步驟調整暖輸送量設定。這些步驟同樣適用於建立全域資料表或次要索引。
若要透過主控台建立 DynamoDB 資料表並設定暖輸送量:
登入 AWS 管理主控台 ,並在 https://https://console.aws.amazon.com/dynamodb/
開啟 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 資料表。