13

AmazonS3 & Rails

  • Upload
    martins

  • View
    5.397

  • Download
    2

Embed Size (px)

DESCRIPTION

A quick overview of AmazonS3 and how you can use it with rails

Citation preview

Page 1: AmazonS3 & Rails

AmazonS3

[email protected]

Page 2: AmazonS3 & Rails

What is it?

"Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers."

S3 = Simple Storage System

Page 3: AmazonS3 & Rails

Write, read, delete from 1B to 5GB

US & European storage

Authentication built-in

REST and SOAP interfaces

HTTP & BitTorrent protocols supported

Features

Page 4: AmazonS3 & Rails

Why use it?

Simple

Reliable 99.99%

Fast

Inexpensive

Scalable

CDN

Page 5: AmazonS3 & Rails

Basic Concepts

Bucket - the storage container (max 100 / dev) - must be unique across whole S3 service

Object - data + metadata (custom + some standard)

Key - unique identifier of an object in a bucket

Page 6: AmazonS3 & Rails

Using S3 with Rails

Signup at Amazon

Install AWS::S3 gem

Install attachment_fu plugin

Page 7: AmazonS3 & Rails

config/amazons3.ymldevelopment: bucket_name: reading_eggs_development access_key_id: my_access_key secret_access_key: my_secret_key

test: bucket_name: reading_eggs_test access_key_id: my_access_key secret_access_key: my_secret_key

prod: etc.....

Page 8: AmazonS3 & Rails

attachment_fu

before:

has_attachment :content_type => 'application/x-shockwave-flash', :storage => :file_system, :path_prefix => 'path/to/files/', :max_size => 10.megabytes

Page 9: AmazonS3 & Rails

attachment_fu

after:

has_attachment :content_type => 'application/x-shockwave-flash', :storage => :s3, :max_size => 10.megabytes

Page 10: AmazonS3 & Rails

attachment_fuaccess:

>> p = PartFile.find(:first)=> #<PartFile:0x23a0eb0 @attributes={"content_type"=>"application/x-shockwave-flash", "size"=>"4434939", "id"=>"315", "filename"=>"I_and_a.swf"}>> p.public_filename=> "http://s3.amazonaws.com/reading_eggs_dev/part_files/315/I_and_a.swf">> p.full_filename=> "part_files/315/I_and_a.swf">> p.bucket_name=> "reading_eggs_dev"

Page 11: AmazonS3 & Rails

PricingStorage$0.15 per GB-Month of storage used

Data Transfer$0.10 per GB - all data transfer in$0.18 per GB - first 10 TB / month data transfer out$0.16 per GB - next 40 TB / month data transfer out$0.13 per GB - data transfer out / month over 50 TB

Requests$0.01 per 1,000 PUT or LIST requests$0.01 per 10,000 GET and all other requests** No charge for delete requests

Page 12: AmazonS3 & Rails

Sample Costings

1 GB Storage = $0.15

5000 Users

200 MB / User / Month

0.2 GB * 5000 = 1000GB * $0.18 = $180

Request = 200/User/Month = 5000 * 200 = 1M get requests

1000000/10000 = 100 * $0.01 = $1

Data Storage Costs

Request Costs

Bandwidth Costs

1GB/M $0.15

US$181.15Total Cost

Page 13: AmazonS3 & Rails

ResourcesAmazon S3 : http://aws.amazon.com/s3

AWS::S3 gem : http://amazon.rubyforge.org/

s3fox : http://www.rjonna.com/ext/s3fox.php

s3 calc : http://calculator.s3.amazonaws.com