Top Banner
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Alec Peterson, AWS, GM Amazon CloudFront Shubham Katiyar, AWS, Sr. Software Development Manager Daniel Amitai, VP Business Development, Cloudinary.com December 1, 2016 NEW LAUNCH! Bringing AWS Lambda to the Edge (Lambda@Edge Preview) CTD206
42

NEW LAUNCH! Bringing AWS Lambda to the Edge

Apr 16, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: NEW LAUNCH! Bringing AWS Lambda to the Edge

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Alec Peterson, AWS, GM – Amazon CloudFront

Shubham Katiyar, AWS, Sr. Software Development Manager

Daniel Amitai, VP Business Development, Cloudinary.com

December 1, 2016

NEW LAUNCH!

Bringing AWS Lambda to the Edge (Lambda@Edge Preview)

CTD206

Page 2: NEW LAUNCH! Bringing AWS Lambda to the Edge

What to Expect from the Session

• Background on AWS Lambda and Amazon CloudFront

• Lambda@Edge: How it works, and when to use it

• Demo of Lambda@Edge

• Customer Case Study: Cloudinary

• Getting started with Lambda@Edge (Preview)

Page 3: NEW LAUNCH! Bringing AWS Lambda to the Edge

AWS Lambda: Evolution of

Cloud Compute towards

Serverless

Page 4: NEW LAUNCH! Bringing AWS Lambda to the Edge

Evolution of Compute – Public Cloud

InfrastructureInstances

Application code

Page 5: NEW LAUNCH! Bringing AWS Lambda to the Edge

Evolution of Compute – Containers

InfrastructureInstances

Application codeContainers

Page 6: NEW LAUNCH! Bringing AWS Lambda to the Edge

Evolution of Compute – Serverless

Application code

Page 7: NEW LAUNCH! Bringing AWS Lambda to the Edge

AWS Lambda: Serverless computing

Run code without servers. Pay only for the compute time you consume. Be happy.

Triggered by events or called from APIs:• PUT to an Amazon S3 bucket

• Updates to Amazon DynamoDB table

• Call to an Amazon API Gateway endpoint

• Mobile app back-end call

• CloudFront requests

• And many more…

Makes it easy to:

• Perform real-time data processing

• Build scalable back-end services

• Glue and choreograph systems

Page 8: NEW LAUNCH! Bringing AWS Lambda to the Edge

Benefits of AWS Lambda

Continuous

scaling

No servers to

manage

Never pay for idle

– no cold servers

(only happy

accountants)

Page 9: NEW LAUNCH! Bringing AWS Lambda to the Edge

…but all triggered from within

a single AWS region

Page 10: NEW LAUNCH! Bringing AWS Lambda to the Edge

Edge: AWS global network of

Points of Presence (POPs) on the

backbone of the Internet –

Amazon CloudFront

Page 11: NEW LAUNCH! Bringing AWS Lambda to the Edge

CloudFront: Global Content Delivery Network

Accelerate your application and APIs

Including static content such as images and video

Massively scalable

Highly secure

Self-service

Priced to minimize cost

Page 12: NEW LAUNCH! Bringing AWS Lambda to the Edge

Dynamic

StaticVideo

User

Input

SSL

CloudFront delivers ALL types of content

Page 13: NEW LAUNCH! Bringing AWS Lambda to the Edge

Without changing your back end…

ALB / ELB

Dynamic Content

Amazon EC2

Static Content

Amazon S3 Custom Origin

OR

OR

Custom OriginAmazon CloudFront

example.com

*.jpg

*.php

Page 14: NEW LAUNCH! Bringing AWS Lambda to the Edge

Imagine if you could run code at…

North America South America EMEA APAC

POPs

Cities Countries Continents

Regional Edge Caches

Page 15: NEW LAUNCH! Bringing AWS Lambda to the Edge

Putting it together: Lambda@Edge

Page 16: NEW LAUNCH! Bringing AWS Lambda to the Edge

Introducing Lambda@Edge

• Lambda@Edge is an extension of AWS Lambda that allows you to run

Node.js code at AWS global edge locations.

• Bring your own code to the edge and customize your content very close to

your users, improving the end-user experience.

Continuous

scaling No servers

to manage

Never pay for idle

– no cold serversGlobally

distributed

Page 17: NEW LAUNCH! Bringing AWS Lambda to the Edge

Write once, run everywhere

Page 18: NEW LAUNCH! Bringing AWS Lambda to the Edge

Current State of the World

Page 19: NEW LAUNCH! Bringing AWS Lambda to the Edge

CloudFront Triggers for Lambda@Edge

Functions

Page 20: NEW LAUNCH! Bringing AWS Lambda to the Edge

CloudFront Triggers for

Lambda@Edge Functions

Page 21: NEW LAUNCH! Bringing AWS Lambda to the Edge

What can Lambda@Edge do?

Page 22: NEW LAUNCH! Bringing AWS Lambda to the Edge

• User Properties – Identify a user’s location or what device they are using to select content accordingly (e.g., smaller images for mobile vs. desktop, selecting page language based on location)

• Client Device properties - Delete or modify headers to match protocols required by legacy end user devices

• Legacy TVs, networked printers

Content Customization

Page 23: NEW LAUNCH! Bringing AWS Lambda to the Edge

Visitor Validation

• Handing bots• Detect search engine bots and filter this

traffic from origin servers by displaying a

Captcha page

• Confirm valid sessions• View user-agent to confirm legitimacy of

request and add an access-control allow

header accordingly

• Validate access token to confirm

