Agile Web Development

Build it. Launch it. Love it.


AwsSdbProxy is a HTTP proxy server bridging ActiveResource calls from Rails to Amazon’s SimpleDB Web Service allowing SimpleDB to be used as a storage backend for Rails applications.

The proxy will listen on a configurable port for web service calls initiated by ActiveResource models and forward the requests to SimpleDB using the aws-sdb Gem by Tim Dysinger.


Install the AwsSdbProxy plugin from Rubyforge[] as usual:

 script/plugin install

Setup and Usage

  1. Enter your Amazon Web Service credentials in the config/aws_sdb_proxy.yml config file (optionally configure server ports and a salt used to hash primary keys from the record content).
  2. Check your available SimpleDB domains with rake aws_sdb:list_domains and create a new one with rake aws_sdb:create_domain DOMAIN=my_new_domain if necessary.
  3. Start the AwsSdbProxy server with rake aws_sdb:start_proxy_in_foreground. (Once things are configured correctly you can also use rake aws_sdb:start_proxy to start the server as a background daemon.)
  4. Connect any ActiveResource model to your SimpleDB domain, e.g.
     class Post < ActiveResource::Base = "http://localhost:8888" # AwsSdbProxy host + port
       self.prefix = "/my_new_domain/"     # use your SimpleDB domain enclosed in /s
  5. Use your model just like any ActiveResource model in your application or try it in script/console, e.g.
     >> p = Post.create(:title => 'My first SimpleDB post')
     => #<Post:0x198ceec @prefix_options={}, @attributes={"updated_at"=>
     Sun Jan 20 00:42:43 UTC 2008, "title"=>"My first SimpleDB post",
     "id"=>1081408...01005954, "created_at"=>Sun Jan 20 00:42:43 UTC 2008}>
     >> p.body = 'Content is king'
     => "Content is king"
     => true
     >> Post.find(:first, :params => { :title => 'My first SimpleDB post' })
     => #<Post:0x18efef8 @prefix_options={}, @attributes={"updated_at"=>
     Sun Jan 20 00:45:28 UTC 2008, "title"=>"My first SimpleDB post",
     "body"=>"Content is king", "id"=>1081408...01005954, "created_at"=>
     Sun Jan 20 00:42:43 UTC 2008}>


As you may have noticed SimpleDB (and thus AwsSdbProxy) 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.

AwsSdbProxy adds a special _resource attribute to distinguish diffent models within the same SimpleDB domain and also adds and handles the usual created_at and updated_at attributes. Record ids are generated using a SHA512 hash function to make key collisions extremely unlikely.

Copyright © 2008, released under the MIT license


License Rails' (MIT)
Rating (3 votes)
Owner Martin Rehfeld
Created 20 January 2008


  • dash
    18 September 2008


    I am getting the following error when I try to execute "rake --trace aws_sdb:create_domain DOMAIN=my_test_domain"

    ** Invoke aws_sdb:create_domain (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Execute aws_sdb:create_domain
    rake aborted!
    wrong number of arguments (3 for 1)
    /Users/dharmesh/NetBeansProjects/FooPetsTranslations/vendor/plugins/aws_sdb_proxy/lib/aws_sdb_proxy/server.rb:27:in `initialize'
    /Users/dharmesh/NetBeansProjects/FooPetsTranslations/vendor/plugins/aws_sdb_proxy/lib/aws_sdb_proxy/server.rb:27:in `new'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
    /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
    /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
    /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
    /usr/bin/rake:19:in `load'

    Please advise. Thanks in advance!

  • Avatar
    12 December 2008

    I can't seem to load more than 100 rows using this, has anyone else experienced this?

  • Avatar
    21 July 2009

    Hello, I really like the proxy server and it's providing me with the scale I need for my site. However how do I use the query function with an "order by" clause?

    Many thanks, Alex

Add a comment