【发布时间】:2019-01-25 02:23:27
【问题描述】:
Amazon DynamoDB 有两种读/写容量模式来处理对表的读取和写入: 一经请求 预配(默认,符合免费套餐条件)
这就是我创建预置表的方式
var AWS = require("aws-sdk");
AWS.config.update({
region: "us-west-2",
endpoint: "http://localhost:8000"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName : "Movies",
KeySchema: [
{ AttributeName: "year", KeyType: "HASH"}, //Partition key
{ AttributeName: "title", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
};
dynamodb.createTable(params, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}
});
如何设置表的按需容量?
【问题讨论】:
-
所以,我刚刚意识到您询问的是按需容量,而不是定价。你的意思是像我想象的那样定价吗?如果您实际上是指容量,答案是您没有设置它,因此您可以摆脱容量参数。这种情况下的容量基本上是无限的。这就是按需计费模式的美妙之处。
-
感谢您的回复)我认为您的回答是正确的。我现在无法检查。是的,我需要按需容量,我认为开启 PAY_PER_REQUEST 计费模式是一种解决方案,因为当您在控制台中开启按需容量时,您需要按请求付费
标签: node.js amazon-web-services amazon-dynamodb