Upload
amazon-web-services
View
554
Download
2
Embed Size (px)
Citation preview
© 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)
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)
AWS Lambda:
Evolution of Cloud Compute
towards Serverless
Evolution of Compute – Public Cloud
InfrastructureInstances
Application code
Evolution of Compute – Containers
InfrastructureInstances
Application codeContainers
Evolution of Compute – Serverless
Application code
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
Benefits of AWS Lambda
Continuous
scaling
No servers to
manage
Never pay for idle
– no cold servers
(only happy
accountants)
…but all triggered from within
a single AWS region
Edge: AWS global network
of Points of Presence (POPs)
on the backbone of the Internet –
Amazon CloudFront
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
Dynamic
StaticVideo
User
Input
SSL
CloudFront delivers ALL types of content
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
North America South America EMEA APAC
POPs
Cities Countries Continents
Regional Edge Caches
Imagine if you could run code at…
Putting it together: Lambda@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 servers
Globally
distributed
Write once, run everywhere
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
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
CloudFront Triggers for Lambda@Edge Functions
What can Lambda@Edge do?
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
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
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
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
Demo Time!
Case Study: Cloudinary
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
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?)
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
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
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
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
Adaptive media delivery based on user network quality
Dynamic security settings and advanced media access control
Dynamic image personalization
Looking Ahead
Lambda@Edge: Getting Started
in Preview
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!
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
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
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!
Thank you!