49
Moving to DynamoDB: Practical Lessons Learned Ryan Park Infrastructure Engineer @StanfordRyan

Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Moving to DynamoDB: Practical Lessons Learned

Ryan ParkInfrastructure Engineer

@StanfordRyan

Page 2: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Build Better APIs, Togetherwith Runscope API Monitoring & Testing

Page 3: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

API TRAFFIC DEBUGGING

Quickly diagnose integration headaches.

Page 4: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Verify that your APIs are returning the right data.

DATA VALIDATION

Page 5: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

UPTIME MONITORING

Be the first to know when an API is down.

Page 6: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Solve API problems as a team.

COLLABORATION

Page 7: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

50 MM

100 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

50 MM

100 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

Monthly API Test Runs

Page 8: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

100 MM

200 MM

300 MM

400 MM

500 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

100 MM

200 MM

300 MM

400 MM

500 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

Cumulative Test Runs(database rows)

Page 9: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

What now?

Page 10: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 11: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Some results are huge

PROBLEM

Page 12: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

SOLUTION

DynamoDB (record size < 10 KB)

Amazon S3 (record size > 10KB)

+

Page 13: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Hash Key: Result ID Global Secondary Index: Test ID

REVERSE INDEX IN DYNAMODB

s3_index

Page 14: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Selecting a Partition Key and Sort Key

Page 15: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Partition Key: Test ID

TEST RESULTS: THE OBVIOUS CHOICE

Sort Key: Result ID

Page 16: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

HOW MANY PARTITIONS WILL WE HAVE?

Page 17: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

EXAMPLE: SMALL, BUSY TABLE

Table Size 6 GB

Read Capacity Units 15,000

Write Capacity Units 2,000

Partitions:

Page 18: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

EXAMPLE: LARGE TABLE

Table Size 380 GB

Read Capacity Units 2,100

Write Capacity Units 400

Partitions:

Page 19: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

EXAMPLE: BULK IMPORT

Table Size 0 GB

Read Capacity Units 30

Write Capacity Units 10,000

Partitions:

Page 20: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

EXAMPLE: BULK EXPORT & BACKUP

Table Size 4 GB

Read Capacity Units 30,600

Write Capacity Units 200

Partitions:

Page 21: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

🦄 Partition

🐱 Partition 🐝 Partition

data hits 10 GB or

provisioned capacity hits limits

Page 22: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

🐙 Partition 🐒 Partition

data hits 10 GB or

provisioned capacity hits limits

🐱 Partition 🐝 Partition

Page 23: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

🐝 Partition

data hits 10 GB or

provisioned capacity hits limits

🐔 Partition 🐳 Partition

🐙 Partition 🐒 Partition

Page 24: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

🐙 Partition 🐒 Partition 🐔 Partition 🐳 Partition

HOW MANY PARTITIONS?

Usually a power of 2.

Page 25: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

TABLE PARTITIONS

test_results

Partition Reads Writes Hash Keys

