与S3锁定 [英] Locking with S3

查看:159
本文介绍了与S3锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是配合使用的推荐方法来实现一个简单的锁定机制,S3?

What's the recommended way to implement a simple locking mechanism to be used in conjunction with S3?

是我想要做的例子:

  • 按对象ID获取锁
  • 从S3阅读对象
  • 修改数据
  • 写对象为S3
  • 在释放锁

在理想情况下寻找一个基于云的锁定机制。我可以使用memcached的地方,但我必须处理标定。我没有看到实现轻量级锁定任何AWS API的一个明显的方式,但它似乎是一个常见的​​问题。

Ideally looking for a cloud based locking mechanism. I could use memcached locally, but then I have to deal with scaling that. I don't see an obvious way to implement lightweight locking with any AWS APIs, but it seems like a common problem.

我不知道你是否可以使用SimpleDB的做一个原子获取锁定操作。有没有人试过?

I wonder if you could use SimpleDB to do an atomic acquire lock operation. Has anyone tried that?

推荐答案

好吧,我花了一些时间今天上午博托玩,我觉得我有一个解决方案,工程使用的SimpleDB。您需要最新的博托释放,使有条件的看跌期权和一致的读取支持。

Ok, I spent some time this morning playing with boto and I think I have a solution that works using SimpleDB. You need the latest boto release so that conditional puts and consistent reads are supported.

例如code在这里: http://pastebin.com/3XzhPqfY

Example code here: http://pastebin.com/3XzhPqfY

请发表意见/建议。我相信这code应该是相当安全的 - 我在测试的main()有10个线程试图就

Please post comments/suggestions. I believe this code should be fairly safe -- my test in main() tries it with 10 threads.

有一件事情我还没有解决的是,S3读取并不一致(右?),所以理论上一个线程可能会在S3价值的旧副本操作。它看起来像有可能是一种解决方法是如下描述:

One thing I haven't addressed is that S3 reads are not consistent (right?), so in theory a thread may be operating on an old copy of the S3 value. It looks like there may be a workaround for that as described here:

<一个href="http://www.shlomoswidler.com/2009/12/read-after-write-consistency-in-amazon.html">http://www.shlomoswidler.com/2009/12/read-after-write-consistency-in-amazon.html

这篇关于与S3锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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