Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

About me Wednesday, 7 August 13

Slide 3

Slide 3 text

About me Solutions Architect Wednesday, 7 August 13

Slide 4

Slide 4 text

About me Solutions Architect Early AWS adopter (2007) Wednesday, 7 August 13

Slide 5

Slide 5 text

About me Solutions Architect Early AWS adopter (2007) Built Cotton On Group’s AWS Infrastructure (2012) Wednesday, 7 August 13

Slide 6

Slide 6 text

Design Patterns Wednesday, 7 August 13

Slide 7

Slide 7 text

Design Patterns Dynamic and Adoptive Thumbnailing Wednesday, 7 August 13

Slide 8

Slide 8 text

Design Patterns Dynamic and Adoptive Thumbnailing Audio/Video Streaming Wednesday, 7 August 13

Slide 9

Slide 9 text

Design Patterns Dynamic and Adoptive Thumbnailing Audio/Video Streaming Private Content Wednesday, 7 August 13

Slide 10

Slide 10 text

Design Patterns Dynamic and Adoptive Thumbnailing Audio/Video Streaming Private Content Live Streaming Wednesday, 7 August 13

Slide 11

Slide 11 text

Dynamic Thumbnailing Wednesday, 7 August 13

Slide 12

Slide 12 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Wednesday, 7 August 13

Slide 13

Slide 13 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Adoptive: optimized for the device Wednesday, 7 August 13

Slide 14

Slide 14 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Adoptive: optimized for the device Anti-pattern: Generate all sizes of thumbnails on image upload and store in S3 Wednesday, 7 August 13

Slide 15

Slide 15 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Adoptive: optimized for the device Anti-pattern: Generate all sizes of thumbnails on image upload and store in S3 Not adoptive Wednesday, 7 August 13

Slide 16

Slide 16 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Adoptive: optimized for the device Anti-pattern: Generate all sizes of thumbnails on image upload and store in S3 Not adoptive Not manageable Wednesday, 7 August 13

Slide 17

Slide 17 text

Dynamic Thumbnailing Dynamic: on-the-fly thumbnailing/caching Adoptive: optimized for the device Anti-pattern: Generate all sizes of thumbnails on image upload and store in S3 Not adoptive Not manageable Minor Design Changes: Regenerate all thumbnails every time Wednesday, 7 August 13

Slide 18

Slide 18 text

Dynamic Thumbnailing Wednesday, 7 August 13

Slide 19

Slide 19 text

Dynamic Thumbnailing Requires Wednesday, 7 August 13

Slide 20

Slide 20 text

Dynamic Thumbnailing Requires A thumbnail cache behavior mapped to custom origin server Wednesday, 7 August 13

Slide 21

Slide 21 text

Dynamic Thumbnailing Requires A thumbnail cache behavior mapped to custom origin server Custom origin server with ability Wednesday, 7 August 13

Slide 22

Slide 22 text

Dynamic Thumbnailing Requires A thumbnail cache behavior mapped to custom origin server Custom origin server with ability To download original image from S3 or any other source Wednesday, 7 August 13

Slide 23

Slide 23 text

Dynamic Thumbnailing Requires A thumbnail cache behavior mapped to custom origin server Custom origin server with ability To download original image from S3 or any other source To generate thumbnail of requested size and return it to CF distribution to serve Wednesday, 7 August 13

Slide 24

Slide 24 text

Dynamic Thumbnailing Requires A thumbnail cache behavior mapped to custom origin server Custom origin server with ability To download original image from S3 or any other source To generate thumbnail of requested size and return it to CF distribution to serve To set expiration time so that in near-future CF don’t request again Wednesday, 7 August 13

Slide 25

Slide 25 text

Dynamic Thumbnailing def thumb (image, width, height) : quality = 0.9 thumbed = getThumb(image, quality, width, height) thumbed.setCacheControlMaxAge(EX) ...... return thumbed Width Height Image Wednesday, 7 August 13

Slide 26

Slide 26 text

Dynamic Thumbnailing def thumb (image, width, height) : quality = 0.9 thumbed = getThumb(image, quality, width, height) thumbed.setCacheControlMaxAge(EX) ...... return thumbed Wednesday, 7 August 13

Slide 27

Slide 27 text

Dynamic Thumbnailing static/images/thumb/b723eh0f0df.png?width=400&height=300 def thumb (image, width, height) : quality = 0.9 thumbed = getThumb(image, quality, width, height) thumbed.setCacheControlMaxAge(EX) ...... return thumbed Wednesday, 7 August 13

Slide 28

Slide 28 text

Dynamic Thumbnailing static/images/thumb/b723eh0f0df.png?width=400&height=300 static/images/thumb/b723eh0f0df.png?width=400&height=300 def thumb (image, width, height) : quality = 0.9 thumbed = getThumb(image, quality, width, height) thumbed.setCacheControlMaxAge(EX) ...... return thumbed Wednesday, 7 August 13

Slide 29

Slide 29 text

Dynamic Thumbnailing static/images/thumb/b723eh0f0df.png?width=400&height=300 static/images/thumb/b723eh0f0df.png?width=400&height=300 def thumb (image, width, height) : quality = 0.9 thumbed = getThumb(image, quality, width, height) thumbed.setCacheControlMaxAge(EX) ...... return thumbed Forward Query Strings is Turned On Wednesday, 7 August 13

