AWS DynamoDB 是否会为因条件表达式而失败的 Put Item(写入)操作消耗吞吐量或费用?

Does AWS DynamoDB consume throuput or charges for a Put Item (write) operation that failed due to a conditional expression?

我无法为此找到直接的答案。

考虑使用 DynamoDB Put Item request with a condition expression

说条件失败,DynamoDB returns 出错。换句话说:Put Item 请求没有成功,没有有效写入。

此请求是否仍消耗写入吞吐量容量(或者如果 table 处于按需模式则收费)?

如果条件表达式在条件写入期间计算为 false,DynamoDB 仍会消耗来自 table:

的写入容量
  • 如果项目当前不存在于table,DynamoDB 消耗一个写入容量单位。

  • 如果项目确实存在,消耗的写入容量单位数取决于项目的大小。例如,1 KB 项目的条件写入失败将消耗一个写入容量单位。如果项目是该大小的两倍,则失败的条件写入将消耗两个写入容量单位。

条件写入失败 returns ConditionalCheckFailedException。发生这种情况时,您不会在响应中收到任何有关消耗的写入容量的信息。但是,您可以在 Amazon CloudWatch 中查看 table 的 ConsumedWriteCapacityUnits 指标。

可以在 DynamoDB 文档文章 Working with Items and Attributes 中找到此信息和更多信息。