CloudFront DESIGN PATTERNS

68
CloudFront DESIGN PATTERNS Abhishek Tiwari @abhishektiwari http://abhishek-tiwari.com Wednesday, 7 August 13

description

CloudFront is a Content Delivery Network (CDN) provided by Amazon Web Services (AWS). It integrates seamlessly with other AWS services. Agenda of this presentation is CloudFront DESIGN PATTERNS which covers standard reusable CloudFront implementations. This presentation was prepared for AWS Sydney Meetup.

Transcript of CloudFront DESIGN PATTERNS

Page 1: CloudFront  DESIGN PATTERNS

CloudFront DESIGN PATTERNS

Abhishek Tiwari@abhishektiwari

http://abhishek-tiwari.com

Wednesday, 7 August 13

Page 2: CloudFront  DESIGN PATTERNS

About me

Wednesday, 7 August 13

Page 3: CloudFront  DESIGN PATTERNS

About me

Solutions Architect

Wednesday, 7 August 13

Page 4: CloudFront  DESIGN PATTERNS

About me

Solutions Architect Early AWS adopter (2007)

Wednesday, 7 August 13

Page 5: CloudFront  DESIGN PATTERNS

About me

Solutions Architect Early AWS adopter (2007)Built Cotton On Group’s AWS Infrastructure (2012)

Wednesday, 7 August 13

Page 6: CloudFront  DESIGN PATTERNS

Design Patterns

Wednesday, 7 August 13

Page 7: CloudFront  DESIGN PATTERNS

Design Patterns

Dynamic and Adoptive Thumbnailing

Wednesday, 7 August 13

Page 8: CloudFront  DESIGN PATTERNS

Design Patterns

Dynamic and Adoptive ThumbnailingAudio/Video Streaming

Wednesday, 7 August 13

Page 9: CloudFront  DESIGN PATTERNS

Design Patterns

Dynamic and Adoptive ThumbnailingAudio/Video StreamingPrivate Content

Wednesday, 7 August 13

Page 10: CloudFront  DESIGN PATTERNS

Design Patterns

Dynamic and Adoptive ThumbnailingAudio/Video StreamingPrivate ContentLive Streaming

Wednesday, 7 August 13

Page 11: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailing

Wednesday, 7 August 13

Page 12: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/caching

Wednesday, 7 August 13

Page 13: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/cachingAdoptive: optimized for the device

Wednesday, 7 August 13

Page 14: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/cachingAdoptive: optimized for the deviceAnti-pattern: Generate all sizes of thumbnails on image upload and store in S3

Wednesday, 7 August 13

Page 15: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/cachingAdoptive: optimized for the deviceAnti-pattern: Generate all sizes of thumbnails on image upload and store in S3

Not adoptive

Wednesday, 7 August 13

Page 16: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/cachingAdoptive: optimized for the deviceAnti-pattern: Generate all sizes of thumbnails on image upload and store in S3

Not adoptiveNot manageable

Wednesday, 7 August 13

Page 17: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingDynamic: on-the-fly thumbnailing/cachingAdoptive: optimized for the deviceAnti-pattern: Generate all sizes of thumbnails on image upload and store in S3

Not adoptiveNot manageableMinor Design Changes: Regenerate all thumbnails every time

Wednesday, 7 August 13

Page 18: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailing

Wednesday, 7 August 13

Page 19: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

Wednesday, 7 August 13

Page 20: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

A thumbnail cache behavior mapped to custom origin server

Wednesday, 7 August 13

Page 21: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

A thumbnail cache behavior mapped to custom origin serverCustom origin server with ability

Wednesday, 7 August 13

Page 22: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

A thumbnail cache behavior mapped to custom origin serverCustom origin server with ability

To download original image from S3 or any other source

Wednesday, 7 August 13

Page 23: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

A thumbnail cache behavior mapped to custom origin serverCustom origin server with ability

To download original image from S3 or any other sourceTo generate thumbnail of requested size and return it to CF distribution to serve

Wednesday, 7 August 13

Page 24: CloudFront  DESIGN PATTERNS

Dynamic ThumbnailingRequires

A thumbnail cache behavior mapped to custom origin serverCustom origin server with ability

To download original image from S3 or any other sourceTo generate thumbnail of requested size and return it to CF distribution to serveTo set expiration time so that in near-future CF don’t request again