( 200 100 α, δ, η, κ…

🕵 200 100 β, ε, θ, λ…

* 200 100 γ, ζ, ι, μ…

Page 26: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

TABLE PARTITIONS

test_results

δ

η

κ

🕵β

ε

θ

λ

ζ

ι

μ

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 27: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

TABLE PARTITIONS

test_results

(α 1 α 2

δ 1 δ 2

🕵β 1 β 2

ε 1 ε 2

*γ 1 γ 2

ζ 1 ζ 2

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 28: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

TABLE PARTITIONS

test_results

(α 1 α 2 α 3 α 4

δ 1 δ 2

🕵 *γ 1 γ 2

ζ 1 ζ 2 ζ 3 ζ 4 ζ 5 ζ 6 ζ 7

β 1

ε 1

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 29: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

200 RCU, 100 WCU

TABLE PARTITIONS

test_results

Test 1, Result 1 Test 1, Result 2 Test 1, Result 3 Test 1, Result 4

Test 5, Result 1 Test 5, Result 2

Test 4, Result 1

Test 7, Result 1

Test 3, Result 1 Test 3, Result 2

Test 12, Result 1 Test 12, Result 2 Test 12, Result 3 Test 12, Result 4 Test 12, Result 5 Test 12, Result 6 Test 12, Result 7 Test 12, Result 8200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 30: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

200 RCU, 100 WCU

Test 1, Result 1 Test 1, Result 2 Test 1, Result 3 Test 1, Result 4

Test 5, Result 1 Test 5, Result 2

Test 4, Result 1

Test 7, Result 1

Test 3, Result 1 Test 3, Result 2

Test 12, Result 1 Test 12, Result 2 Test 12, Result 3 Test 12, Result 4 Test 12, Result 5 Test 12, Result 6 Test 12, Result 7 Test 12, Result 8

ProvisionedThroughputExceededException

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 31: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

200 RCU, 100 WCU

Test 1, Result 1 Test 1, Result 2 Test 1, Result 3 Test 1, Result 4

Test 5, Result 1 Test 5, Result 2

Test 4, Result 1

Test 7, Result 1

Test 3, Result 1 Test 3, Result 2

Test 12, Result 1 Test 12, Result 2 Test 12, Result 3 Test 12, Result 4 Test 12, Result 5 Test 12, Result 6 Test 12, Result 7 Test 12, Result 8

ProvisionedThroughputExceededException

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 32: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

200 RCU, 100 WCU

Test 1, Result 1 Test 1, Result 2 Test 1, Result 3 Test 1, Result 4

Test 5, Result 1 Test 5, Result 2

Test 4, Result 1

Test 7, Result 1

Test 3, Result 1 Test 3, Result 2

Test 12, Result 1 Test 12, Result 2 Test 12, Result 3 Test 12, Result 4 Test 12, Result 5 Test 12, Result 6 Test 12, Result 7 Test 12, Result 8200 RCU, 600 WCU 200 RCU, 600 WCU 200 RCU, 600 WCU

SHORT TERM FIX: OVER-PROVISION ALL PARTITIONS

test_results

Page 33: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

200 RCU, 100 WCU

Test 1, Result 1 Test 1, Result 2 Test 1, Result 3 Test 1, Result 4

Test 5, Result 1 Test 5, Result 2

Test 4, Result 1

Test 7, Result 1

Test 3, Result 1 Test 3, Result 2

Test 12, Result 1 Test 12, Result 2 Test 12, Result 3 Test 12, Result 4 Test 12, Result 5 Test 12, Result 6 Test 12, Result 7 Test 12, Result 8

SHORT TERM FIX: OVER-PROVISION ALL PARTITIONS

test_results

200 RCU, 600 WCU 200 RCU, 600 WCU 200 RCU, 600 WCU

Page 34: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Result 58 (Test 7)

Result 55 (Test 4)

LONG TERM FIX: REPLACE THE HASH KEY

Result 41 (Test 7)

Result 8 (Test 3)

Result 3 (Test 9)

Result 37 (Test 7)

Result 73 (Test 7)

Result 87 (Test 6)

Result 27 (Test 3)

Result 63 (Test 7)

Result 85 (Test 2)

Result 78 (Test 7)

test_results_v2

200 RCU, 100 WCU 200 RCU, 100 WCU 200 RCU, 100 WCU

Page 35: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

DEBUGGING EXCEPTIONS

AWS APIs return useful debugging data:

"ConsumedCapacity": { "CapacityUnits": 3.0, "TableName": "test_results", "Table": { "CapacityUnits": 3.0 } }

Page 36: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

DEBUGGING EXCEPTIONS

AWS APIs return useful debugging data:

Content-Type: application/x-amz-json-1.0 Date: Wed, 27 Jan 2016 02:31:20 GMT X-Amzn-Requestid: S0JI33OC2OPW73KHD028LJWY9W5...

Page 37: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

DEBUGGING EXCEPTIONS

Libraries hide the details.

Page 38: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

DEBUGGING EXCEPTIONS

Page 39: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

RUNSCOPE TRAFFIC INSPECTOR?

“Quickly diagnose integration headaches.”

Page 40: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

USING BOTOCORE HOOKS

Page 41: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 42: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 43: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 44: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 45: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 46: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)
Page 47: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

100 MM

200 MM

300 MM

400 MM

500 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

100 MM

200 MM

300 MM

400 MM

500 MM

Jan 2014 Mar May Jul Sep Nov Jan 2015 Mar May Jul Sep Nov

Cumulative Test Runs(database rows)

Page 48: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)

Everything is going to be

200 OK

Page 49: Moving to DynamoDB: Practical Lessons Learnedfiles.meetup.com/8763012/Behind the Scenes with Runscope - Movin… · DynamoDB (record size < 10 KB) Amazon S3 (record size > 10KB)