0

我们有几个智能手机应用程序依赖于 Amazon SimpleDB 和 s3。

该架构通常非常简单,数据不敏感,每个应用程序没有太多用户,应用程序直接查询亚马逊(而不是在中间有我们自己的服务器)。

到目前为止一切都很好,完美地满足了我们合理的需求。

但是现在,我遇到了这个问题,我们的一个应用程序必须触发一个由 2 个 SimpleDB put 组成的操作。

问题是那些“2 put”必须以原子方式完成,作为一个全有或全无的块。在 2 次放置之间,数据库没有完整性,在这种不良状态下应该没有人能够读取它。

所以,我正在看的是实现这一目标的最简单方法,我想它将涉及某种队列,其中操作被一个一个地处理,包括读取。

但老实说,这不是我的领域,我希望它不会涉及在专用服务器上编写一些非常复杂的 Webapp。

任何解决方法或指向我显然还没有的知识的指针将不胜感激。

谢谢!

4

1 回答 1

1

Atomicity and transactions are some of the great features in relational databases you give up when using a NoSQL solution like SimpledDB. You may want to consider a cheap hosted MySQL database like the ones provided by Amazon RDS or one of the many other hosted DB vendors. However, if you want to continue with SimpleDB, you don't need queueing, but could roll your own transactions and do like Willy suggested:

  1. Add an attribute like "committed" to your saved items.
  2. Write a tool (or find a product) that can update all your previously saved items with a value of committed=1.
  3. Update your code so that the first step of your two-step operation saves the item with attribute committed=0, and the second step 'commits' the item by setting committed=1.
  4. Change all your queries to only pull committed items, something like this "select * from your_domain where {criteria1} and {criteria2} and {more criteria} and committed = '1'".
于 2013-05-05T17:31:23.900 回答