Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CloudFront DESIGN PATTERNS

CloudFront DESIGN PATTERNS

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.

Abhishek Tiwari

August 07, 2013
Tweet

More Decks by Abhishek Tiwari

Other Decks in Technology

Transcript

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

    View full-size slide

  2. About me
    Wednesday, 7 August 13

    View full-size slide

  3. About me
    Solutions Architect
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. Design Patterns
    Wednesday, 7 August 13

    View full-size slide

  7. Design Patterns
    Dynamic and Adoptive Thumbnailing
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  11. Dynamic Thumbnailing
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  14. 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

    View full-size slide

  15. 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

    View full-size slide

  16. 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

    View full-size slide

  17. 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

    View full-size slide

  18. Dynamic Thumbnailing
    Wednesday, 7 August 13

    View full-size slide

  19. Dynamic Thumbnailing
    Requires
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  22. 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

    View full-size slide

  23. 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

    View full-size slide

  24. 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

    View full-size slide

  25. 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

    View full-size slide

  26. 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

    View full-size slide

  27. 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

    View full-size slide

  28. 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

    View full-size slide

  29. 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

    View full-size slide

  30. Audio/Video Streaming
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  33. 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

    View full-size slide

  34. 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

    View full-size slide

  35. 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

    View full-size slide

  36. Audio/Video Streaming
    Wednesday, 7 August 13

    View full-size slide

  37. Private Content
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  41. 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

    View full-size slide

  42. 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

    View full-size slide

  43. Private Content
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  46. 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

    View full-size slide

  47. 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

    View full-size slide

  48. 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

    View full-size slide

  49. 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

    View full-size slide

  50. 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

    View full-size slide

  51. Private Content (Streaming)
    Wednesday, 7 August 13

    View full-size slide

  52. Private Content (Download)
    Wednesday, 7 August 13

    View full-size slide

  53. Live Streaming
    Wednesday, 7 August 13

    View full-size slide

  54. Live Streaming
    Supports live streaming with
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  57. 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

    View full-size slide

  58. 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

    View full-size slide

  59. 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

    View full-size slide

  60. Live Streaming
    Wednesday, 7 August 13

    View full-size slide

  61. Live Streaming
    How it work?
    Wednesday, 7 August 13

    View full-size slide

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

    View full-size slide

  63. 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

    View full-size slide

  64. 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

    View full-size slide

  65. 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

    View full-size slide

  66. 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

    View full-size slide

  67. Wednesday, 7 August 13

    View full-size slide

  68. Thank You
    Q & A
    Wednesday, 7 August 13

    View full-size slide