【问题标题】:batchWriteItem of dynamodb doesn't insert more than 25 itensdynamodb 的 batchWriteItem 插入的项不超过 25 个
【发布时间】:2021-01-23 02:10:27
【问题描述】:

我正在尝试使用 dynamodb 使用以下代码插入超过 25 个项目:

    const writeBatch = async () => {
    const items = await accounts(26)

      for (let item of items) {
        const itemArray = createArray(item)
        const params = createParam(itemArray)
        dynamodb.batchWriteItem(params, (error, data) => {
            if(error) console.log(error) 
            else console.log(data)
        })
      }
    }

    writeBatch()

对于此示例,我尝试插入 26 个项目,每次交互插入 25 个项目或更少。在第一个插入 25 中,在第二个插入 1 中。但是,当我在 dynambodb 中搜索时,最后一个不存在。

这是 for 循环的每个交互的打印: 25 itens 1 item

你能帮我解决这个问题吗

【问题讨论】:

    标签: amazon-dynamodb


    【解决方案1】:

    每个请求限制为 25 个项目,请求中的总项目大小限制为 16 MB。

    查看此处了解更多限制: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html

    如果您需要发送超过 25 个项目,您可以将它们拆分为单独的请求。

    【讨论】:

    • 是的,这就是我正在做的。在每次交互中,我都会做一个请求。问题是只完成了一个请求
    • 您的桌子上配置了多少作者?失败的物品尺寸是多少?
    • WCU 为 5kb/s,每一项包含 100 个字节。发生的情况是前 25 个插入是可以的,但下一个失败。 console.log 中没有消息错误。
    • AWS 指标仪表板上是否有任何可疑之处?
    • 我不认为。
    猜你喜欢
    • 1970-01-01
    • 2020-03-13
    • 2015-09-12
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多