So, I have just launched my first production application with SimpleDB at http://snappress.com. I’ve mostly used Postgresql and MongoDB and I just wanted to share some of my experience. Similar to MongoDB, I love how easy and simple it is using SimpleDB. No schemas, migrations to worry about. But I find the ORM that comes with the aws-sdk for Ruby a little lacking in functionality. There are a lot of commands that I miss such as User.last that I use very often when using ActiveRecord/Mongoid.
Why I chose SimpleDB?
I didn’t jump into a lot of the technical aspect since this application isn’t meant to be a heavily trafficked or data filled. My main goal was to save on hosting costs. The obvious choice was to make full use of Heroku’s free tier! I could have easily gone with Postgresql since I didn’t really need the fast write speed from a no-sql database and honestly, I wouldn’t have mind a relational database. However, Heroku only offers 5mb free with postgresql and the next step up is USD15 for 15GB of database space (which I doubt I’ll need). As for MongoDB, I tend to stay away from it just in case I wanted to migrate everything over to a single instance VPS for both my application and database. So, I figured well, I’ll just give SimpleDB a shot. I’ve heard good things about it and the thought of not managing the database sounded ideal! Plus, it’s ridiculously cheap for my situation. (note: simpleDB does get expensive comparatively if your application is query heavy. But you’ll never have to worry about master-slave replication and high availability and even geographical region. It is however, advisable to keep your database as close to your application as possible though. Since Heroku uses Amazon’s EC2. Perfect!)
Using AWS-SDK (There’s a better gem for simpleDB in my opinion)
I did find a better gem to use when using SimpleDB with your rails application. It’s called simple_record by appoxy https://github.com/appoxy/simple_record. It’s much more comprehensive but I have no idea how it handles relation and joint calls like user.addresses.find(:id). Technically it’s not possible with SimpleDB since it’s just a simple key-value storage but it can be done in the application layer. It might be inefficient though. (that’s when relational database has it’s advantages!)
Anyway, just my 2 cents on SimpleDB. Read through carefully on its use cases before you choose to go with it! I ran into some issues with paypal. The project I was working on basically sells digital marketing tools. I’ve built the simple shopping cart application from scratch to manage the sale of these marketing tools. I’ve chosen PayPal Express checkout as my sole payment options for simplicity. Paypal returns a lot of information for each successful transaction and I would love to store them all. There was one particular ‘value’ that came in the form of an extremely long hash. It exceeded the size limit of 1024 characters imposed on SimpleDB. So, I had 2 options to get around it.
1. Store a pointer in SimpleDB that points to a file in S3
2. Split up the value and store them under 2 separate attributes.
I chose the second way, since making round trips from my application to the database then back to the application to S3 and back to application didn’t sound ideal in my application. (It exceeded the 1024 limit but not by much so I could still, in my opinion, efficiently store the value separately in SimpleDB). Since it’s a hash, I stored the keys of the hash under one attribute(or column) and the corresponding values of the hash under another attribute. Problem solved!