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

查看:145
本文介绍了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

发电机的原子计数器似乎是我需要的合理选择,但我确实担心数据的一致性,尤其是整个分布式数据库(例如发电机)的数据一致性,并会影响数据的准确性。我希望API能在高峰时期发挥作用,但我想避免与条件更新相关的性能问题。我想我想知道DynamoDB使用Atomic Counters的可靠性,以及如何使用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如果并且只有IF,则现有值为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)

您引用的同一文档解释了Atomic Counter:

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天全站免登陆