167
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc. Dynamic Content Acceleration: Lightning-Fast Web Apps with Amazon CloudFront and Amazon Route 53 Kalyanaraman Prasad Parviz Deyhim November 13, 2013

Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Embed Size (px)

DESCRIPTION

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.

Citation preview

Page 1: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.

Dynamic Content Acceleration: Lightning-Fast Web Apps with Amazon CloudFront and Amazon Route 53 Kalyanaraman Prasad Parviz Deyhim November 13, 2013

Page 2: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Fundamental Facts

Any web application must have… • Tight Security • High Availability • High Performance

Page 3: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Does Availability Matter? • If your application is not available, your revenue loss is

100%.

• Impact to customer loyalty and your brand image.

Page 4: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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.

Page 5: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Performance Matters? • Performance translates to …

• Higher Page Views • Better Customer Experience • Higher Conversion Rates

Page 6: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Performance Matters?

Page 7: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Performance Matters?

Great amount of time and money spent improving back-end infrastructure performance

Page 8: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Performance Matters?

80% of user’s perceived latency comes from front-end

Page 9: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 10: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Static or Re-Usable Content

Can be cached (High TTLs or Low TTLs)

Page 11: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Typical Architecture

Page 12: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Dynamic or Unique Content

Cannot be cached - BUT affects 100% of your viewers!

Page 13: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Why Not…?

Page 14: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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.

Page 15: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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!

Page 16: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 17: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Unique or Reusable Contents?

Page 18: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

STATIC or REUSABLE A given content where the state of the content

does NOT change for a given period of time

t0 t1

Page 19: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

DYNAMIC OR UNIQUE A given content where the state of the content

changes as soon as it gets created

t0 t1

Page 20: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Example

Page 21: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Example Index.jsp (dynamic)

Images (static)

Page 22: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

. sec

Page 23: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Page Load Time?

. Sec

Page 24: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Improving Web Application Performance

Accelerating static contents Accelerating dynamic contents

Page 25: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Brief Introduction to Waterfall Graphs

Page 26: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Waterfall Graphs

• Most important tool for web-performance measurement • Most browsers provide waterfall graph plug-ins

Page 27: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

What Happens?

Typing the Address Browser renders

Page 28: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Understanding Waterfall Graphs

DNS Lookup

TCP Connection

Time to First Byte

Content Download

Page 29: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Understanding Waterfall Graphs

Index.jsp

Page 30: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content

Page 31: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content

Index.jsp

Images, JS and CSS

Page 32: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content

Index.jsp

Optimize By Caching With Amazon CloudFront

Page 33: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

User Request A

Page 34: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

Get Image

User Request A

Page 35: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

Get Image

Get Image

User Request A

Page 36: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

Get Image

Get Image

Image

User Request A

Page 37: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

Get Image

Get Image

Image

Image

User Request A

Page 38: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

User Request B

Get Image

Page 39: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Caching

Origin

Edge Location

Get Image Image

User Request B

Page 40: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content with Caching

Brings content closer to the users

Page 41: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content with Caching

Improves the experience and performance

Page 42: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Static Content with Caching

Offloads your infrastructure

Page 43: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 44: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Before Caching = 1.46sec

Page 45: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

After Caching = 770ms

Page 46: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Are We Done?

Page 47: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

NOT SO FAST . sec GOAL:

Page 48: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Cache As Much As You Can

Page 49: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How? I’m Caching All My Images, CSS

and JS

Page 50: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Steps to Find Cachable Content

1. Collect web (W3C) logs from your web tier

2. Run a report on your logs (Amazon EMR, Amazon RDS, or Amazon Redshift)

3. Identify top N URLs

Page 51: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Steps to Find Cachable Content

Example of query:

Select count(url) count, url from logs_table Group by url sort by count;

Page 52: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Site Content

Page 53: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

STATIC or REUSABLE A given content where the state of the content

does NOT change for a given period of time

t0 t1

Page 54: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 55: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Content with Query Strings

Reusable?

110 /factor/create_image?name=book1&size=10x10

Page 56: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Content with Query Strings

