Amazon DynamoDB 条件写入和原子计数器 [英] Amazon DynamoDB Conditional Writes and Atomic Counters

查看:17
本文介绍了Amazon DynamoDB 条件写入和原子计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理的应用程序要求我在 20 到 30 分钟的时间内多次增加属于 DynamoDB 中某个项目的属性.我一直在做一些关于 DynamoDB 的额外阅读条件写入和原子计数器

The application im working on currently requires me to increment an attribute belonging to an item in DynamoDB many times in a 20 to 30 minute period. I've been doing some additional reading about DynamoDBs conditional writes and atomic counters

dynamo 中的原子计数器似乎是我需要的一个合乎逻辑的选择,但我确实担心数据的一致性,尤其是跨分布式数据库(如 dynamo)和数据准确性问题.我预计 API 会在高峰时间受到重创,但我想避免与条件更新相关的性能问题.我想我想知道原子计数器在 DynamoDB 中的可靠性以及如何使用 dynamo 正确实现它们.也欢迎其他建议.

Atomic Counters in dynamo seems like a logical choice for what I need but I do worry about the consistency of the data especially across a distributed database like dynamo and issues accuracy of my data. I'm expecting the API to get hammered at peak times but I want to avoid the performance issues related to conditional updates. I guess I want to know how reliable the Atomic Counters are with DynamoDB and how to implement them correctly using dynamo. Other suggestions are also welcome.

推荐答案

是的,这些是您想要使用的功能.通过 Dynamo API 使用它们是一种方式.

Yes, these are the features you would want to use. Using them via Dynamo API is the way.

现在,在这两个功能之间,如果您需要修改的计数器对业务非常重要,请使用条件写入(您告诉 API 更新值以说 x + 10如果且仅当"现有值为 x)

Now, between these two features, use conditional write if the counter you need to modify if very critical to business (you tell the API to update the value to say x + 10 "IF and only IF" the existing value is x)

你提到的同一份文件解释了原子计数器:

The same document which you referred explains Atomic Counter:

"如果您怀疑之前的请求可能会重试此操作没有成功.但是,您可能会冒险应用相同的更新两次.这对于网站计数器来说可能是可以接受的,因为您可以容忍稍微多计或少计访客.但是,在银行应用程序中,使用有条件的更新."

"You might retry this operation if you suspect that a previous request was unsuccessful. However, you would risk applying the same update twice. This might be acceptable for a web site counter, because you can tolerate with slightly over- or under-counting the visitors. However, in a banking application, it would be safer to use a conditional update."

因此,如果是关键业务操作,则使用条件写入,否则使用原子计数器.希望它澄清.

So if it is business critical operation use Conditional write, otherwise atomic counter. Hope it clarifies.

这篇关于Amazon DynamoDB 条件写入和原子计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