Saving Time and Money with Fake S3
Amazon S3 is a extremely powerful service at the core of Amazon Web Services. However, outside of a production environment, S3 can be challenging to work with. It involves passing keys around, provisioning user accounts, and a reliable network connection — not to mention it costs money.
At Spool, we built Fake S3 to make working with S3 in development and testing environments much easier. Our goal was to make a self contained executable that can mimic the majority of S3 Rest API with few external dependencies.
For development, each engineer runs her own instance of Fake S3 where she can put gigabytes of images and video to develop and test against, and her setup will work offline because it is all local. We also have a continuous integration setup that is running tests 24/7 (often against large video files). Fake S3 saves us $1000 a month in bandwidth alone for our tests. In both development and testing, the time saved in not waiting for assets to go back and forth into AWS, especially our larger media files, makes Fake S3 very useful.
We’re releasing Fake S3 as a gem on github. It’s an early release and we’ll keep improving it. If you have ideas or issues, please contribute to the project!
Installation
gem install fakes3
Running
fakes3 -r ~/fakes3_root -p 10001
Example Client Code
require 'rubygems'
require 'aws/s3'
include AWS::S3
AWS::S3::Base.establish_connection!(:access_key_id => "123",
:secret_access_key => "abc",
:server => "localhost",
:port => "10001")
Bucket.create('mystuff')
('a'..'z').each do |filename|
S3Object.store(filename, 'Hello World', 'mystuff')
end
bucket = Bucket.find('mystuff')
bucket.objects.each do |s3_obj|
puts "#{s3_obj.key}:#{s3_obj.value}"
end
Bucket.delete("mystuff",:force => true) # Delete your bucket and all its keys
In general clients can work if you can specify a host and port to connect them, as well as forcing path style requests (instead of subdomains.) Subdomain style S3 requests can work, but it involves adding your bucket names into /etc/hosts (ie. s3.localhost or mybucket.localhost) or using dnsmasq if you have a large number of buckets.
Simulating Network Conditions
Another useful feature is the support for simulating network conditions. You can run fakes3 with bandwidth limiting enabled like so:
fakes3 -r ~/fakes3_root -p 10001 --limit=50K
This will limit your GET request bandwidth to 50K/s per request instead of instantly off of your local machine. This is very convenient, for example, to simulate how mobile devices would behave in the real world.
Related Tools
Fake S3 is great for development and testing due to its simplicity, but is not intended to replace S3 in production. If you want to replace S3, there are other tools such as Ceph, ParkPlace (supports bitorrent), Boardwalk (S3 interface in front of MongoDB), and RiakCS that you can check out.
Pingback: Alternativa gratis ad Amazon S3
Love this idea. Instant savings for any startup testing their environment and want to practice CI.
Pingback: Fake S3 - Monday By Noon
Pingback: S3の開発・テスト環境を構築できる「Fake S3」 | P2P today ダブルスラッシュ
Does it simulate eventual consistency?
Why Ruby?
You can run fake-s3 from the command line and then use the library of your choice to connect to fake-s3 from your codebase. The sample ruby code just shows how to use it from a ruby script. But because you’re hitting the local port from your code, you can write your code from any language you like.
Great idea! It’s really necessary for testing and developement.
Awesome, i’ve got a couple of projects using S3 and having to hit amazon when running development/testing is just annoying and slightly terrifying (even though we’re hitting a dev bucket).
My wallet says thank you
Great stuff! I can totally understand and empathize with the overhead of cost associated with all the testing. Must give this a try to see if it helps our development.
Great work! Must give this a shot in our dev cycles.
How does this compare to fog.io (already has a test mode?)
As far as I know, fog.io uses a storage abstraction in front of various cloud services to make it easy to switch out say Rackspace Cloudfiles for Amazon S3. If you are using Fog in your ruby app, then putting it into test mode writes thes files to the local disk.
On the other hand, Fake S3 abstracts only Amazon S3 at the http layer so you can use low level S3 clients in any language to connect with it. Test mode in your app (whatever language) would mean connecting to Fake S3′s host and port rather than Amazon’s.
Pingback: Sysadmin Sunday 76 « Server Density Blog
Do you plan to implement POSTs?
Pingback: CloudSpring | Fake S3 – Save time, money, and develop offline
Pingback: Magazine | Digital Entrepreneur Tips