Wednesday, 7 August 13

Page 25: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailingdef thumb (image, width, height) :

quality = 0.9thumbed = getThumb(image, quality, width, height)thumbed.setCacheControlMaxAge(EX)......return thumbed

Width Height Image

Wednesday, 7 August 13

Page 26: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailingdef thumb (image, width, height) :

quality = 0.9thumbed = getThumb(image, quality, width, height)thumbed.setCacheControlMaxAge(EX)......return thumbed

Wednesday, 7 August 13

Page 27: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailing

static/images/thumb/b723eh0f0df.png?width=400&height=300

def thumb (image, width, height) :quality = 0.9thumbed = getThumb(image, quality, width, height)thumbed.setCacheControlMaxAge(EX)......return thumbed

Wednesday, 7 August 13

Page 28: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailing

static/images/thumb/b723eh0f0df.png?width=400&height=300static/images/thumb/b723eh0f0df.png?width=400&height=300

def thumb (image, width, height) :quality = 0.9thumbed = getThumb(image, quality, width, height)thumbed.setCacheControlMaxAge(EX)......return thumbed

Wednesday, 7 August 13

Page 29: CloudFront  DESIGN PATTERNS

Dynamic Thumbnailing

static/images/thumb/b723eh0f0df.png?width=400&height=300static/images/thumb/b723eh0f0df.png?width=400&height=300

def thumb (image, width, height) :quality = 0.9thumbed = getThumb(image, quality, width, height)thumbed.setCacheControlMaxAge(EX)......return thumbed

Forward Query Strings is Turned On

Wednesday, 7 August 13

Page 30: CloudFront  DESIGN PATTERNS

Audio/Video Streaming

Wednesday, 7 August 13

Page 31: CloudFront  DESIGN PATTERNS

Audio/Video StreamingRequires two CloudFront distributions

Wednesday, 7 August 13

Page 32: CloudFront  DESIGN PATTERNS

Audio/Video StreamingRequires two CloudFront distributions

Download distribution (HTTP protocol) for media player

Wednesday, 7 August 13

Page 33: CloudFront  DESIGN PATTERNS

Audio/Video StreamingRequires two CloudFront distributions

Download distribution (HTTP protocol) for media playerStreaming distribution (RMTP protocol) for video/audio file

Wednesday, 7 August 13

Page 34: CloudFront  DESIGN PATTERNS

Audio/Video StreamingRequires two CloudFront distributions

Download distribution (HTTP protocol) for media playerStreaming distribution (RMTP protocol) for video/audio file

Adobe Flash Media Server 3.5 as the streaming server

Wednesday, 7 August 13

Page 35: CloudFront  DESIGN PATTERNS

Audio/Video StreamingRequires two CloudFront distributions

Download distribution (HTTP protocol) for media playerStreaming distribution (RMTP protocol) for video/audio file

Adobe Flash Media Server 3.5 as the streaming serverRTMP Variants: RTMP, RTMPT, RTMPE, RTMPTE

Wednesday, 7 August 13

Page 36: CloudFront  DESIGN PATTERNS

Audio/Video Streaming

Wednesday, 7 August 13

Page 37: CloudFront  DESIGN PATTERNS

Private Content

Wednesday, 7 August 13

Page 38: CloudFront  DESIGN PATTERNS

Private ContentRestrict viewer access using signed URL

Wednesday, 7 August 13

Page 39: CloudFront  DESIGN PATTERNS

Private ContentRestrict viewer access using signed URLSigned URLs control access based on policy statement

Wednesday, 7 August 13

Page 40: CloudFront  DESIGN PATTERNS

Private ContentRestrict viewer access using signed URLSigned URLs control access based on policy statementPolicy statement can be

Wednesday, 7 August 13

Page 41: CloudFront  DESIGN PATTERNS

Private ContentRestrict viewer access using signed URLSigned URLs control access based on policy statementPolicy statement can be

Canned policy (access to one object)

Wednesday, 7 August 13

Page 42: CloudFront  DESIGN PATTERNS

Private ContentRestrict viewer access using signed URLSigned URLs control access based on policy statementPolicy statement can be

Canned policy (access to one object)Custom policy (access to one or more objects using pattern matching)

Wednesday, 7 August 13

Page 43: CloudFront  DESIGN PATTERNS

