使用添加更新时,在竞赛条件可能的可能性中,DynamoDB原子计数器的一致性如何?
我希望为我的DynamoDB表使用简单的增量和减少。
更新看起来像:
aws dynamodb update-item \
--table-name table_name \
--key 'le key' \
--update-expression "ADD #C :delta" \
--expression-attribute-names '{"#C": "count"}' \
--expression-attribute-values '{":delta":{"N":"1"}}' \
--return-values UPDATED_NEW
为增量delta
为1,对于减少为-1。
在同时工作量和种族条件可能性中,如果我们有多次增量和减少在一起,这种更新将如何一致?
考虑到我们是不是“获取和设置”值,但直接传递要添加的delta
,我希望它会非常一致。这就是我将其添加为一个单独的问题的原因,并且不要将其视为这些人们经常建议有条件更新。
I wish to use a simple increment and decrement for my dynamoDB table.
The update looks something like:
aws dynamodb update-item \
--table-name table_name \
--key 'le key' \
--update-expression "ADD #C :delta" \
--expression-attribute-names '{"#C": "count"}' \
--expression-attribute-values '{":delta":{"N":"1"}}' \
--return-values UPDATED_NEW
For increment delta
would be 1, for decrement it would be -1.
In concurrent workloads and race condition possibilities, how consistent would such updates be if we have multiple increments and decrements occurring together?
I hope it would be pretty consistent, considering we are NOT "getting and setting" the values, but directly passing the delta
to be added. This is the reason I've added this as a separate question and don't consider it a duplicate of questions like these where people often suggest conditional updates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对单个项目的写入访问已序列化,因此您不必担心这一点 - 即使在重负载下也是如此。
要考虑的事情(担心)是当您的呼叫产生类似网络超时错误的内容时,您将不知道突变是否发生。你应该重做电话吗?你不会知道。
因此,通常更奇特的技术是处理这种情况并以某种方式进行呼叫。
Write access to an individual item is serialized, so you don’t have to worry about that - even under heavy load.
The thing to consider (worry about) is when your call produces something like a network timeout error you won’t know if the mutation happened or not. Should you redo the call? You won’t know.
So usually the fancier techniques are to handle this situation and make the call idempotent somehow.