This session introduces Lambda@Edge, a new AWS Lambda feature that allows developers to perform simple computations at AWS edge locations in response to CloudFront events. This will be of interest to developers who want to build low-latency, customized web experiences. We cover product functionality and details of the programming model, and we walk through potential use cases.
2. 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)
7. 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
8. Benefits of AWS Lambda
Continuous
scaling
No servers to
manage
Never pay for idle
– no cold servers
(only happy
accountants)
10. Edge: AWS global network of
Points of Presence (POPs) on the
backbone of the Internet –
Amazon CloudFront
11. 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
16. 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
22. • 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
23. 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
24. 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
25. 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
28. 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 11BManaged Assets 2K Transformations/sec
29. 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
30. Lambda @ Edge
URL
Request headers, Client Hints
Adapted URL
Adapted 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
32. 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
33. 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!
34. ● Adaptive media delivery based on user network quality
● Dynamic security settings and advanced media access control
● Dynamic image personalization
Looking Ahead
36. 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
37. 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!
38. 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
39. 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
40. 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!