35
Use Somebody Else's Infrastructure: Utilizing Amazon S3 and EC2 Jonathan Weiss Peritor Wissensmanagement GmbH, www.peritor.com Web 2.0 Expo Berlin, 2007

Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

Embed Size (px)

DESCRIPTION

Scaling a Web Application is a very hard problem, especially for small project and teams who do not have sufficient manpower, money, and time to solve this problem. Luckily Amazon already had to solve this problem in their datacenters and offers their services to other developers. This talk will introduce the two most important Amazon Web Services, the Elastic Compute Cloud (EC2) and the Simple Storage Service (S3), and will present different ways to leverage them in your own web application. Ruby on Rails will be used for the examples but they will apply to any web framework. Several use-cases will be covered that show how S3 and EC2 can be used to move load from your servers to Amazon's or even to completely host your application at Amazon.

Citation preview

Page 1: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

Use Somebody Else's Infrastructure:

Utilizing Amazon S3 and EC2

Jonathan Weiss

Peritor Wissensmanagement GmbH, www.peritor.comWeb 2.0 Expo Berlin, 2007

Page 2: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

2

Peritor

• Consultancy from Berlin, Germany

• Specialized on Architecture, Scaling andRuby on Rails

• A lot of our clients use Amazon WebServices

Page 3: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

3

www.peritormail.com

We run a Webmail portal on top of Amazon Web Services

Page 4: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

4

Starting Point

One machine:

• Apache

• Ruby on Rails / PHP / Perl / Java / …

• MySQL

Page 5: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

5

Worst Case Populariy

Page 6: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

6

A Difficult Path

Page 7: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

7

Problem: Backup

• High availability

• Redundancy

• Very big data sets

Page 8: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

8

Problem: File System

• Important files have to be accessed by many servers

• NFS / Samba not practical

Page 9: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

9

Problem: Messaging

• Many servers on different locations have to communicate

• Creating a reliable and scalable message queue is really hard

Page 10: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

10

Problem: Spontaneous Traffic

Page 11: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

11

Problem: Load Fluctuation

Page 12: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

12

Don‘t reinvent the wheel!

Page 13: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

13

Amazon Web Services

Simple Storage Service - S3

Redundant Data Store

$0,15 per GB data permonth

$0,10 - $0,20 per GBtraffic

Virtual server per hour

$0,10 per CPU hour

$0,10 - $0,20 per GBtraffic

Elastic Compute Cloud - EC2

…….

E-Commerce..

Reliable Message System

$0,10 per 1,000 messages

$0,10 - $0,18 per GBtraffic

Simple Queue Service - SQS

Page 14: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

14

S3 - Simple Storage Service

• Redundant storage - as much as you like

• max. 5 GB per object

• Organized in „Buckets“

• Web Service API for uploads

• Downloads via

• Web Service

• HTTP / HTTPS

• BitTorrent

Page 15: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

15

S3 - Buckets

• Unique over all S3

• Contains manykey-value-metadata tupel

• Cannot contain other buckets!

• Key can contain „/“

MyBucket_name

S3

foto_5.jpg

backups/januar.zip

fotos/2007/001.png

www.peritor.com

site/screen.css

site/script.js

FreeBSD-6.2.iso

Page 16: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

16

S3 with AWS::S3Upload

Download

Page 17: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

17

EC2 - Elastic Compute Cloud

• Based on XEN virtualization

• On demand virtual servers - controlled with Web Service API

• Use your favorite Linux distro (Linux 2.6.16),Amazon Machine Images (AMI) are stored on S3

• ACLs for hosts/ports access control

Page 18: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

18

EC2 ToolsList availabe images

Start a new instance

Login with SSH

Shutdown instance

Page 19: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

19

amazon-ec2 gemSetup

Usage

Page 20: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

20

SQS - Simple Queue Service

• Distributed, highly scalable and reliable message system

• Unlimited number of queues and messages

• Locking / releasing built-in

• 256 KB message payload

• Basic permission model

Page 21: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

21

SQS gemSetup

Usage

Page 22: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

22

How does this solvemy problems?

Page 23: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

23

S3 - Backup

• s3sync.rb

• Brackup

• Jungle Disk

• S3 FUSE

• s3DAV

• Duplicity

• S3Browser

• Firefox S3 Organizer extension

• …

Page 24: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

24

s3sync.rb

Backup

Restore

Page 25: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

25

S3 Asset Host

Page 26: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

26

S3 Asset Host

Setup DNS

Rails configuration

Page 27: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

27

S3 Asset Host

welcome.rhtml template

Output

Page 28: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

28

S3 - Authenticated User Data

Page 29: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

29

attachment_fu Rails plugin

Setup

Page 30: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

30

attachment_fu Rails plugin

Upload

Download

Page 31: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

31

On-Demand Computing with EC2

Time based, e.g. with cron

Page 32: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

32

On-Demand Computing with EC2

Load based, e.g. with Monit

Page 33: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

33

On-Demand Computing with EC2

Page 34: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

34

EC2 for extra capacity

Page 35: Use Somebody Else's Infrastructure - Utilizing Amazon S3 and EC2

35

Peritor Wissensmanagement GmbH

Lenbachstrasse 212157 Berlin

Internet: www.peritor.comEmail: [email protected]

© Peritor Wissensmanagement GmbH - All Rights Reserved

Phone: +49 (0)30 69 40 11 94Fax: +49 (0)30 69 40 11 95