79
November 13, 2014 | Las Vegas, NV Ben Clay, Amazon DynamoDB Brett McCleary, Precision Exams

(PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Embed Size (px)

DESCRIPTION

This expert level session covers best practices and tips on how to reduce latency to the absolute minimum when dealing with high volume, high speed datasets, using Amazon DynamoDB. We take a deep dive into the design patterns and access patterns geared to provide low latency at very high throughput. We cover some ways in which customers have achieved low latencies and have a customer speak about their experience of using DynamoDB at scale.

Citation preview

Page 1: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

November 13, 2014 | Las Vegas, NV

Ben Clay, Amazon DynamoDB

Brett McCleary, Precision Exams

Page 2: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 3: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 4: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 5: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

• Independent throughput or storage scaling

• Supports both document and key-value data models

Page 6: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 7: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 8: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 9: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Example Schema: Webstore Orders

Hash Key (string) Customer ID

Range Key (string) Timestamp

Attribute (map) Item ID : quantity map

Attribute (number) Customer ID

Page 10: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Item #1 #2 …

Partition #1 Partition #2 Partition #3

Item #N• One item, one partition

• Placement based on key

Page 11: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Item #1 #2 …

Partition #1 Partition #2 Partition #3

Provisioned

Throughput1000 WPS 1000 WPS 1000 WPS

Page 12: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Table

Partition 1

Partition 3Partition 2

Client

Client

Client

Partition 4

Partition 6Partition 5

Client

Client

Client

Page 13: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 14: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Client Machine

Application

OS

SDK

DynamoDB

Page 15: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Client Machine

Application

OS

SDK

DynamoDB

Page 16: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Client Machine

Application

OS

SDK

DynamoDB

Page 17: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

0

250

500

750

1000

1250

1500

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

Th

rou

gh

pu

t

Time

Provisioned

Consumed

Page 18: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Table

Partition 1

Partition 3Partition 2

Client

Client

Client

Partition 4Client

Table

Partition 1Client

Client

Table grows over time, skew becomes noticeable

Page 19: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 20: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 21: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 22: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Webstore Orders

Hash Customer ID

Range Timestamp

Attrib Items ordered

Attrib Order ID

Page 23: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Orders

Partition 1

Partition 3Partition 2

Client

Client

Client

Partition 4

Partition 6Partition 5

Client

Client

Client

Page 24: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 25: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Webstore Orders

Hash Customer ID

Range Timestamp

Attrib Items ordered

Attrib Order ID

Attrib Household ID

Household Index

Hash Household ID

Range Timestamp

Attrib Items ordered

Attrib Order ID

Attrib Customer ID

Indexing

Page 26: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

TableItem #1

Item #3Item #2

IndexItem #1

Item #3Item #2

Read

Clients

Read +

Write

Clients

Page 27: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Day of Order Index

Hash Day of order

Range Order ID

Attrib Items ordered

Attrib Customer ID

Attrib Timestamp

Webstore Orders

Hash Customer ID

Range Timestamp

Attrib Items ordered

Attrib Order ID

Attrib Day of order

Indexing

Page 28: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Day of

order

indexTable

Partition 1

Partition 3Partition 2

Index

Partition 1

Partition 3Partition 2

Client

Client

Client

New

orders

Page 29: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Day of

order

indexTable

Partition 1

Partition 3Partition 2

Index

Partition 1

Partition 3Partition 2

Client

Client

Client

New

orders

… …

Page 30: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 31: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Alternate Approach: Scanning

H: Alice

R: Oct 2

Partition #1 Partition #2

H: Alice

R: Nov 11

H: Alice

R: Dec 25

H: Bob

R: Oct 20

H: Bob

R: Nov 12

H: Bob

R: Dec 23

P1 P2 P3 P4 P5 P6 P7 P8 P9

Scan

Page 32: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

• Delete old items from the client side

H: Alice

R: Oct 2

Partition #1 Partition #2

H: Alice

R: Nov 11

H: Alice

R: Dec 25

H: Bob

R: Oct 20

H: Bob

R: Nov 12

H: Bob

R: Dec 23

• Takeaway: Table growth can impact throughput per key

• Important when: Accumulating infrequently-read data

Page 33: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 34: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

• Controlling table growth with deletes works but…

• Deleting items from client = 2x write cost!

• Can we achieve cheaper deletes AND scans?

H: Alice

R: Oct 2

Partition #1 Partition #2

H: Alice

R: Nov 11

H: Alice

R: Dec 25

H: Bob

R: Oct 20

H: Bob

R: Nov 12

H: Bob

R: Dec 23

Scan for last month

Page 35: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

H: Alice

R: Dec 23

Dec Table

Hash: Bob

R: Dec 25

H: Alice

R: Oct 2

Oct Table

Hash: Bob

R: Oct 20

• Takeaway: Time series data chunks very well

• Important when: Big, growing time series tables

H: Alice

R: Nov 11

Nov Table

Hash: Bob

R: Nov 12

Scan last month

Page 36: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 37: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Orders TableItem #1Item #2Item #3

Page 38: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 39: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Orders TableItem #1Item #2

EMR

Fleet

2. Export

1. ScanItem #3

Page 40: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Orders TableItem #1Item #2

Stream

Processor

Fleet

1. Update

records

You need near-realtime data

2. Export

Page 41: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 42: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 43: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 44: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

“It is not the strongest of the species

that survives, nor the most

intelligent, but the one most

adaptable to change.”

-- Charles Darwin

Page 45: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 46: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

web nweb02web02

Web Tier

app01 app02 app n

Application Tier

Page 47: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 48: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

rpt01

web nweb02web02

Web Tier

app01 app02 app n

Application Tier

Data warehouse process

sat01

sat02

sat n

Page 49: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 50: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 51: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 52: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 53: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

rpt01

web nweb02web02

Web Tier

app01 app02 app n

Application Tier

dw01

Amazon

DynamoDB

Page 54: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 55: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 56: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 57: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Test Packet Answer Record

Hash Key (string) Test Packet ID

Attribute (string) Answer JSON

Page 58: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Test Packet Response Record

Hash Key (string) Test Packet ID

Range Key (string) Test Packet Response ID

Attribute (string) Create Timestamp

Attribute (string) Post Date

Attribute (string) Response JSON

Page 59: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 60: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 61: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

{

"testPacketId":11193654,

"answerJson": {

"SQ22545":{"responses":{"010":"Y"},"awardedPts":1},

"SQ22546":{"responses":{"040":"Y"},"awardedPts":1},

"21137":{"responses":{"030":"Y"},"awardedPts":0}

...

}

}

Page 62: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 63: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

{

"testPacketId":11193654,

"testPacketResponseId":"SQ22545",

"createdTimeStamp":"1412609315419",

"postDate":"1412609315419",

"responseJson":{"i":"26492","f":"N","t":0,"r":{"010":"Y"}}

}

Page 64: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 65: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 66: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

tst01

tst02 Amazon

DynamoDB

Page 67: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 68: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 69: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

Client

Client

ClientG

rinder

Client

Client

ClientAmazon

DynamoDB

Page 70: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 71: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 72: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 73: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 74: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

0

2

4

6

8

10

12

300 600 1200 2200 5000

La

ten

cy (

ms

)

Provisioned Capacity (units)

P90 Client Latency (ms) Avg. Server Latency (ms) Avg. Client Latency (ms)

Page 75: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 76: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 77: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 78: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014
Page 79: (PFC402) Bigger, Faster: Performance Tips for High Speed and High Volume Applications | AWS re:Invent 2014

http://bit.ly/awsevals