SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Alec Peterson, GM Amazon CloudFront
July 27, 2017
Deep Dive on Accelerating Content,
APIs, and Applications with Amazon
CloudFront and Lambda@Edge
What to expect from this session
• Amazon CloudFront and AWS Lambda
• Lambda@Edge
• Getting started with Lambda@Edge
AWS Core Services
Compute
Storage
Database
Edge
Edge Services: A core infrastructure component
Users can access
application
resources directly
Customer
Application
Edge services include
CloudFront, Route 53,
AWS WAF, AWS Shield,
AWS Elemental
AWS Core Services
Edge Services: A core infrastructure component
Users can access application resources
through the Edge to secure, scale, and
optimize applications
Compute
Storage
Database
Edge
Customer
Application
AND/OR
Edge: AWS global network of
points of presence (POPs) on the
backbone of the Internet –
Amazon CloudFront
79 Edge locations
11 regional Edge caches
48 cities
21 countries
5 continents
79 Edge locations + 11 regional Edge caches
CloudFront: Global content delivery network
 Accelerate your application and APIs
 Include static content such as images and video
 Massively scalable
 Highly secure
 Self-service
 Priced to minimize cost
Dynamic
Static
Video
User
input
SSL/TLS
CloudFront delivers ALL types of content
Without having to change your backend…
ALB/ELB
Dynamic content
Amazon EC2
Static content
Amazon S3 Custom origin
OR
OR
Custom origin
Amazon CloudFront
example.com
*.jpg
*.php
AWS Lambda: Serverless
Computing
Traditional programming model
• A persistent process that
processes events
• Handles message queue and
network connections
• Code includes ‘event handling’
AND logic to process the event
• Developer manages server
infrastructure for application
• Developer owns forecasting
demand and scaling
• Revolves around an event
source
• E.g., CloudFront request
or Amazon S3 PUT
• Your code is only the event
handling code itself
• No servers to manage
• Scaling is all managed by
AWS
Serverless programming model
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 backend call
• CloudFront requests
• And many more…
Makes it easy to:
• Perform real-time data processing
• Build scalable backend 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)
Lambda programming model – sync vs. async
• Synchronous
• Execution is serialized with the requesting event
• End viewer can depend on function execution –
the result of the execution may be used to
influence the requesting event
• All existing Lambda@Edge events are
synchronous
• Asynchronous
• Execution is parallelized with the requesting event
• The result of the Lambda execution may not be
used to influence the requesting event
• E.g., batch processing of logs and responding to
an Amazon S3 object PUT
AWS Lambda@Edge:
Serverless Edge Computing
Introducing Lambda@Edge
• Lambda@Edge is an extension of AWS Lambda that allows you to run
Node.js code at global AWS locations
• Bring your own code to the Edge and customize your content very close to
your users, improving end-user experience
Continuous
scaling
No servers
to manage
Never pay for idle
– no cold servers
Globally
distributed
CloudFront triggers for Lambda@Edge
functions
CloudFront triggers for Lambda@Edge
functions
CloudFront cache
End user
Origin
server
Viewer request Origin request
Origin responseViewer response
Lambda@Edge events
• All Lambda@Edge invocations are synchronous
• Request events
• URI and header modifications can change the object being requested
• Viewer request can change the object being requested from the CloudFront
cache and the origin
• Origin request can change the object or path pattern being requested from the
origin
• Response events
• Origin response can modify what is cached and generate cacheable responses
to be returned to the viewer
• Viewer response can change what is returned to the viewer
CloudFront
cache
End user Origin
server
Viewer request Origin request
Origin responseViewer response
Write once, run everywhere
AWS
Location
AWS
Location
AWS
Location
AWS
Location
Origin server
AWS
Location
Lambda@Edge functionality
• Read and write access to headers, URIs, and
cookies across all triggers
• Ability to generate custom responses from
scratch
• Access to make network calls to external
resources on origin-facing hooks
Lambda@Edge event structure
{
"Records": [ {
"cf": {
"config": {
"distributionId": "EDFDVBD6EXAMPLE"
},
"request": {
"clientIp": "2001:0db8:85a3:0:0:8a2e:0370:7334",
"method": "GET",
"uri": "/picture.jpg",
"headers": {
"host": [ {
"key": "Host",
"value": "d111111abcdef8.cloudfront.net"
} ],
"user-agent": [ {
"key": "User-Agent",
"value": "curl/7.51.0"
} ]
}
}
]
}
Request and distribution
information
Event data – headers,
clientIP, user agent
Lambda@Edge function structure
'use strict';
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
// No-op
callback(null, request);
return;
}
So, what can I do with
Lambda@Edge?
Highly personalized websites
• Redirect viewers to the optimal
experience based on their location,
language preferences, and device type
Highly personalized websites – how?
• Trigger: Viewer request
• Inputs
• Requested URL
• Device type (i.e., User-Agent)
• Existing session data
• Output
• Generate a response directly from Lambda@Edge,
specifically a redirect to the most relevant experience (e.g. ,
cropped images and mobile sites for mobile users)
Pretty URLs
• Rewrite the URL end user's request
to serve content without exposing
your team’s internal directory
structure and organization
• Provide customized experiences
without compromising consistency in
what your viewers see
Pretty URLs – how?
• Trigger: Origin request
• Inputs
• URL requested
• Outputs
• Rewrite the requested URL, which will be passed to the origin
• The response will be cached based on what the customer
requested to serve subsequent requests (i.e., the pretty URL)
Authorization at the Edge
• Inspect cookies or custom headers to
authenticate clients right at the edge
• Enforce paywalls at the Edge to gate
access to premium content to only
authenticated viewers
Authorization at the Edge – how?
• Trigger: Viewer request
• Prerequisites
• The customer must have previously authenticated against your authoritative
service, resulting in some sort of authorization credential. Typically this is a
cookie.
• Inputs
• URL
• Authorization credential (cookie)
• Outputs
• Allow the request to succeed if the request is authorized. If not, either return
a 403 response or redirect to an authentication page
A/B testing
• ‘Flip a coin’ to select a
version of content
displayed to each user
on an asset level
• Set cookies to ensure
that users continue to
see the right versions
of content
A/B testing – how?
• Trigger: Viewer request
• Inputs
• URL
• Cookies
• Outputs
• If the A/B testing cookie is set, rewrite the requested URI to
be the correct content version
• If it is not set, flip a coin and set the cookie accordingly.
Limited access to content
• Enforce timed access to content
at the edge
• Make a call to an external
authentication server to confirm
if a user’s session is still valid
• Forward valid requests to the
origin, and serve redirects to
new users to login pages
Limited content access – How?
• Trigger: Origin request
• Inputs
• URL/cookies
• Access to external user-tracking database
• Outputs
• If a customer requests content for specific URLs or with
specific cookies, make a request to the external server to
confirm session validity.
• Based on response from external server, serve content, or
redirect to a login page.
Response generation at the Edge
Generate an HTTP response to end
user requests arriving at AWS locations:
• Generate customized error pages
and static websites directly from Edge
locations
• Combine content drawn from multiple
external resources to dynamically
build websites at the Edge
Response generation – how?
• Viewer or origin request event
• Inputs
• URI
• Headers
• Outputs
• Custom response based on URI and headers
Let’s see it in action
Demo Time!
Lambda@Edge: Getting Started
Lambda@Edge pricing
Just as with Lambda today, Lambda@Edge is priced on two
dimensions:
• $0.60 / million function executions
• $0.0225 per hour of execution duration (128 MB per function, metered at
50ms granularity)
For example - 10 million executions, 50ms each time
• Total charges = Compute charges (10M * 0.05 sec * ($0.0225 / 3600) =
$3.13) + Request charges (10M * $0.6/M = $6.00) = $3.13 + $6.00 = $9.13
per month
Recap – using Lambda@Edge
Bring your own code
• Self-service through the
Lambda console
Familiar programming
model
• Standard Node.js-6.10
Write once, run everywhere
• Automatically deployed to the AWS network
of 79 Edge locations
• Requests are routed to the locations closest
to your end users across the world
Functionalities:
- Modify response header
- CloudFront response generation
- CloudFront HTTP redirect
- A/B testing
Benefits:
- Simple remote call at origin-facing hooks
- Cacheable static content generation
- Content generation with remote calls
Lambda@Edge – let’s get started
• Sign up: https://aws.amazon.com/lambda/edge
Thank you!
Remember to complete
your evaluations!

Weitere ähnliche Inhalte

Was ist angesagt?

Automate Migration to AWS with Datapipe
Automate Migration to AWS with DatapipeAutomate Migration to AWS with Datapipe
Automate Migration to AWS with Datapipe
Amazon Web Services
 

Was ist angesagt? (20)

Advanced Techniques for Federation of the AWS Management Console and Command ...
Advanced Techniques for Federation of the AWS Management Console and Command ...Advanced Techniques for Federation of the AWS Management Console and Command ...
Advanced Techniques for Federation of the AWS Management Console and Command ...
 
Security Best Practices
Security Best PracticesSecurity Best Practices
Security Best Practices
 
Build on AWS: Delivering and Modernizing.
Build on AWS: Delivering and Modernizing. Build on AWS: Delivering and Modernizing.
Build on AWS: Delivering and Modernizing.
 
Cost Optimisation on AWS
Cost Optimisation on AWSCost Optimisation on AWS
Cost Optimisation on AWS
 
ENT302 Deep Dive on AWS Management Tools and New Launches
ENT302 Deep Dive on AWS Management Tools and New LaunchesENT302 Deep Dive on AWS Management Tools and New Launches
ENT302 Deep Dive on AWS Management Tools and New Launches
 
Introduction to CloudFront
Introduction to CloudFrontIntroduction to CloudFront
Introduction to CloudFront
 
Design, Deploy, and Optimize SQL Server on AWS - June 2017 AWS Online Tech Talks
Design, Deploy, and Optimize SQL Server on AWS - June 2017 AWS Online Tech TalksDesign, Deploy, and Optimize SQL Server on AWS - June 2017 AWS Online Tech Talks
Design, Deploy, and Optimize SQL Server on AWS - June 2017 AWS Online Tech Talks
 
HSBC and AWS Day - Security Identity and Access Management
HSBC and AWS Day - Security Identity and Access ManagementHSBC and AWS Day - Security Identity and Access Management
HSBC and AWS Day - Security Identity and Access Management
 
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech TalksDeep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
 
AWS re:Invent 2016: Driving Innovation with Big Data and IoT (GPSST304)
AWS re:Invent 2016: Driving Innovation with Big Data and IoT (GPSST304)AWS re:Invent 2016: Driving Innovation with Big Data and IoT (GPSST304)
AWS re:Invent 2016: Driving Innovation with Big Data and IoT (GPSST304)
 
Amazon Cloudfront
Amazon CloudfrontAmazon Cloudfront
Amazon Cloudfront
 
Content Delivery Using Amazon CloudFront - AWS Presentation - John Mancuso
Content Delivery Using Amazon CloudFront - AWS Presentation - John MancusoContent Delivery Using Amazon CloudFront - AWS Presentation - John Mancuso
Content Delivery Using Amazon CloudFront - AWS Presentation - John Mancuso
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
Automate Migration to AWS with Datapipe
Automate Migration to AWS with DatapipeAutomate Migration to AWS with Datapipe
Automate Migration to AWS with Datapipe
 
AWS Enterprise Summit Netherlands - Big Data Architectural Patterns & Best Pr...
AWS Enterprise Summit Netherlands - Big Data Architectural Patterns & Best Pr...AWS Enterprise Summit Netherlands - Big Data Architectural Patterns & Best Pr...
AWS Enterprise Summit Netherlands - Big Data Architectural Patterns & Best Pr...
 
Build a Website on AWS for Your First 10 Million Users
Build a Website on AWS for Your First 10 Million UsersBuild a Website on AWS for Your First 10 Million Users
Build a Website on AWS for Your First 10 Million Users
 
Jumpstart Your Digital Journey
Jumpstart Your Digital JourneyJumpstart Your Digital Journey
Jumpstart Your Digital Journey
 
The Best of re:invent 2016
The Best of re:invent 2016The Best of re:invent 2016
The Best of re:invent 2016
 
Big Data Architectural Patterns and Best Practices on AWS
Big Data Architectural Patterns and Best Practices on AWSBig Data Architectural Patterns and Best Practices on AWS
Big Data Architectural Patterns and Best Practices on AWS
 
AWS re:Invent 2016: Tips for Building Successful Solutions with AWS Marketpla...
AWS re:Invent 2016: Tips for Building Successful Solutions with AWS Marketpla...AWS re:Invent 2016: Tips for Building Successful Solutions with AWS Marketpla...
AWS re:Invent 2016: Tips for Building Successful Solutions with AWS Marketpla...
 

Ähnlich wie SRV418 Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFront and Lambda@Edge

Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 

Ähnlich wie SRV418 Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFront and Lambda@Edge (20)

Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
 
Building Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech TalksBuilding Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech Talks
 
NEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeNEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the Edge
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
 
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
 
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API GatewayStephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
 
Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017
 
Lambdaless and AWS CDK
Lambdaless and AWS CDKLambdaless and AWS CDK
Lambdaless and AWS CDK
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
AWS re:Invent 2016: Born in the Cloud; Built Like a Startup (ARC205)
AWS re:Invent 2016: Born in the Cloud; Built Like a Startup (ARC205)AWS re:Invent 2016: Born in the Cloud; Built Like a Startup (ARC205)
AWS re:Invent 2016: Born in the Cloud; Built Like a Startup (ARC205)
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
 
Build and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API Gateway
 
saa3_wk5.pdf
saa3_wk5.pdfsaa3_wk5.pdf
saa3_wk5.pdf
 
Maximizing Audience Engagement in Media Delivery (MED303) | AWS re:Invent 2013
Maximizing Audience Engagement in Media Delivery (MED303) | AWS re:Invent 2013Maximizing Audience Engagement in Media Delivery (MED303) | AWS re:Invent 2013
Maximizing Audience Engagement in Media Delivery (MED303) | AWS re:Invent 2013
 
AWS Community Day Bangkok 2019 - Build a Serverless Web Application in 30 mins
AWS Community Day Bangkok 2019 - Build a Serverless Web Application in 30 minsAWS Community Day Bangkok 2019 - Build a Serverless Web Application in 30 mins
AWS Community Day Bangkok 2019 - Build a Serverless Web Application in 30 mins
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Build an App on AWS for Your First 10 Million Users
Build an App on AWS for Your First 10 Million UsersBuild an App on AWS for Your First 10 Million Users
Build an App on AWS for Your First 10 Million Users
 
Being Well Architected in the Cloud (Updated)
Being Well Architected in the Cloud (Updated)Being Well Architected in the Cloud (Updated)
Being Well Architected in the Cloud (Updated)
 
Being Well-Architected in the Cloud
Being Well-Architected in the CloudBeing Well-Architected in the Cloud
Being Well-Architected in the Cloud
 

Mehr von Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Mehr von Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 
Come costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSCome costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWS
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

SRV418 Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFront and Lambda@Edge

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Alec Peterson, GM Amazon CloudFront July 27, 2017 Deep Dive on Accelerating Content, APIs, and Applications with Amazon CloudFront and Lambda@Edge
  • 2. What to expect from this session • Amazon CloudFront and AWS Lambda • Lambda@Edge • Getting started with Lambda@Edge
  • 3. AWS Core Services Compute Storage Database Edge Edge Services: A core infrastructure component Users can access application resources directly Customer Application Edge services include CloudFront, Route 53, AWS WAF, AWS Shield, AWS Elemental
  • 4. AWS Core Services Edge Services: A core infrastructure component Users can access application resources through the Edge to secure, scale, and optimize applications Compute Storage Database Edge Customer Application AND/OR
  • 5. Edge: AWS global network of points of presence (POPs) on the backbone of the Internet – Amazon CloudFront
  • 6. 79 Edge locations 11 regional Edge caches 48 cities 21 countries 5 continents 79 Edge locations + 11 regional Edge caches
  • 7. CloudFront: Global content delivery network  Accelerate your application and APIs  Include static content such as images and video  Massively scalable  Highly secure  Self-service  Priced to minimize cost
  • 9. Without having to change your backend… ALB/ELB Dynamic content Amazon EC2 Static content Amazon S3 Custom origin OR OR Custom origin Amazon CloudFront example.com *.jpg *.php
  • 11. Traditional programming model • A persistent process that processes events • Handles message queue and network connections • Code includes ‘event handling’ AND logic to process the event • Developer manages server infrastructure for application • Developer owns forecasting demand and scaling • Revolves around an event source • E.g., CloudFront request or Amazon S3 PUT • Your code is only the event handling code itself • No servers to manage • Scaling is all managed by AWS Serverless programming model
  • 12. 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 backend call • CloudFront requests • And many more… Makes it easy to: • Perform real-time data processing • Build scalable backend services • Glue and choreograph systems
  • 13. Benefits of AWS Lambda Continuous scaling No servers to manage Never pay for idle – no cold servers (only happy accountants)
  • 14. Lambda programming model – sync vs. async • Synchronous • Execution is serialized with the requesting event • End viewer can depend on function execution – the result of the execution may be used to influence the requesting event • All existing Lambda@Edge events are synchronous • Asynchronous • Execution is parallelized with the requesting event • The result of the Lambda execution may not be used to influence the requesting event • E.g., batch processing of logs and responding to an Amazon S3 object PUT
  • 16. Introducing Lambda@Edge • Lambda@Edge is an extension of AWS Lambda that allows you to run Node.js code at global AWS locations • Bring your own code to the Edge and customize your content very close to your users, improving end-user experience Continuous scaling No servers to manage Never pay for idle – no cold servers Globally distributed
  • 17. CloudFront triggers for Lambda@Edge functions
  • 18. CloudFront triggers for Lambda@Edge functions CloudFront cache End user Origin server Viewer request Origin request Origin responseViewer response
  • 19. Lambda@Edge events • All Lambda@Edge invocations are synchronous • Request events • URI and header modifications can change the object being requested • Viewer request can change the object being requested from the CloudFront cache and the origin • Origin request can change the object or path pattern being requested from the origin • Response events • Origin response can modify what is cached and generate cacheable responses to be returned to the viewer • Viewer response can change what is returned to the viewer CloudFront cache End user Origin server Viewer request Origin request Origin responseViewer response
  • 20. Write once, run everywhere AWS Location AWS Location AWS Location AWS Location Origin server AWS Location
  • 21. Lambda@Edge functionality • Read and write access to headers, URIs, and cookies across all triggers • Ability to generate custom responses from scratch • Access to make network calls to external resources on origin-facing hooks
  • 22. Lambda@Edge event structure { "Records": [ { "cf": { "config": { "distributionId": "EDFDVBD6EXAMPLE" }, "request": { "clientIp": "2001:0db8:85a3:0:0:8a2e:0370:7334", "method": "GET", "uri": "/picture.jpg", "headers": { "host": [ { "key": "Host", "value": "d111111abcdef8.cloudfront.net" } ], "user-agent": [ { "key": "User-Agent", "value": "curl/7.51.0" } ] } } ] } Request and distribution information Event data – headers, clientIP, user agent
  • 23. Lambda@Edge function structure 'use strict'; exports.handler = (event, context, callback) => { const request = event.Records[0].cf.request; // No-op callback(null, request); return; }
  • 24. So, what can I do with Lambda@Edge?
  • 25. Highly personalized websites • Redirect viewers to the optimal experience based on their location, language preferences, and device type
  • 26. Highly personalized websites – how? • Trigger: Viewer request • Inputs • Requested URL • Device type (i.e., User-Agent) • Existing session data • Output • Generate a response directly from Lambda@Edge, specifically a redirect to the most relevant experience (e.g. , cropped images and mobile sites for mobile users)
  • 27. Pretty URLs • Rewrite the URL end user's request to serve content without exposing your team’s internal directory structure and organization • Provide customized experiences without compromising consistency in what your viewers see
  • 28. Pretty URLs – how? • Trigger: Origin request • Inputs • URL requested • Outputs • Rewrite the requested URL, which will be passed to the origin • The response will be cached based on what the customer requested to serve subsequent requests (i.e., the pretty URL)
  • 29. Authorization at the Edge • Inspect cookies or custom headers to authenticate clients right at the edge • Enforce paywalls at the Edge to gate access to premium content to only authenticated viewers
  • 30. Authorization at the Edge – how? • Trigger: Viewer request • Prerequisites • The customer must have previously authenticated against your authoritative service, resulting in some sort of authorization credential. Typically this is a cookie. • Inputs • URL • Authorization credential (cookie) • Outputs • Allow the request to succeed if the request is authorized. If not, either return a 403 response or redirect to an authentication page
  • 31. A/B testing • ‘Flip a coin’ to select a version of content displayed to each user on an asset level • Set cookies to ensure that users continue to see the right versions of content
  • 32. A/B testing – how? • Trigger: Viewer request • Inputs • URL • Cookies • Outputs • If the A/B testing cookie is set, rewrite the requested URI to be the correct content version • If it is not set, flip a coin and set the cookie accordingly.
  • 33. Limited access to content • Enforce timed access to content at the edge • Make a call to an external authentication server to confirm if a user’s session is still valid • Forward valid requests to the origin, and serve redirects to new users to login pages
  • 34. Limited content access – How? • Trigger: Origin request • Inputs • URL/cookies • Access to external user-tracking database • Outputs • If a customer requests content for specific URLs or with specific cookies, make a request to the external server to confirm session validity. • Based on response from external server, serve content, or redirect to a login page.
  • 35. Response generation at the Edge Generate an HTTP response to end user requests arriving at AWS locations: • Generate customized error pages and static websites directly from Edge locations • Combine content drawn from multiple external resources to dynamically build websites at the Edge
  • 36. Response generation – how? • Viewer or origin request event • Inputs • URI • Headers • Outputs • Custom response based on URI and headers
  • 37. Let’s see it in action Demo Time!
  • 39. Lambda@Edge pricing Just as with Lambda today, Lambda@Edge is priced on two dimensions: • $0.60 / million function executions • $0.0225 per hour of execution duration (128 MB per function, metered at 50ms granularity) For example - 10 million executions, 50ms each time • Total charges = Compute charges (10M * 0.05 sec * ($0.0225 / 3600) = $3.13) + Request charges (10M * $0.6/M = $6.00) = $3.13 + $6.00 = $9.13 per month
  • 40. Recap – using Lambda@Edge Bring your own code • Self-service through the Lambda console Familiar programming model • Standard Node.js-6.10 Write once, run everywhere • Automatically deployed to the AWS network of 79 Edge locations • Requests are routed to the locations closest to your end users across the world Functionalities: - Modify response header - CloudFront response generation - CloudFront HTTP redirect - A/B testing Benefits: - Simple remote call at origin-facing hooks - Cacheable static content generation - Content generation with remote calls
  • 41. Lambda@Edge – let’s get started • Sign up: https://aws.amazon.com/lambda/edge