In today’s talk at the Ruby Users Group Berlin (RUG-B) I gave an introduction to Amazon SimpleDB focusing on how to connect it to Ruby on Rails via the ActiveResource framework and my AWS SDB Proxy Server Plugin.
The vision of eventually forming a truly scalable deployment architecture using Amazons EC2, S3, SQS and SimpleDB web services together, triggered a very vivid discussion.
Related Posts
February 8th, 2008
With SimpleDB, Amazon added the long-awaited database-like service to it’s web services portfolio. A database was the one thing missing for building a complete web hosting stack with Amazon’s services.
Using SimpleDB together with Ruby on Rails was the thing I immediately wanted to try. Some problems had to be dealt with first:
- Amazon does not provide any Ruby code for SimpleDB access
- SimpleDB has quite some limitations as detailed in a previous post
As Lars Schenk outlines on his Blog at least three different projects on RubyForge are addressing problem number one - only one of them has actual code, though. And that is aws-sdb by Tim Dysinger from Hawaii.
OK, using Tim’s aws-sdb gem, one can get access to SimpleDB using Ruby. But using SimpleDB as a drop-in-replacement for a relational database and connecting Rails’ ActiveRecord to it would require a fairly complex adapter - I am not sure, if this can be done at all, actually.
Looking at Rails, another interface comes to mind: ActiveResource. ActiveResource was written to connect model objects to RESTful web services as their datastore. That sounds like a fit. The APIs are different, but the functionality needed by ActiveResource can be provided by SimpleDB - it’s all just CRUD after all.
All that’s needed would be a adapter, a proxy, a proxy server? Yes, that’s right. As it turned out, it’s not too hard to write one, so here it is
Announcing AWS SDB Proxy
My AWS SDB Proxy is a HTTP proxy server bridging ActiveResource calls from Rails to Amazon’s SimpleDB Web Service allowing it to be used as a storage backend for Rails applications.
The proxy will listen for web service calls initiated by ActiveResource models and forward the requests to SimpleDB using the aws-sdb gem.
Install the AWS SDB Proxy Plugin from RubyForge as usual:
script/plugin install http://rug-b.rubyforge.org/svn/aws_sdb_proxy
Then follow the instructions provided in the README.
Features and Limitations
SimpleDB (and thus AWS SDB Proxy) do not use any pre-defined schema. Every record can potentially have different attributes. SimpleDB also has no data types associated with it’s attributes, all data will be stored as strings.
AWS SDB Proxy adds a special _resource attribute, allowing storage of multiple models within the same SimpleDB domain. Record ids are generated using a SHA512 hash function to make key collisions extremely unlikely.
If you like this plugin, please consider recommending me on Working with Rails. Thank you!
Related Posts
January 20th, 2008
Amazon Web Services yesterday announced its latest creation: SimpleDB. SimpleDB is a database-like storage service for structured data. It complements EC2 (the Elastic Compute Cloud) and S3 (the Simple Storage Service), potentially enabling web applications to run solely on Amazon’s service stack. SimpleDB has a couple of limitations compared to traditional relational databases, the most important being:
- No joined queries against multiple tables (or domains, as Amazon puts it)
- No transactions protecting multiple updates
- No instant data updates, i.e. you might get “old” data when you query data that was updated very recently
We will have to wait and see what kind of applications SimpleDB can support regardless of these limitations. On the plus side we get the usual benefits of Amazon’s Web Services:
- very good scalability
- high availability
- low cost / pay for usage
At GL Networks we will definately take a close look at SimpleDB, possibly bridging it to Rails via the ActiveResource framework.
SimpleDB will enter a closed beta program very soon.
Related Post: Amazon EC2 - The Future of (Rails-) Hosting?
December 15th, 2007
At yesterday’s meeting of the Berlin Ruby Users Group my fellow rubyist Adam Groves and I shared our thoughts on how to utilize Amazons EC2 (Elastic Compute Cloud) web service for hosting applications, especially with Ruby on Rails in mind. A major issue is the non persistence of local storage in the EC2 environment. We outlined several approaches on how to possibly solve this issue, minimizing potential data loss.
Download the complete set of slides here.

For further questions or comments, just drop me a line at martin.rehfeld@glnetworks.de.
April 6th, 2007