41
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Nihar Bihani, Senior Manager Product Management, Amazon CloudFront Meena Vembusubramanian, Senior Product Manager, Amazon CloudFront December 16, 2016 Bringing AWS Lambda to the Edge (Lambda@Edge Preview)

Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Embed Size (px)

Citation preview

Page 1: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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

Nihar Bihani, Senior Manager Product Management, Amazon CloudFront

Meena Vembusubramanian, Senior Product Manager, Amazon CloudFront

December 16, 2016

Bringing AWS Lambda to the Edge

(Lambda@Edge Preview)

Page 2: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

AWS Lambda:

Evolution of Cloud Compute

towards Serverless

Page 4: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Evolution of Compute – Public Cloud

InfrastructureInstances

Application code

Page 5: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Evolution of Compute – Containers

InfrastructureInstances

Application codeContainers

Page 6: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Evolution of Compute – Serverless

Application code

Page 7: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Benefits of AWS Lambda

Continuous

scaling

No servers to

manage

Never pay for idle

– no cold servers

(only happy

accountants)

Page 9: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

…but all triggered from within

a single AWS region

Page 10: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Edge: AWS global network

of Points of Presence (POPs)

on the backbone of the Internet –

Amazon CloudFront

Page 11: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Dynamic

StaticVideo

User

Input

SSL

CloudFront delivers ALL types of content

Page 13: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Without changing your back end…

ALB / ELB

Dynamic Content

Amazon EC2

Static Content

Amazon S3 Custom

Origin

OR

OR

Custom

Origin

Amazon CloudFront

example.com *.jpg

*.php

Page 14: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

North America South America EMEA APAC

POPs

Cities Countries Continents

Regional Edge Caches

Imagine if you could run code at…

Page 15: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Putting it together: Lambda@Edge

Page 16: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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 servers

Globally

distributed

Page 17: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Write once, run everywhere

Page 18: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Current State of the World

ALB / ELB

Dynamic Content

Amazon EC2

Static Content

Amazon S3 Custom

Origin

OR

OR

Custom

Origin

Amazon CloudFront

example.com*.jpg

*.php

Page 19: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

ALB / ELB

Dynamic Content

Amazon EC2

Static Content

Amazon S3 Custom

Origin

OR

OR

Custom

Origin

*.jpg

*.php

CloudFront Triggers for Lambda@Edge Functions

Amazon CloudFront

example.com

Page 20: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

CloudFront Triggers for Lambda@Edge Functions

Page 21: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

What can Lambda@Edge do?

Page 22: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Demo Time!

Page 27: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Case Study: Cloudinary

Page 28: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Dynamic applicative decisions needed, but still use a global CDN

Deliver the optimal image format, quality, and resolution

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

Image Delivery Challenges

(Why is Dynamic Image CDN Important?)

Page 30: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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

(with Automatic Mobile Sata Saving)

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

Dynamic Image Quality Encoding

Page 34: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Adaptive media delivery based on user network quality

Dynamic security settings and advanced media access control

Dynamic image personalization

Looking Ahead

Page 35: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Lambda@Edge: Getting Started

in Preview

Page 36: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series
Page 37: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

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: Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series

Thank you!