本文介绍了如何在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:


  • 操作(即获取与查询/扫描)

  • 项目的大小

  • 是否读取的内容为

  • the operation (ie. Get vs. Query/Scan)
  • the size of the items
  • whether the read is strongly consistent or eventually consistent

如果使用 GetItem 操作读取某项,则根据项的大小(即200B项),将以4KB的增量计费消耗的容量而3KB的项目每个将消耗1个RCU,而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)

如果您使用 Query Scan 操作,那么消耗的容量取决于访问的项目的累积大小(即使使用过滤器,即使从查询或扫描中过滤掉的项目,您也要付费)。因此,如果您的查询或扫描访问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)

此外,如果执行最终的一致读取,则可以将每个容量单位的大小加倍。因此,只需花费7个RCU即可读取10个5KB的项目。

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