• CloudFront can cache content with query strings • Every unique query string combination is a new

object in CloudFront’s cache

Page 57: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

API Calls

Reusable?

100 /api/GetBooks?category=math

Page 58: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

API Calls

Reusable?

80 /api/GetBooks?top=10

Page 59: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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: Elastic Load Balancing or any

other LB

• Provision less capacity and reduce cost

1000 /api/GetBooks?top=10

Page 60: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Base Page (First HTML page)

Reusable?

220 /index.jsp

Page 61: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Dynamic Content

Page 62: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Dynamic Content

Index.jsp

Page 63: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing Dynamic Content

Index.jsp

Page 64: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Can Dynamic Content Be Optimized?

Dynamic content is not cachable Content proxied by CDN to the origin and back

Page 65: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Can Dynamic Content Be Optimized?

User Request

Origin

Edge Location

Poke

Poke

Ok

Ok

Poke Poke

User Request

Page 66: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Can Dynamic Content Be Optimized?

That adds latency? How to optimize dynamic content?

Page 67: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Optimize Dynamic Content?

DNS Lookup

TCP Connection

Time to First Byte

Content Download

Page 68: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 69: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

After Caching/Before CloudFront Dynamic Acceleration = 770ms

Page 70: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Improve DNS Time?

DNS Lookup

Index.jsp

Page 71: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With Amazon Route 53

Route 53

Page 72: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Optimizing DNS Response Time • Amazon 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

Page 73: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Without Amazon Route 53

Page 74: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With Amazon Route 53

Page 75: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Improve TCP Connection and First Byte Time?

TCP Connection

Index.jsp

Page 76: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With CloudFront’s Keep-Alive Connections

Page 77: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 78: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Two Users without CloudFront SYN

SYN-ACK

ACK

GET /index.jsp

ACK

SYN-ACK

GET /index.jsp

2nd User SYN

90ms

360ms

360ms

Page 79: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Without CloudFront

• Every user is new connection

• More users = more TCP connections

Page 80: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Without Keep-Alive Connections

• Puts load on your web servers: Memory/CPU

Page 81: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Without Keep-Alive Connections

• Load on your web server increases the time to first byte

Time to First Byte

Page 82: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

SYN

SYN-ACK

ACK

GET /index.jsp GET /index.jsp

Keep Alive Connections

2nd Request

Page 83: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

CloudFront Keep Alive SYN

SYN-ACK

ACK

GET /index.jsp

ACK

SYN-ACK

GET /index.jsp

SYN

30ms

SYN

SYN-ACK

ACK

GET /index.jsp

GET /index.jsp

60ms

2nd User

360ms

180ms

Page 84: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

• More users More TCP connections

• Offloads your web tier’s CPU/memory • Improves response time

2 connections Without CloudFront 1 connection With CloudFront

720 ms Without CloudFront 540 ms With CloudFront

CloudFront Keep Alive

Page 85: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Test CPU Util. % Without CloudFront 20% With CloudFront 6%

Page 86: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Optimize My SSL Connections?

TCP Connection

Index.jsp

Page 87: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With CloudFront’s SSL Termination

Page 88: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 89: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 90: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

SSL Optimization Patterns with CloudFront

Two optimization patterns:

1. Half bridge SSL termination

2. Full bridge SSL termination

Page 91: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Half Bridge SSL Termination

HTTP CloudFront

Page 92: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Half Bridge SSL Termination Benefits

• Better performance by leveraging HTTP connections to origin

HTTP CloudFront

Page 93: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Full Bridge SSL Termination

HTTPs

Page 94: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Improve Content Download Time?

Content Download

Index.jsp

Page 95: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With Amazon CloudFront Slow-Start Optimization

Page 96: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

TCP Slow Start Packet1

Packet 1 ACK

Packet 2

Packet 3 ACK

Packet 3

Packet 4

Packet 5

Packet 6

Packet 7

Page 97: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

• 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

Page 98: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Packet1

Packet 1 ACK

Packet 2

Packet 3 ACK

Packet 3

Packet 4

Packet 5