Slide 30

Slide 30 text

Audio/Video Streaming Wednesday, 7 August 13

Slide 31

Slide 31 text

Audio/Video Streaming Requires two CloudFront distributions Wednesday, 7 August 13

Slide 32

Slide 32 text

Audio/Video Streaming Requires two CloudFront distributions Download distribution (HTTP protocol) for media player Wednesday, 7 August 13

Slide 33

Slide 33 text

Audio/Video Streaming Requires two CloudFront distributions Download distribution (HTTP protocol) for media player Streaming distribution (RMTP protocol) for video/audio file Wednesday, 7 August 13

Slide 34

Slide 34 text

Audio/Video Streaming Requires two CloudFront distributions Download distribution (HTTP protocol) for media player Streaming distribution (RMTP protocol) for video/audio file Adobe Flash Media Server 3.5 as the streaming server Wednesday, 7 August 13

Slide 35

Slide 35 text

Audio/Video Streaming Requires two CloudFront distributions Download distribution (HTTP protocol) for media player Streaming distribution (RMTP protocol) for video/audio file Adobe Flash Media Server 3.5 as the streaming server RTMP Variants: RTMP, RTMPT, RTMPE, RTMPTE Wednesday, 7 August 13

Slide 36

Slide 36 text

Audio/Video Streaming Wednesday, 7 August 13

Slide 37

Slide 37 text

Private Content Wednesday, 7 August 13

Slide 38

Slide 38 text

Private Content Restrict viewer access using signed URL Wednesday, 7 August 13

Slide 39

Slide 39 text

Private Content Restrict viewer access using signed URL Signed URLs control access based on policy statement Wednesday, 7 August 13

Slide 40

Slide 40 text

Private Content Restrict viewer access using signed URL Signed URLs control access based on policy statement Policy statement can be Wednesday, 7 August 13

Slide 41

Slide 41 text

Private Content Restrict viewer access using signed URL Signed URLs control access based on policy statement Policy statement can be Canned policy (access to one object) Wednesday, 7 August 13

Slide 42

Slide 42 text

Private Content Restrict viewer access using signed URL Signed URLs control access based on policy statement Policy statement can be Canned policy (access to one object) Custom policy (access to one or more objects using pattern matching) Wednesday, 7 August 13

Slide 43

Slide 43 text

Private Content Wednesday, 7 August 13

Slide 44

Slide 44 text

Private Content A complete singed URL contains Wednesday, 7 August 13

Slide 45

Slide 45 text

Private Content A complete singed URL contains a base URL (http:/ /my.cf.net/image.png, /v/myvideo.flv) Wednesday, 7 August 13

Slide 46

Slide 46 text

Private Content A 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

Slide 47

Slide 47 text

Private Content A 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

Slide 48

Slide 48 text

Private Content A 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

Slide 49

Slide 49 text

Private Content A 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

Slide 50

Slide 50 text

Private Content A 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 If signed URL is valid then CF gives viewer access to object Wednesday, 7 August 13

Slide 51

Slide 51 text

Private Content (Streaming) Wednesday, 7 August 13

Slide 52

Slide 52 text

Private Content (Download) Wednesday, 7 August 13

Slide 53

Slide 53 text

Live Streaming Wednesday, 7 August 13

Slide 54

Slide 54 text

Live Streaming Supports live streaming with Wednesday, 7 August 13

Slide 55

Slide 55 text

Live Streaming Supports live streaming with Adobe’s Flash Media Server 4.5 (AFMS) Wednesday, 7 August 13

Slide 56

Slide 56 text

Live Streaming Supports live streaming with Adobe’s Flash Media Server 4.5 (AFMS) IIS Media Services (Smooth Streaming) Wednesday, 7 August 13

Slide 57

Slide 57 text

Live Streaming Supports 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

Slide 58

Slide 58 text

Live Streaming Supports 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 AFMS streams to Flash clients with HDS Wednesday, 7 August 13

Slide 59

Slide 59 text

Live Streaming Supports 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 AFMS streams to Flash clients with HDS IIS MS stream to Silverlight clients over HTTP Wednesday, 7 August 13

Slide 60

Slide 60 text

Live Streaming Wednesday, 7 August 13

Slide 61

Slide 61 text

Live Streaming How it work? Wednesday, 7 August 13

Slide 62

Slide 62 text

Live Streaming How it work? Each solution relies on an encoder and a media service or server Wednesday, 7 August 13

Slide 63

Slide 63 text

Live Streaming How it work? Each solution relies on an encoder and a media service or server Encoder takes live video as input and convert video into right format Wednesday, 7 August 13

Slide 64

Slide 64 text

Live Streaming How it work? Each solution relies on an encoder and a media service or server Encoder takes live video as input and convert video into right format Video is pushed to origin server (media service or server) Wednesday, 7 August 13

Slide 65

Slide 65 text

Live Streaming How it work? Each solution relies on an encoder and a media service or server Encoder takes live video as input and convert video into right format Video 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

Slide 66

Slide 66 text

Live Streaming How it work? Each solution relies on an encoder and a media service or server Encoder takes live video as input and convert video into right format Video 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

Slide 67

Slide 67 text

Wednesday, 7 August 13

Slide 68

Slide 68 text

Thank You Q & A Wednesday, 7 August 13