drupal amazon integration

69
Drupal Integration with Amazon S3 & Cloudfront Mark Schoonover – ThetaJoin [email protected] SandCamp 2010

Upload: sowmya-sreenivasan

Post on 11-Mar-2015

119 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Drupal Amazon Integration

Hosting Drupal – Getting Started!

Drupal Integration with Amazon S3 & Cloudfront

Mark Schoonover – [email protected] 2010

Page 2: Drupal Amazon Integration

Content Delivery Networks

● What do they do?

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 3: Drupal Amazon Integration

Content Delivery Networks

● What do they do?

● Content Delivery Networks (CDN) are used to move bandwidth intensive files off your Drupal hosting server and put them closer to end user computers.

● Content can be audio, video, photos, software, other documents, or static files.

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 4: Drupal Amazon Integration

Content Delivery Networks

● What do they do?

● Content Delivery Networks (CDN) are used to move bandwidth intensive files off your Drupal hosting server and put them closer to end user computers.

● Content can be audio, video, photos, software, other documents, or static files.

● Excellent not just for distributing large files, but frequently accessed smaller files.

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 5: Drupal Amazon Integration

Content Delivery Networks

● What do they do?

● Content Delivery Networks (CDN) are used to move bandwidth intensive files off your Drupal hosting server and put them closer to end user computers.

● Content can be audio, video, photos, software, other documents, or static files.

● Excellent not just for distributing large files, but frequently accessed smaller files.

● Excellent for streaming audio and video, especially if your Drupal server doesn't support streaming.

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 6: Drupal Amazon Integration

Content Delivery Networks

● Popular CDNs

– Akamai– Amazon Cloudfront– Amazon Simple Storage Service (S3)– CacheFly– Many more...

http://www.thetajoin.com

Page 7: Drupal Amazon Integration

Content Delivery Networks

We'll be concentrating on integrating Drupal 6 with Amazon Simple Storage Service – S3 & Amazon Cloudfront

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 8: Drupal Amazon Integration

Content Delivery Networks

Requirements

http://www.thetajoin.comCreative Commons Attribution ShareAlike 3.0

Creative Commons Attribution ShareAlike 3.0

Page 9: Drupal Amazon Integration

Content Delivery Networks

Requirements

– Amazon Web Services Account– Signup for Amazon S3 & Cloudfront– Amazon S3 file management tools– Comfortable installing & configuring Drupal modules– Comfortable modifying Drupal settings.php file– Comfortable modifying template.php theme file– Know how to configure ImageCache

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 10: Drupal Amazon Integration

Content Delivery Networks

Benefits of Amazon S3

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 11: Drupal Amazon Integration

Content Delivery Networks

Benefits of Amazon S3– Unlimited, pay as you go storage– Geographical data centers in US, Northern CA, Europe

too– Many S3 file managment tools– Keeps your Drupal files directory free of large infrequently

changed files– Supports BitTorrent

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 12: Drupal Amazon Integration

Content Delivery Networks

Drawbacks of Amazon S3– Not as many datacenters as Cloudfront– No CCK for S3– Manual integration with Drupal content– Data in two places

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 13: Drupal Amazon Integration

Content Delivery Networks

Benefits of Amazon Cloudfront

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 14: Drupal Amazon Integration

Content Delivery Networks

Benefits of Amazon Cloudfront– Unlimited temporary storage– Uses Amazon S3 as origin storage– More datacenters than S3– Now supports audio & video content streaming

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 15: Drupal Amazon Integration

Content Delivery Networks

Benefits of Amazon Cloudfront– Unlimited temporary storage– Uses Amazon S3 as origin storage– More datacenters than S3– Now supports audio & video content streaming

● Unlimited, Private YouTube anyone??Unlimited, Private YouTube anyone??

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 16: Drupal Amazon Integration

Content Delivery Networks

United States

* Ashburn, VA

* Dallas/Fort Worth, TX

* Los Angeles, CA

* Miami, FL

* Newark, NJ

* Palo Alto, CA

* Seattle, WA

* St. Louis, MO

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Europe

* Amsterdam

* Dublin

* Frankfurt

* London

Asia

* Hong Kong

* Tokyo

Page 17: Drupal Amazon Integration

Content Delivery Networks

Drawbacks of Amazon Cloudfront– 24 hour limit on files at edge, must recopy from S3– Charged for every time file is copied from S3 to

Cloudfront.– Charged when file requested from Cloudfront– Revisions of files with same name

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 18: Drupal Amazon Integration

Content Delivery Networks

Copy Content to Amazon S3

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 19: Drupal Amazon Integration

Content Delivery Networks

Copy Content to Amazon S3– Amazon S3 Drupal module

● Can be found: http://drupal.org/project/amazon_s3– Firefox S3Fox add-on

● Can be found: http://www.s3fox.net/– There are others...

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 20: Drupal Amazon Integration

Content Delivery Networks

Sign Up for Amazon Web Services

– http://aws.amazon.com/

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 21: Drupal Amazon Integration

Content Delivery Networks

Sign Up for Amazon S3 & Cloudfront

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 22: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Access Keys

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 23: Drupal Amazon Integration

Content Delivery Networks

Install & Enable Amazon S3 Module

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 24: Drupal Amazon Integration

Content Delivery Networks

Install & Enable Amazon S3 Module

– Download– Untar into /path/to/drupal/sites/all/modules– Enable

● Administer->Site Building->Modules

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 25: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module Configuration

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 26: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module Configuration

Administer­>Site Configuration­>Amazon S3 Configuration

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 27: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module Configuration

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 28: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module Usage

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 29: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module Usage

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 30: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 Drupal Module– Draw backs

