本文介绍了如何在 DynamoDB 查询中计算消耗的读取容量单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在亚马逊上看过这个页面,知道 1 个 RCU 是一个 4KB 的项目.

I've seen the page on amazon and understand that 1 RCU is a 4KB item.

如果我有一个包含 50 个项目的表,我读到扫描将读取全部 50 个项目并使用 50 个 RCU.但是假设我做了一个查询,我的表是 10 x 5,它还会使用 50 RCU 吗?

If I have a table with 50 items, I've read that a scan will read the full 50 items and use 50 RCU. But lets say I did a query, my table is 10 by 5, will it still use 50 RCU?

推荐答案

仅当 50 个项目的总大小等于 200KB(对于强一致性读取,或 400KB)时,扫描包含 50 个项目的表将消耗 50 RCU最终一致的读取).大多数项目都没有那么大,所以 50 个项目通常只需要大约 10KB 来存储,这意味着对 50 个项目的表进行完整扫描,最终一致性,只需要大约 3 个 RCU.

Scanning a table that contains 50 items will consume 50 RCU only if the total size of the 50 items combined equal 200KB (for a strongly consistent read, or 400KB for an eventual consistent read). Most items are not that big, so a 50 items typically only require about 10KB to store meaning a full scan for a table of 50 items, with eventual consistency, would only cost about 3 RCU.

消耗的读取容量单位 (RCU) 取决于多种因素:

The consumed Read Capacity Units (RCU) depends on multiple factors:

如果使用 GetItem 操作读取一个项目,那么消耗的容量将根据项目的大小以 4KB 的增量计费(即,一个 200B 的项目和一个 3KB 的项目将分别消耗1RCU,而一个 5KB 的项目会消耗 2 RCU)

If an item is read using a GetItem operation than the consumed capacity is billed in increments of 4KB, based on the size of the item (ie. a 200B item and a 3KB item would each consume 1RCU, while a 5KB item would consume 2 RCU)

如果您使用查询扫描操作读取多个项目,则消耗的容量取决于正在访问的项目的累积大小(即使在使用过滤器时从查询或扫描中过滤出的项目,您也会被计费).因此,如果您的查询或扫描访问 10 个项目,每个项目的大小约为 200 字节,那么它将仅消耗 1 个 RCU.如果读取 10 个项目,但每个项目的大小约为 5KB,则总消耗容量将为 13 个 RCU(50KB/4KB = 12.5,四舍五入为 13)

If you read multiple items using a Query or Scan operation, then the capacity consumed depends on the cumulative size of items being accessed (you get billed even for items filtered out of a query or scan when using filters). So, if your query or scan accesses 10 items, that are approximately 200 bytes each in size, then it will consume only 1 RCU. If you read 10 items but each item is about 5KB in size, then the total consumed capacity will be 13 RCU (50KB / 4KB = 12.5, rounded up, is 13)

此外,如果您执行最终一致的读取,那么您可以将每个容量单位的大小增加一倍.所以读取10个5KB的项目只需要7个RCU.

What's more, if you perform an eventual consistent read, then you can double the size per capacity unit. So it would only cost 7 RCU to read the 10 5KB items.

您可以在此处阅读更多关于吞吐能力的信息.

需要注意的几点:

  • 单个项目可能高达 400KB,因此读取一个项目可能会消耗多达 100 个 RCU.
  • 在计算商品大小时,属性名称也会计入商品大小,而不仅仅是它们的值!

这篇关于如何在 DynamoDB 查询中计算消耗的读取容量单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 06:50