Tweetegy On the edge of chaos with Ruby, Rails, JavaScript and AngularJS.

| About | Search | Archive | Github | RSS |

Compare Amazon S3 to EBS data read performance

If you are going to store data in the cloud that requires frequent reading (such as a database file) then you should consider using EBS. Just to reinforce that statement, lets compare the read performance between S3 and EBS.

I used the following straightforward Ruby program to perform the test. To try this yourself, just fill in the access keys and configure the local folder, bucket and files with your own setup:

 1 require 'benchmark'
 2 require 'rubygems'
 3 require 'aws/s3'
 5 AWS::S3::Base.establish_connection!(:access_key_id => YOUR_ACCESS_KEY_ID, :secret_access_key => YOUR_SECRET_ACCESS_KEY)
 7 do |x|
 8"disk (1 read): ") { 1.times {'/your-ebs-mount/1.xml')}}
 9"s3 (1 read): ") { 1.times { AWS::S3::S3Object.value '1.xml', "your-s3-bucket" } }
10"disk (1000 read): ") { 1000.times {'/your-ebs-mount/1.xml')}}
11"s3 (1000 read): ") { 1000.times { AWS::S3::S3Object.value '1.xml', "your-s3-bucket" } }
12 end

This code was executed in a small EC2 instance on the cloud and the output is shown below. As you can see, disk read is not only faster (as expected) but very much faster at about 2000x!!

Of course, S3 is best used for backing up files, packing up a EC2 image and as a source to Amazon’s CDN via CloudFront, which explains the massive speed difference here. The purpose of this test was to simply make a side-by-side comparison of reading the same file from S3 compared with EBS.

user     system      total        real
disk (1 read):   0.000000   0.000000   0.000000 (  0.000126)
s3 (1 read):   0.010000   0.000000   0.010000 (  0.308293)
disk (1000 read):   0.030000   0.020000   0.050000 (  0.116382)
s3 (1000 read):   0.710000   0.100000   0.810000 (259.014794)