0

We have a couple of smartphone apps that rely on Amazon SimpleDB and s3.

The architecture is typically very simple, the data not sensitive, there are not too many users per app, the apps query Amazon directly (as opposed to have our own server in the middle).

It has been all good so far and catered perfectly for our raisonable needs.

But now, I have this problem where one of our apps has to trigger an operation that is made of 2 SimpleDB puts.

The problem is that those “2 puts” have to be done in an atomic way, as a all-or-nothing block. Between the 2 puts, the database has no integrity and no-one should be able to read it in that bad state.

So, what I’m looking at is the simplest way to achieve this, I guess it will involve some sort of queues where operations are processed one by one, including just reads.

But to be honest, it’s not my area and I hope it doesn’t involve writing some very complex Webapp on a dedicated server.

Any workaround or pointers towards the sort of knowledge I obviously don’t have yet would be greatly appreciated.

Thanks!

MikaelW
  • 1,145
  • 4
  • 11
  • 29
  • Why not just set a special attribute with your first put and then you can aware if the item is in the bad state.? – Willy Feb 07 '13 at 16:55

1 Answers1

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'".
lreeder
  • 12,047
  • 2
  • 56
  • 65