authentication status

Page 24: NEW LAUNCH! Bringing AWS Lambda to the Edge

Manage Multiple URLs

• Ad content - Rewrite URL from

request.jpg to request.html to show

image with contextual information

and relevant ads

• Pretty URLs – Avoid revealing your

origin directory structure and

introducing “ugly” complexity to URLs

Page 25: NEW LAUNCH! Bringing AWS Lambda to the Edge

A/B Testing

• “Flip a coin” to

select a version of

content displayed

to each user

• Set cookies to

ensure that users

continue to see the

right versions of

content

Page 26: NEW LAUNCH! Bringing AWS Lambda to the Edge

Demo Time!

Page 27: NEW LAUNCH! Bringing AWS Lambda to the Edge

Case Study: Cloudinary

Page 28: NEW LAUNCH! Bringing AWS Lambda to the Edge

Comprehensive Image and Video Management

Solution

API-based back end for web and mobile developers

Image & Video

Upload

Cloud

Storage

Image & Video

Transformations

Fast

Delivery

160K Developers 11B Managed Assets 2K Transformations/sec

Page 29: NEW LAUNCH! Bringing AWS Lambda to the Edge

Dynamic applicative decisions needed, but still use a global CDN

Image Delivery Challenges(Why is Dynamic Image CDN Important?)

Deliver the optimal image format, quality, and resolution

for every user, device, browser, graphic design, and responsive layout

Page 30: NEW LAUNCH! Bringing AWS Lambda to the Edge

Lambda @ Edge

URLRequest headers, Client Hints

Adapted URLAdapted request header

Best-fit manipulated imageCached image

Adaptation at the CDN of image manipulation request

Per-user and per-browser dynamic decision

Dynamic content negotiation and URL rewriting

Dynamic responsive images

Cloudinary Solution Using Lambda @ Edge

Page 31: NEW LAUNCH! Bringing AWS Lambda to the Edge

http://idemo-cf2.cloudinary.com/w_300,h_200,c_fill,q_90,f_auto/balloons.jpg

Same URL. Same great looking image. 30% bandwidth save!

30.3KB JPEG 23.5KB JPEG-XR21.3KB WebP

Dynamic Image Format Delivery For Every Browser

Page 32: NEW LAUNCH! Bringing AWS Lambda to the Edge

var width_step = 100;var requested_width = parseInt(request.headers["Width"]);var image_width =

Math.ceil(requested_width / width_step) * width_step;

3 lines of code using Lambda@Edge vs.

up to hundreds using configuration-based CDNs.

http://idemo-cf2.cloudinary.com/ar_16:9,c_fill,w_auto,dpr_auto/balloons.jpg

Auto responsive width

Auto device pixel ratio

Responsive Images Using Client Hints

Page 33: NEW LAUNCH! Bringing AWS Lambda to the Edge

192KB Eco mode

Save-Data: on

255KB High quality

Default mode

http://idemo-cf2.cloudinary.com/w_1500,h_1500,c_fill,q_auto/balloons.jpg

Dynamic Image Quality Encoding (with Automatic Mobile Sata Saving)

Same URL. Different Quality Levels. 30% bandwidth save!

Page 34: NEW LAUNCH! Bringing AWS Lambda to the Edge

● Adaptive media delivery based on user network quality

● Dynamic security settings and advanced media access control

● Dynamic image personalization

Looking Ahead

Page 35: NEW LAUNCH! Bringing AWS Lambda to the Edge

Lambda@Edge: Getting Started in

Preview

Page 36: NEW LAUNCH! Bringing AWS Lambda to the Edge

Recap – Using Lambda@Edge

Bring your own code

• Self-service through the

AWS Lambda console

Familiar programming

model

• Standard Node.js

Write once, run everywhere

• Automatically deployed to the AWS network

of 68 edge locations

• Requests are routed to the locations closest

to your end users across the world

Page 37: NEW LAUNCH! Bringing AWS Lambda to the Edge

Lambda@Edge Preview – Let’s get started

1. Sign up at this link: http://bit.ly/lambdaattheedge

2. Receive email whitelisting your Account ID – And you’re good to go!

Page 38: NEW LAUNCH! Bringing AWS Lambda to the Edge

Lambda@Edge Service Limits

Items Lambda@Edge Lambda

Timeouts 50 ms 300 seconds

Function “Power Level” 128 MB 128 MB – 1.5 GB

Function Deployment

Package Size

1MB 50MB

• Runtime: Node.js 4.3

• Triggered by CloudFront events

• Access: No network connections, AWS region access, disk access, or Amazon VPC

Page 39: NEW LAUNCH! Bringing AWS Lambda to the Edge

Lambda@Edge Pricing

Just as with Lambda today, Lambda@Edge is priced on two

dimensions:

• $0.60 per million function executions

• $0.00000625125 per second of execution duration (128 MB per function)

For example, 10 million executions, 50 ms each time

• Total charges = Compute charges (10M * 0.05sec * $0.00000625125 =

$3.13) + Request charges (10M * $0.6/M = $6.00) = $3.13 + $6.00 = $9.13

per month

Page 40: NEW LAUNCH! Bringing AWS Lambda to the Edge

What can Lambda@Edge do?

We have more functionality that we are considering adding to

the product, but we look forward to your feedback in prioritizing

what comes next!

Page 41: NEW LAUNCH! Bringing AWS Lambda to the Edge

Thank you!

Page 42: NEW LAUNCH! Bringing AWS Lambda to the Edge

Remember to complete

your evaluations!