Private Content

Wednesday, 7 August 13

Page 44: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

Wednesday, 7 August 13

Page 45: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv)

Wednesday, 7 August 13

Page 46: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv) a policy statement as a signature (hashed+signed, optionally Base-64 encoded for URL safe compression)

Wednesday, 7 August 13

Page 47: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv) a policy statement as a signature (hashed+signed, optionally Base-64 encoded for URL safe compression)CF key-pair id

Wednesday, 7 August 13

Page 48: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv) a policy statement as a signature (hashed+signed, optionally Base-64 encoded for URL safe compression)CF key-pair id optional parameters (expiration timestamp etc)

Wednesday, 7 August 13

Page 49: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv) a policy statement as a signature (hashed+signed, optionally Base-64 encoded for URL safe compression)CF key-pair id optional parameters (expiration timestamp etc)

CF matches the signed URL pattern

Wednesday, 7 August 13

Page 50: CloudFront  DESIGN PATTERNS

Private ContentA complete singed URL contains

a base URL (http://my.cf.net/image.png, /v/myvideo.flv) a policy statement as a signature (hashed+signed, optionally Base-64 encoded for URL safe compression)CF key-pair id optional parameters (expiration timestamp etc)

CF matches the signed URL patternIf signed URL is valid then CF gives viewer access to object

Wednesday, 7 August 13

Page 51: CloudFront  DESIGN PATTERNS

Private Content (Streaming)

Wednesday, 7 August 13

Page 52: CloudFront  DESIGN PATTERNS

Private Content (Download)

Wednesday, 7 August 13

Page 53: CloudFront  DESIGN PATTERNS

Live Streaming

Wednesday, 7 August 13

Page 54: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Wednesday, 7 August 13

Page 55: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Adobe’s Flash Media Server 4.5 (AFMS)

Wednesday, 7 August 13

Page 56: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Adobe’s Flash Media Server 4.5 (AFMS) IIS Media Services (Smooth Streaming)

Wednesday, 7 August 13

Page 57: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Adobe’s Flash Media Server 4.5 (AFMS) IIS Media Services (Smooth Streaming)

Both Stream media over HTTP/HTTPS to Apple iOS devices in HLS format

Wednesday, 7 August 13

Page 58: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Adobe’s Flash Media Server 4.5 (AFMS) IIS Media Services (Smooth Streaming)

Both Stream media over HTTP/HTTPS to Apple iOS devices in HLS formatAFMS streams to Flash clients with HDS

Wednesday, 7 August 13

Page 59: CloudFront  DESIGN PATTERNS

Live StreamingSupports live streaming with

Adobe’s Flash Media Server 4.5 (AFMS) IIS Media Services (Smooth Streaming)

Both Stream media over HTTP/HTTPS to Apple iOS devices in HLS formatAFMS streams to Flash clients with HDSIIS MS stream to Silverlight clients over HTTP

Wednesday, 7 August 13

Page 60: CloudFront  DESIGN PATTERNS

Live Streaming

Wednesday, 7 August 13

Page 61: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Wednesday, 7 August 13

Page 62: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Each solution relies on an encoder and a media service or server

Wednesday, 7 August 13

Page 63: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Each solution relies on an encoder and a media service or serverEncoder takes live video as input and convert video into right format

Wednesday, 7 August 13

Page 64: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Each solution relies on an encoder and a media service or serverEncoder takes live video as input and convert video into right formatVideo is pushed to origin server (media service or server)

Wednesday, 7 August 13

Page 65: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Each solution relies on an encoder and a media service or serverEncoder takes live video as input and convert video into right formatVideo is pushed to origin server (media service or server)Origin server then breaks the video into a series of smaller files (segments or fragments)

Wednesday, 7 August 13

Page 66: CloudFront  DESIGN PATTERNS

Live StreamingHow it work?

Each solution relies on an encoder and a media service or serverEncoder takes live video as input and convert video into right formatVideo is pushed to origin server (media service or server)Origin server then breaks the video into a series of smaller files (segments or fragments)Each fragment is cached in CF and can be encoded on different bit rate

Wednesday, 7 August 13

Page 67: CloudFront  DESIGN PATTERNS

Wednesday, 7 August 13

Page 68: CloudFront  DESIGN PATTERNS

Thank YouQ & A

Wednesday, 7 August 13