● Can't create subdirectories● Very basic S3 control● Can't modify existing buckets● Can't create Cloudfront distributions

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 31: Drupal Amazon Integration

Content Delivery Networks

Toplevel bucket name needs to be unique across ALL of S3!

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 32: Drupal Amazon Integration

Content Delivery Networks

Toplevel bucket name needs to be unique across ALL of S3!

– cdn.example.com

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 33: Drupal Amazon Integration

Content Delivery Networks

S3Fox – Firefox Addon

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 34: Drupal Amazon Integration

Content Delivery Networks

S3Fox – Firefox Addon– www.s3fox.net

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 35: Drupal Amazon Integration

Content Delivery Networks

S3Fox Account Manager

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 36: Drupal Amazon Integration

Content Delivery Networks

S3Fox Configuration

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 37: Drupal Amazon Integration

Content Delivery Networks

S3Fox Usage

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 38: Drupal Amazon Integration

Content Delivery Networks

S3Fox Usage

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 39: Drupal Amazon Integration

Content Delivery Networks

Files are now on Amazon S3!

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 40: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal & Amazon S3 Integration

Page 41: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal & Amazon S3 Integration● Obtain URL to file on S3

– Copy URL to Clipboard● Insert URL into Content

Page 42: Drupal Amazon Integration

Content Delivery Networks

Amazon S3 File URL

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

http://cdn.thetajoin.com.s3.amazonaws.com/HostingGuide/CactiLogin01.png

Page 43: Drupal Amazon Integration

Content Delivery Networks

Paste S3 URL

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Page 44: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal & Amazon S3 Integration Complete!

Page 45: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Oh, this URL

http://cdn.thetajoin.com.s3.amazonaws.com/HostingGuide/....

Page 46: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Oh, this URL

http://cdn.thetajoin.com.s3.amazonaws.com/HostingGuide/....

Oh SO ugly!

Page 47: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

DNS CNAME trick

Page 48: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

New URL:

http://cdn.thetajoin.com/HostingGuide/CactiLogin01.png

Page 49: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Amazon Cloudfront Integration

Page 50: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Amazon Cloudfront Integration● Upload files to S3● Create Cloudfront distribution

– Right click on bucket->manage distribution

Page 51: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Amazon Cloudfront Integration● Upload files to S3● Create Cloudfront distribution

– Right click on bucket->manage distribution● Add CNAME like cf.example.com in DNS

Page 52: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Amazon Cloudfront Integration● Upload files to S3● Create Cloudfront distribution

– Right click on bucket->manage distribution● Add CNAME like cf.example.com in DNS

– cf.example.com

Page 53: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Amazon Cloudfront Integration● Upload files to S3● Create Cloudfront distribution

– Right click on bucket->manage distribution● Add CNAME like cf.example.com in DNS

– cf.example.com– http://cf.example.com/directory/file.pdf

Page 54: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Amazon Cloudfront Integration● Upload files to S3● Create Cloudfront distribution

– Right click on bucket->manage distribution● Add CNAME like cf.example.com in DNS

– cf.example.com– http://cf.example.com/bucket/file.pdf

● Amazon Cloudfront handles requesting content from S3

Page 55: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Amazon Cloudfront Integration● Determine URL● Copy N Paste URL into Drupal

Page 56: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Amazon Cloudfront Integration● Determine URL● Copy N Paste URL into Drupal● You're golden!

Page 57: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal and Amazon Cloudfront Automation● Use Cloudfront module

Page 58: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal Amazon Cloudfront Module● Install Cloudfront module, enable, permissions

– http://drupal.org/project/cloudfront– Depends on ImageCache & ImageAPI modules

● Add Access & Secret Keys to settings.php● Add 'Send to Cloudfront' Image Cache action &

Configure● Override theme_imagecache function in template.php● Cron configuration & security

Page 59: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Drupal Amazon Cloudfront Module● Add Access & Secret Keys to settings.php

Page 60: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Cloudfront Config

Page 61: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Cloudfront Config

Page 62: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Override theme_imagecache function in template.php

Page 63: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

How does it work?● imagecache inserts path data into cloudfront_files

table

Page 64: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

How does it work?● imagecache inserts path data into cloudfront_files

table● CRON job http://localhost/cloudfront/processqueue

– Pushes images to S3– Updates cloudfront_send_queue table with updated

path info

Page 65: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

How does it work?● imagecache inserts path data into cloudfront_files

table● CRON job http://localhost/cloudfront/processqueue

– Pushes images to S3– Updates cloudfront_send_queue table with updated

path info● garland_imagecache() rewrites IMG tag URL to

point to Cloudfront

Creative Commons Attribution ShareAlike 3.0

Page 66: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Creative Commons Attribution ShareAlike 3.0

Becareful flushing imagecache!

– Could take significant time to reprocess images, copy to S3!

Page 67: Drupal Amazon Integration

Content Delivery Networks

http://www.thetajoin.com

Becareful flushing imagecache!– Could take significant time to reprocess images,

copy to S3!– Remember Cloudfront and revisions, there's no

way to manually flush Cloudfront

Page 68: Drupal Amazon Integration

Slides of this talk available on: http://www.thetajoin.com - SandCAMP

Page 69: Drupal Amazon Integration

Thank you for attending my SandCAMP 2010 session. I hope you enjoyed the session as much as I did preparing and presenting.

For attendees of my sessions & people who download my slides, I'm offering a free Drupal performance analysis of your site! I have to limit this offer to a single site only, so pick your worst! Just email or call to setup an appointment.

Hope you had a great time at SandCAMP 2010!

Regards,Mark Schoonover

http://www.thetajoin.com - The Drupal Hosting & Performance CompanyEmail: [email protected] :: Voice: 619-928-4473 :: Fax: 619-374-3130