(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application for Best Possible...

Preview:

DESCRIPTION

You can't (yet) bend the law of Physics, but you can use the power of the cloud to design applications that run as fast as the speed of light! This session will focus on the best practices for optimizing performance to the very last millisecond. We'll dive into topics such as caching at every layer of your application, TCP optimizations, SSL optimizations, latency based routing, and much more. These best practices can help you to streamline your infrastructure utilization, improve performance and allow you to scale economically.

Citation preview

1. Tight security

2. High availability

3. High performance

Data center/back bone measurements

Last-mile measurements

Synthetic real user measurements

Real user measurements

Tokyo

Singapore

Hong Kong

Tracing route to ns-01.cloudfront.net [207.171.170.1] over a maximum of 32 hops:

1 <1 ms <1 ms <1 ms 203.208.249.242 2 <1 ms <1 ms <1 ms 203.208.232.54 3 <1 ms <1 ms <1 ms 203.208.232.34 4 4 ms 4 ms 4 ms 203.208.232.49 5 <1 ms <1 ms <1 ms 202.160.250.225 6 <1 ms <1 ms <1 ms ge-1-0-0-0.sngc3-dr1.ix.singtel.com [203.208.173.134] 7 <1 ms 10 ms <1 ms ge-4-1-0-0.sngc3-ar3.ix.singtel.com [203.208.172.170] 8 87 ms 97 ms 97 ms 59.128.15.141 9 87 ms 97 ms 97 ms otecbb103.kddnet.ad.jp [124.211.33.1] 10 98 ms 77 ms 90 ms otejbb203.kddnet.ad.jp [59.128.4.61] 11 87 ms 88 ms 89 ms cm-ote252.kddnet.ad.jp [59.128.7.209] 12 77 ms 88 ms 77 ms 118.155.202.30 13 98 ms 87 ms 98 ms ns-01.cloudfront.net [207.171.170.1]

SingaporeTokyoDNS Resolver

Singapore

DNS response

d123.sin.cloudfront.net

1.2.3.4

DNS response

d123.cloudfront.net CNAME

d123.sin.cloudfront.net

DNS query

d123.sin.cloudfront.net

TCP Connect 1.2.3.4

HTTP/1.1

GET /example.jpg

DNS query

d123.cloudfront.net

Tracing route to ns-sin2-01.cloudfront.net

[204.246.164.22]

over a maximum of 32 hops:

1 <1 ms <1 ms <1 ms 203.208.249.242

...

6 13 ms <1 ms <1 ms ge-1-1-0-0.sngtp-

ar6.ix.singtel.com [203.208.183.81]

7 32 ms 33 ms 33 ms so-3-1-2-0.hkgcw-

cr3.ix.singtel.com [203.208.172.46]

8 31 ms 46 ms 32 ms ge-5-0-6-0.hkgcw-

cr3.ix.singtel.com [203.208.152.121]

9 40 ms 35 ms 35 ms if-13-46.icore1.HK2-

HongKong.as6453.net [116.0.67.17]

10 40 ms 35 ms 36 ms Vlan32.icore1.S9U-

Singapore.as6453.net [116.0.83.1]

11 32 ms 32 ms 32 ms ix-12-3.icore1.S9U-

Singapore.as6453.net [116.0.83.70]

12 * * * Request timed out.

13 * * * Request timed out.

14 33 ms 33 ms 33 ms 203.83.223.83

15 33 ms 33 ms 33 ms 204.246.164.22

Tokyo

Singapore

Hong Kong

Singapore

DNS Resolver

Hong Kong

TCP Connect 5.6.7.8

HTTP/1.1

GET /example.jpg

DNS response

d123.cloudfront.net

5.6.7.8

DNS query

d123.cloudfront.net

Routing Engine Maps

Resolvers/Viewer Networks =>

Edge Location

Tokyo

5.6.7.8

Anonymous Latency

measurements from real

users

*Nav URL = http://pfc303.origin-v.jman.ws

{{ my_url_for('static', filename='0001.css') }}

xmlhttp0.open("GET","ajax?num=10",true);

…{{ s }}

Test instance

Origin

0

0.1

0.2

0.3

0.4

0.5

0.6

1 3 5 7 9 11 13 15 17 19

Pag

e L

oad

Tim

e (

s)

Test Iteration

Virginia - Baseline

Virginia - Baseline

0.4

0.9

1.4

1.9

2.4

2.9

3.4

3.9

4.4

1 3 5 7 9 11 13 15 17 19

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Baseline

Oregon - Baseline

9

9.1

9.2

9.3

9.4

9.5

9.6

9.7

9.8

9.9

10

1 3 5 7 9 11 13 15 17 19

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Baseline

Tokyo - Baseline

0.4

0.9

1.4

1.9

2.4

2.9

3.4

3.9

4.4

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Baseline Oregon - Static CDN

0

2

4

6

8

10

12

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Baseline Tokyo - Static CDN

http://pfc303.cdn-v.jman.ws/

def add_header(response):

response.cache_control.max_age = 300

return response*Nav URL = http://pfc303.origin-v.jman.ws

Caching

Origin

Edge

Location

User Request A

Caching

Origin

Edge

Location

Get Image

User Request A

Caching

Origin

Edge

Location

Get Image

Get Image

User Request A

Caching

Origin

Edge

Location

Get Image

Get Image

Image

User Request A

Caching

Origin

Edge

Location

Get Image

Get Image

Image

Image

User Request A

Caching

Origin

Edge

Location

User Request B

Get Image

Caching

Origin

Edge

LocationGet ImageImage

User Request B

0

0.5

1

1.5

2

2.5

3

3.5

4

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Static CDN Oregon - Whole Site

0

0.2

0.4

0.6

0.8

1

1.2

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Static CDN Oregon - Whole Site

0

2

4

6

8

10

12

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Static CDN Tokyo - Whole Site

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Static CDN Tokyo - Whole Site

_static = 'static/'

response.cache_control.max_age = 0

response.cache_control.max_age = 300

if response.mimetype != 'text/html':

*Nav URL = http://pfc303.cdn-v.jman.ws

CloudFront Origin = http://pfc303.origin-v.jman.ws

• HTTP runs on TCP/IP

• TCP has the concept of TCP handshake

• Every HTTP connection has to complete TCP

handshake

Two Users Without an Edge Proxy

SYN

SYN-ACK

ACK

GET /index.jsp

ACK

SYN-ACK

GET /index.jsp

2nd User

Region

SYN

100ms

200ms

200ms

With CloudFront as an Edge Proxy

SYN

SYN-ACK

ACK

GET /index.jsp

ACK

-ACK

GET /index.jsp

Region

SYN

20ms

SYN

SYN-ACK

ACK

GET /index.jsp

GET /index.jsp

80ms

2nd User

200ms

120ms

Window Size Optimization

Packet1

Packet 1 ACK

Packet 2

Packet 3 ACK

Packet 3

Packet 4

Packet 5

Packet 6

Packet 7

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

Window Size Optimization (Continued)

Region

Test Instance

Origin

0

1

2

3

4

5

6

7

8

9

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Whole Site Tokyo - Multi-Region

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Whole Site Tokyo - Multi-Region

58

Test Instance

Origin

Test Instance

Origin

Test Instance

Origin

Test Instance

Origin

0

0.5

1

1.5

2

2.5

3

3.5

4

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Whole Site Oregon - Cache-able Base

0

0.2

0.4

0.6

0.8

1

1.2

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Whole Site Oregon - Cache-able Base

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Multi-Region Tokyo - Cache-able Base

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Multi-Region Tokyo - Cache-able Base

_static = 'static/'

response.cache_control.max_age = 300

response.cache_control.max_age = 0

if response.mimetype != 'text/html':

*Nav URL = http://pfc303.cdn.jman.ws

CDN origin = http://pfc303.origin.jman.ws

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Cache-able Base Oregon - Final

0

0.5

1

1.5

2

2.5

3

3.5

4

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Oregon - Cache-able Base Oregon - Final

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

1 2 3

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Cache-able Base Tokyo - Final

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Pag

e L

oad

Tim

e (

s)

Test Iteration

Tokyo - Cache-able Base Tokyo - Final

Virginia - Baseline Virginia - Final % Improvement

1st Request 0.49s 0.43s 11.89%

Avg of Requests 2-20 0.40s 0.28s 27.18%

Oregon - Baseline Oregon - Final % Improvement

1st Request 3.50s 2.39s 31.75%

Avg of Requests 2-20 3.47s 0.47s 86.82%

Tokyo - Baseline Tokyo - Final % Improvement

1st Request 9.93s 2.32s 76.68%

Avg of Requests 2-20 9.53s 0.46s 95.99%

Tokyo - Final (Single Region) % Improvement

1st Request 4.88s 52.93%

Avg of Requests 2-20 0.59s 93.60%

Please give us your feedback on this session.

Complete session evaluations and earn re:Invent swag.

http://bit.ly/awsevals

Recommended