CloudFront is Amazon's content delivery network (CDN) that can accelerate content delivery, improve performance and protect origins from traffic spikes. It has points of presence in over 100 locations globally. Lambda@Edge allows running Lambda functions at the edge of the CloudFront network to modify requests and responses. This allows things like dynamic content generation, authorization checks, A/B testing and more to occur closer to users for faster performance.
14. Globally
distributed
Scales with usage Never pay for idle Built-in availability
and fault tolerance
Bring your own code to the edge to improve user experience
Lambda@Edge
No servers to provision
or manage
15. Write once, run Lambda functions globally
N Virginia
AWS Location
AWS Location
AWS Location
AWS Location
AWS Location
AWS Location
17. Lambda@Edge
Content-based routing
to any origin
Response generation
• Generate custom responses at the
edge
• Read and write access to headers,
query string, and cookies
Network calls
• Origin events
• Viewer events
18. Lambda vs Lambda@Edge
Lambda Lambda@Edge
Languages Node.js, Python, C#, Java Node.js
Memory 128->1536MB 128MB
Execution time <300 seconds <3 seconds (Origin-facing)
<1 seconds (Viewer-facing)
Deployment size <50MB <1MB
Request pricing First 1 million free
$0.20 per 1 million
$0.60 per 1 million
Duration
granularity
100ms 50ms
128MB for 100ms $0.000000208 $0.000000625
25. Usecases – A/B Testing
Test your theory on a proportion of users
Measure valuable metric (social likes/shares, engagement,
purchases, etc)
Implement findings
26. Usecases: Origin request, Origin selection
id user
1 alex
2 bob
3 joe
4 jane
User database
200 OK
Application
User Agent
POST /login
user=jane&pass=***
home-region
na
eu
ap
eu
Set-Cookie: home-region=eu
27. User Agent CloudFront distribution
www.example.com
North America
origin
User DB
Cache Behavior
/login
North America
app DB
hom
e-region=na ?
Europe origin Europe app DB
home-region=eu ?
APAC origin APAC app DB
home-region=ap ?
Cache Behavior
/app
Origin Request
Event
Set-Cookie
Usecases: Origin request, Origin selection
29. CloudFront
CDN’s are good!
• They protect origins from load
• Accelerate static and dynamic content (websites, APIs)
• Scalable and Global
• Cache content closer to the user
• Support HTTP/2 and IPv6