Traditionally, content delivery networks (CDNs) were known to accelerate static content. Amazon CloudFront has come a long way and now supports delivery of entire websites that include dynamic and static content. In this session, we introduce you to CloudFront dynamic delivery features that help improve the performance, scalability and availability of your website, while helping you lower your costs. In this session we will talk about architectural patterns such as SSL termination, close proximity connection termination, origin offload with keep-alive connections and last-mile latency improvement. You will also learn how to take advantage of Amazon Route 53 health check, automatic failover and latency-based routing to build highly available web apps on AWS.
5. Why Don’t Customers Use CDNs for Dynamic Content?
I don’t see the value - each request is unique and must go
back to the origin web server.
I see the value, but my current CDN charges premium rates
for dynamic content acceleration, with many additional fees.
Configuring a CDN for dynamic content acceleration requires
expensive professional services and is not self-service.
6. Re-Usable or Unique Content?
• Static or Re-Usable
– A given content where the state of the content does NOT change for
a given period of time.
t
0
t
1
7. Re-Usable or Unique Content?
• Dynamic or Unique
– A given content where the state of the content changes as soon as it
gets created.
t
0
t
1
23. Optimizing Static Content with Caching
OR
Amazon S3 Custom
User request B Edge location
Origin
Get image
24. Optimizing Static Content with Caching
OR
Amazon S3 Custom
User request B Edge location
Origin
Get image
Image
25. Optimizing Static Content with Caching
• Bring content closer to the users
• Improves the experience and performance
• Offloads your infrastructure
29. Optimizing Static Content with Caching
• Cache as much as you can.
• How? I’m caching all my images, CSS, and JS.
• Find cacheable content.
– Collect web (w3c) logs from your web-tier
– Run a report on your logs (EMR, RDS, or Redshift)
– Identify top N URLs
30. Optimizing Static Content with Caching
• Steps to find cacheable content
– Example query
Select count(url) count, url
from logs_table
Group by url sort by count;
32. Re-Usable or Unique Content?
• Static or Re-Usable
– A given content where the state of the content does NOT change for
a given period of time.
t
0
t
1
33. Caching for Smaller Time Units
• Goal: find content that can be cached for any given period
of time.
– Hours
– Minutes
– Seconds
• CloudFront can cache content for any period of time.
34. Optimizing Static Content with Caching
• Content with query strings
110 /factor/create_image?name=book1&size=10x10
• Reusable?
• CloudFront can cache content with query strings.
• Every unique query-string combination is a new object in
CloudFront’s cache.
35. Optimizing Static Content with Caching
• API calls
100 /api/GetBooks?category=math
• Reusable?
• CloudFront can cache content with query strings.
• Every unique query-string combination is a new object in
CloudFront’s cache.
36. Caching for Smaller Time Units
100 /api/GetBooks?category=math
• Imagine your have a read heavy API GETS hit 100 or 1,000
RPS.
• Offload your web-tier from handling 1,000 RPS.
• Offload your load balancer; Elastic Load Balancing or any
other LB.
• Provision less capacity and reduce costs.
37. Caching Personalized Content
• Optionally configure CloudFront to forward request headers to
your origin.
• Enables caching for personalized content:
• Mobile Device Detection
• Geo Targeting
• Multi-Site Hosting
• Cross Origin Resource Sharing (CORS)
• Protocol Detection
• Cookies
41. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
42. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
43. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
44. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
Response
45. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
Response
46. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
47. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
48. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
49. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
Response
50. OR
Amazon S3 Custom
Optimizing Dynamic Content
User request A
Edge location
Origin
User request B
Get
Response
51. Optimizing Dynamic Content
• Can dynamic content be optimized?
– That adds latency?
– How to optimize dynamic content?
– Response time =
Σ Time (DNS + Connection + First Byte + Content Download)
DNS lookup
TCP connection Content download
Time to first byte
52. Faster Response Time =
Reduced DNS Time
+
Reduced Connection Time
+
Reduced First Byte Time
+
Reduced Content Download Time
Optimizing Dynamic Content
53. Faster Response Time =
Reduced DNS Time
+
Reduced Connection Time
+
Reduced First Byte Time
+
Reduced Content Download Time
Optimizing Dynamic Content
54. Keep-Alive connections
& SSL termination
Faster Response Time =
Reduced DNS Time
+
Reduced Connection Time
+
Reduced First Byte Time
+
Reduced Content Download Time
Optimizing Dynamic Content
55. Optimizing Dynamic Content
Keep-Alive connections
& SSL termination
Faster Response Time =
Reduced DNS Time
+
Reduced Connection Time
+
Reduced First Byte Time
+
Reduced Content Download Time
Keep-Alive connections
56. Optimizing Dynamic Content
Keep-Alive connections
& SSL termination
Faster Response Time =
Reduced DNS Time
+
Reduced Connection Time
+
Reduced First Byte Time
+
Reduced Content Download Time
Keep-Alive connections
TCP/IP optimization
61. Optimizing TCP Connections and First Byte
• How to optimize TCP connections?
– with CloudFront Keep Alive connections.
TCP connection
Amazon CloudFront
Keep-Alive Connections
62. Optimizing TCP Connections
• TCP/IP handshake
– HTTP runs on TCP/IP
– TCP has the concept of TCP handshake
– Every HTTP connection has to complete TCP handshake
– TCP/IP handshake penalizes dynamic content
66. Two Users without CloudFront
SYN
SYN-ACK
ACK
GET /index.jsp
90ms
Region
67. Two Users without CloudFront
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
90ms
Region
68. Two Users without CloudFront
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
90ms
Region
69. Two Users without CloudFront
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
90ms
Region
70. Two Users without CloudFront
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
ACK
GET /index.jsp
90ms
Region
360ms
71. Without CloudFront
• Every user is a new connection.
• More users = more TCP connections.
Region
72. Without CloudFront
• Every user is a new connection.
• More users = more TCP connections.
Region
73. Without CloudFront
• Every user is a new connection.
• More users = more TCP connections.
Region
74. Without CloudFront
• Every user is a new connection.
• More users = more TCP connections.
Region
75. Optimizing TCP Connections
• Without Keep-Alive connections
– Puts load on memory/CPU
– Puts load on your web servers
– Load on your web servers, increases the time to first byte.
76. Two Users with CloudFront Keep-Alive
SYN
30ms 60ms
Region
77. Two Users with CloudFront Keep-Alive
SYN
SYN-ACK
30ms 60ms
Region
78. Two Users with CloudFront Keep-Alive
SYN
SYN-ACK
ACK
GET /index.jsp
30ms 60ms
Region
79. Two Users with CloudFront Keep-Alive
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
30ms 60ms
Region
80. Two Users with CloudFront Keep-Alive
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
30ms 60ms
Region
81. Two Users with CloudFront Keep-Alive
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
ACK
GET /index.jsp
30ms 60ms
Region
82. Two Users with CloudFront Keep-Alive
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
ACK
GET /index.jsp
60ms
SYN
30ms
Region
83. Two Users with CloudFront Keep-Alive
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
ACK
GET /index.jsp
60ms
SYN
SYN-ACK
30ms
Region
84. Two Users with CloudFront Keep-Alive
360ms
SYN
SYN-ACK
ACK
GET /index.jsp
SYN
SYN-ACK
ACK
GET /index.jsp
60ms
SYN
SYN-ACK
ACK
GET /index.jsp
30ms
Region
GET /index.jsp
180ms
86. Optimizing SSL Connections
• How to optimize SSL connections?
– with CloudFront SSL termination.
TCP connection
Amazon CloudFront
SSL termination
87. Optimizing SSL Connections
• CloudFront has the ability to support SSL traffic.
• Use CloudFront cert or bring your own.
• SSL traffic gets terminated at the closet CloudFront
location.
104. Performance Tests
• Without CloudFront
Oregon Virginia
• With CloudFront
Oregon Virginia
105. Performance Tests Results
Test # Of Packets Response Time Per Request
Response Time For 200
Requests
Without
CloudFront
2605 170 ms 33.876 s
With
CloudFront
896 96 ms 19.24 s
106. Optimizing PUT/POST
• How to optimize content PUT/POST?
– with CloudFront PUT/POST Verb optimization
TCP connection
Amazon CloudFront
PUT/POST Verb optimization
107. Optimizing PUT/POST
• CloudFront can support verbs:
PUT, POST, DELETE, OPTIONS, and PATCH.
• Data won’t get cached.
• CloudFront can proxy data to origin.
111. Optimizing PUT/POST Performance Tests
• Uploading 10MB data from an instance in US East region to
US West region: average result is 5 seconds.
Upload
Oregon Virginia
112. Optimizing PUT/POST Performance Tests
• Uploading 10MB data from an instance in US East region to
closest CloudFront location: average result is 3.5 seconds.
Oregon Virginia
113. Optimizing Content Download – Even More!
• How to optimize content download even more?
– with Route 53 Latency Based Routing (LBR)
Content download
133. Customer Stories
• PUT/POST
– “We are excited to use CloudFront's new POST, PUT, PATCH, and DELETE
capabilities to accelerate our RESTful APIs on Amazon EC2. With these
new HTTP methods we can now take advantage of CloudFront’s global
footprint and optimized connections back to our origin servers in AWS.
Routing our customers’ API requests via a CloudFront edge location near
them will help improve their experience by minimizing packet loss and
upload latency. This will help provide a streamlined experience for our
customers.” Ilan Rabinovitch, Tech Lead, Site Reliability Region
Engineering
135. Customer Stories
• Health Checks and Failover
– “Amazon Route 53’s DNS Failover feature provides high availability
across our multiple AWS regions and gives us the ability to offload
our origins.”
Region
136. Get Started with CloudFront
• AWS Free Usage Tier
• 50 GB CloudFront Data Transfer per Month
• 2,000,000 HTTP/HTTPS Requests per Month
• Learn More: http://aws.amazon.com/free/
Region