Packet 6

Packet 7

Packet1

Packet 2

Packet 4 ACK

Packet 3

Packet 4

Packet 5

Packet 6

Packet 7

Packet 8

Packet 9

Page 99: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Performance Test 1: Without CloudFront

Page 100: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Performance Test 2: With CloudFront

Page 101: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 102: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Optimize PUT/POST? TCP Connection

Index.jsp

Page 103: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With Amazon CloudFront PUT/POST Verb Optimization

Page 104: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization with CloudFront

• CloudFront supports verbs: PUT, POST, DELETE, OPTIONS, and PATCH

• Data won’t get cached

• CloudFront proxies data to origin

Page 105: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization with CloudFront

• Dynamic content optimizations apply

– Keep-alive connections

– TCP slow-start optimization

– Close proximity connection termination

Page 106: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization with CloudFront

• Optimizing form POSTs

• Optimizing AJAX POST requests

• Optimizing content upload – Uploading to Amazon S3

Page 107: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization Test

CloudFront

Page 108: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization Test

Uploading 10 MB data from an instance in US East region to US West region

Avg. result: 5sec

Page 109: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

PUT/POST Optimization Test

Uploading 10MB data from an instance in US East region to the closest CloudFront location

Avg. result: 3.5sec

CloudFront

Page 110: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

How to Improve Content Download Time Even More?

Content Download

Index.jsp

Page 111: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

With Amazon Route 53 Latency-based Routing

Route 53

Page 112: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Latency-based Routing (LBR) • Run multiple stacks of your application in different Amazon

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

Page 113: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 114: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

LBR For End-Users

114

Page 115: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

LBR For End-Users

115

Page 116: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

CloudFront and Route 53 • Use CloudFront for dynamic content optimization

• Host your origin at multiple AWS locations (or data

centers)

– US – Europe

Page 117: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 118: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

LBR For End-Users

118

Page 119: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

LBR For End-Users

119

Page 120: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 121: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 122: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 123: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 124: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 125: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 126: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Lower Latency with CloudFront and Route 53

Page 127: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 128: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 129: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 130: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 131: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 132: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 133: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 134: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 135: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013
Page 136: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

After CloudFront Dynamic Content Optimization = 555 ms

Page 137: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Example: somecompany.com

. sec

Page 138: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure with CloudFront and Route 53

Route 53

Page 139: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure Normal interaction: 1. Users connect to

CloudFront 1. CloudFront

connects to Origin

CloudFront

Page 140: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure • What happens if the origin fails to respond back

to CloudFront?

CloudFront

Page 141: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure • With Amazon Route 53, you can health-check

your origin

Page 142: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure • Failures can be detected by Route 53 health

checks

CloudFront

Page 143: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure • The traffic shifts to the healthy instances or load

balancers instead

CloudFront

Page 144: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Can mix health check and latency-based routing

Can apply the same logic to multiregion deployments

Page 145: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Users get connected to the closest region if both regions are healthy

Page 146: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Route 53 detects failures via health checks

Page 147: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Users get connected to the

healthy regions if the

closest region is not

passing the health check

Page 148: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

148

Page 149: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Caching • Going back to “cache as much as you can”

• More caching = better availability

149

Page 150: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

User Request A

Page 151: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

User Request A

Page 152: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image

User Request A

Page 153: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image

Image

User Request A

Page 154: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image

Image

Image

User Request A

Page 155: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Image

User Request B

Page 156: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image

User Request B

Page 157: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image

User Request B

Page 158: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Design for Failure: Serve Cached Content

Origin

Edge Location

Get Image

Get Image Image

User Request B

Page 159: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

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

Page 160: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Stories

Page 161: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: Low TTLs

Page 162: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: Query Strings

Page 163: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: Cookies

Page 164: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: POST/PUT “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

Page 165: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: Custom SSL

Page 166: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Customer Story: Health Checks & 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.”

Page 167: Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) | AWS re:Invent 2013

Please give us your feedback on this presentation

As a thank you, we will select prize winners daily for completed surveys!

ARC309