DynamoDB on-demand table: 密集写入会影响阅读吗

DynamoDB on-demand table: does intensive writing affect reading

我开发了一个高负载应用程序,可以按需从 DynamoDB 中读取数据 table。假设它每秒持续执行大约 500 次读取。

有时我需要将大型数据集上传到数据库中(1 亿条记录)。我使用 python、spark 和 audienceproject/spark-dynamodb。我设置 throughput=40k 并使用 BatchWriteItem() 进行数据写入。

一开始,我观察到一些写入限制请求,写入容量只有 4k,但随后发生了升级,写入容量增加了。

问题:

  1. 在点播table的情况下,密集写作会影响阅读吗? reading/writing 的自动缩放是否独立工作?
  2. 短时间设置大吞吐量可以吗?据我所知,按需 tables 的成本是相同的。有哪些潜在问题?
  3. 我观察到一些请求受到限制,但最终,所有数据都已成功上传。这怎么解释呢?我建议我使用的客户端具有高级限速逻辑,我目前没有找到明确的答案。

一个问题里面有很多问题,你会得到一个高水平的答案。

DynamoDB 通过增加分区数量进行扩展。每个项目都存储在一个分区上。每个分区可以处理:

  • 最多 3000 个读取容量单位
  • 最多 1000 个写入容量单位
  • 最多 10 GB 的数据

一旦达到这些限制中的任何一个,分区就会一分为二并重新分配项目。这种情况会发生,直到有足够的可用容量来满足需求。您无法控制它是如何发生的,它是一种在后台执行此操作的托管服务。

分区数量只会增加。

根据这些信息,我们可以解决您的问题:

  1. Does intensive writing affects reading in the case of on-demand tables? Does autoscaling work independently for reading/writing?

    读和写的缩放机制相同activity,但缩放点不同,如前所述。在 on-demand table 中不涉及自动缩放,这仅适用于具有配置吞吐量的 table。您应该不会注意到此处对您的阅读有影响。

  2. Is it fine to set large throughput for a short period of time? As far as I see the cost is the same in the case of on-demand tables. What are the potential issues?

    我假设您设置了 spark 可以用作写入预算的吞吐量,它不会对 on-demand tables 产生太大影响。这是信息,它可以在内部使用来决定并行化的可能性。

  3. I observe some throttled requests but eventually, all the data is successfully uploaded. How can this be explained? I suggest that the client I use has advanced rate-limiting logic and I didn't manage to find a clear answer so far.

    如果客户端使用 BatchWriteItem,它将获得无法为每个请求写入的项目列表,并可以将它们重新排入队列。可能涉及指数退避,但这是一个实现细节。这不是魔法,您只需要跟踪您已经成功写入的项目并将您没有再次写入的项目排入队列,直到“to-write”队列为空。