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’s dynamic delivery features that help improve the performance, scalability, and availability of your website while helping you lower your costs. We talk about architectural patterns such as SSL termination, close proximity connection termination, origin offload with keep-alive connections, and last-mile latency improvement. Also learn how to take advantage of Amazon Route 53's health check, automatic failover, and latency-based routing to build highly available web apps on AWS.
2. Fundamental Facts
Any web application must have…
• Tight Security
• High Availability
• High Performance
3. Why Does Availability Matter?
• If your application is not available, your revenue loss is
100%.
• Impact to customer loyalty and your brand image.
4. How AWS Helps?
Use Amazon Route 53 to health-check your origin
webservers, with automatic failover.
Use Amazon CloudFront to front your origins to reduce
load on your origins.
Use Amazon CloudFront to customize your error pages.
Amazon CloudFront will automatically serve stale
content when origin is unavailable.
9. How do we Improve Performance ?
A Typical Web Application Has …
• Static or Re-Usable Content
• High TTLs
• Low TTLs (Customized Content)
• Dynamic or Unique Content
• Zero TTL
14. Why Don’t Customers Use a CDN for Dynamic
Content?
I don’t see the value - each request is unique and must go back
to the origin web server.
AND/OR
I see the value, but my current CDN charges premium rates for
dynamic content acceleration, with many additional fees.
AND/OR
Configuring a CDN for dynamic content acceleration requires
expensive professional services and is not self-service.
15. How Can Amazon CloudFront Help?
TCP/IP optimizations for the network path
Keep-Alive Connections to reduce RTT
SSL Termination close to viewers
POST/PUT upload optimizations
Latency Based Routing
Low prices, same as static content delivery!
50. Steps to Find Cachable Contents
1. Collect web (W3C) logs from your web tier
2. Run a report on your logs (EMR, RDS or
Redshift)
3. Identify top N URLs
51. Steps to Find Cachable Contents
Example of query:
Select count(url) count, url
from logs_table
Group by url sort by count;
53. STATIC or REUSABLE
A given content where the state of the content
does NOT change for a given period of time
t0 t1
54. Caching for Smaller Time Units
• Goal: Find contents that can be cached for any given
period of time
• Hours
• Minutes
• Seconds
• CloudFront can cache content for any period of time
55. Content with Query Strings
Reusable?
110 /factor/create_image?name=book1&size=10x10
56. Content with Query Strings
• CloudFront can cache content with query strings
• Every unique query string combination is a new
object in CloudFront’s cache
59. Caching for Smaller Time Units
• Imagine your have a read heavy API GETS Hit 100 or
1000 RPS
• Offload your web-tier from handling 1000 RPS
• Offload your load balancer: ELB or any other LB
• Provision less capacity and reduce cost
1000 /api/GetBooks?top=10
64. Can Dynamic Content Be Optimized?
Dynamic content are not cachable
Content proxied by CDN to the
origin and back
65. Can Dynamic Content Be Optimized?
User
Request
Origin
Edge
Location
Poke
Poke
Ok
Ok
PokePoke
User
Request
66. Can Dynamic Content Be Optimized?
That adds latency?
How to optimize dynamic content?
67. How to Optimize Dynamic Contents?
DNS Lookup
TCP Connection
Time to First Byte
Content Download
68. How to Optimize Dynamic Delivery?
Route 53
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
Rute53
Route 53
72. Optimizing DNS Response Time
• Route 53 managed DNS offering
• Designed to be fast
• Low latency DNS resolution
• Global network of DNS servers
• Queries routed to the nearest DNS server
77. TCP/IP Hand Shake
• HTTP Runs on TCP/IP
• TCP has the concept of TCP handshake
• Every HTTP Connection has to complete TCP
Handshake
• TCP/IP Hand Shake Penalizes Dynamic Contents
78. Two Users without CloudFront
SYN
SYN-ACK
ACK
GET /index.jsp
ACK
SYN-ACK
GET /index.jsp
2nd User
Region
SYN
90ms
360ms
360ms
83. CloudFront Keep Alive
SYN
SYN-ACK
ACK
GET /index.jsp
ACK
SYN-ACK
GET /index.jsp
Region
SYN
30ms
SYN
SYN-ACK
ACK
GET /index.jsp
GET /index.jsp
60ms
2nd User
360ms
180ms
84. • More users More TCP connections
• Offloads your web tier’s CPU/memory
• Improves response time
2 connectionsWithout CloudFront
1 connectionWith CloudFront
720 msWithout CloudFront
540 msWith CloudFront
CloudFront Keep Alive
85. Test CPU Util. %
Without CloudFront 20%
With CloudFront 6%
86. How to Optimize My SSL Connections?
TCP Connection
Index.jsp
88. SSL Optimization with CloudFront
• CloudFront has the ability to support SSL traffic
• Use CloudFront cert or bring your own
• SSL traffic gets terminated at the closest
CloudFront location
89. CloudFront SSL Optimization Benefits
• Taking advantage of keep-alive connections
• SSL introduces additional TCP handshake packets
• Keep alive eliminates additional SSL TCP handshake
packets
• Offloading your infrastructure from terminating 1000s of
end-users SSL connections
90. SSL Optimization Patterns with CloudFront
Two optimization patterns:
1. Half bridge SSL termination
2. Full bridge SSL termination
97. • CloudFront can optimize slow start
• Slow start impacts new connections not the
existing ones
• CloudFront uses existing connections so users
can skip slow start
Slow-Start Optimization with CloudFront
101. Performance Results
Test # Of Packets Response Time Per Request
Response Time For 200
Requests
Without
CloudFront
2605 170 ms 33.876 ms
With
CloudFront
896 96 ms 19.24 ms
104. PUT/POST Optimization with CloudFront
• CloudFront supports verbs: PUT, POST,
DELETE, OPTIONS, and PATCH
• Data won’t get cached
• CloudFront proxies data to origin
108. PUT/POST Optimization Test
Oregon Virginia
Upload
Uploading 10 MB data from an instance in US
East region to US West region
Avg. result: 5sec
109. PUT/POST Optimization Test
Oregon Virginia
Upload
U
p
load
Uploading 10MB data from an instance in US
East region to the closest CloudFront location
Avg. result: 3.5sec
CloudFront
110. How to Improve Content Download Time
Even More?
Content Download
Index.jsp
112. Latency-based Routing (LBR)
• Run multiple stacks of your application in different EC2 regions around
the world
• Create LBR records for each location and tag the location with geo
information
• Route 53 will route end users to the endpoint that provides the lowest
latency
112
113. LBR Benefits
• Better performance than running in a single region
• Improved reliability relative to running in a single region
• Easier implementation than traditional DNS solutions
• Much lower prices than traditional DNS solutions
113
116. CloudFront and Route 53
• Use CloudFront for dynamic content optimization
• Host your origin at multiple AWS locations (or data
centers)
– US
– Europe
117. CloudFront and Route 53
• Create Origin DNS records in Route 53 for each location
• Route 53 measures the latency between CloudFront and
all configured origins
• Route 53 resolves origin’s hostname to the closest
location
• Reduce content download time
148. Design for Failure: Caching
• Caching improves performance
• Can also improve availability
• If your infrastructure is experiencing failure,
CloudFront can serve cached content instead of
5xx,4xx and etc
149. Design for Failure: Caching
• Going back to “cache as much as you can”
• More caching = better availability
150. Design for Failure: Serve Cached Content
Origin
Edge
Location
User Request A
151. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
User Request A
152. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get Image
User Request A
153. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get Image
Image
User Request A
154. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get Image
Image
Image
User Request A
155. Design for Failure: Serve Cached Content
Origin
Edge
Location
Image
User Request B
156. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get Image
User Request B
157. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get Image
User Request B
158. Design for Failure: Serve Cached Content
Origin
Edge
Location
Get Image
Get ImageImage
User Request B
159. Summary
• Accelerate all your content with CloudFront
• Use CloudFront with Route 53 latency-based
routing to improve your performance
• Design for failure with CloudFront and Amazon
Route 53