Amazon SimpleDB

11
Amazon SimpleDB Developer Brown Bag Jakub, Rande, Stefano, Tim, & Brett

description

Amazon SimpleDB. Developer Brown Bag Jakub, Rande, Stefano, Tim, & Brett. Agenda. Recap/clarification on recent releases BatchPutAttributes Long running Select queries Select Count Step-by-step SimpleDB tutorial Your questions. BatchPutAttributes API. - PowerPoint PPT Presentation

Transcript of Amazon SimpleDB

Page 1: Amazon SimpleDB

Amazon SimpleDB

Developer Brown BagJakub, Rande, Stefano, Tim, & Brett

Page 2: Amazon SimpleDB

Agenda• Recap/clarification on recent releases

• BatchPutAttributes• Long running Select queries• Select Count

• Step-by-step SimpleDB tutorial

• Your questions

Page 3: Amazon SimpleDB

BatchPutAttributes API• Natural extension to PutAttributes• Up to 25 items per batch• Up to 256 attributes per item

• Same as PutAttributes• One megabyte maximum request size• Improved throughput compared to PutAttributes

• Fewer round trips with SimpleDB• Server side optimizations

Page 4: Amazon SimpleDB

BatchPutAttributes parameters• Rest:

Item.X.ItemName=ItemNameItem.X.Attribute.Y.Name=AttributeNameItem.X.Attribute.Y.Value=AttributeValueItem.X.Attribute.Y.Replace=true/falseX: 0-24 itemsY: 0-255 attributes per item

• Soap: <Item>

<ItemName>...</ItemName><Attribute><Name>...</Name><Value>...</Value><Replace>...</Replace> </Attribute>

</Item>

• Replace flag is optional and defaults to FALSE • Specify only when strictly necessary

Page 5: Amazon SimpleDB

More on BatchPutAttributes• BatchPutAttributes can be executed in

parallel• Can achieve even higher throughput• Requests throttled aggressively (503) if excessive

parallelism• Excessive depends on dataset

• All or nothing semantics• API Call either accepted or rejected in its entirety• Call rejected when throttled (503)• Call rejected when limit exceeded

Page 6: Amazon SimpleDB

Long Running Selects• Query, QueryWithAttributes and Select all have a 5

seconds timeout• When timeout elapses

• Query and QueryWithAttributes return 408 (timeout) error and no data

• Select returns partial result set accumulated so far and NextToken to pick up where it left off

• Individual partial result set could be empty• Client responsible for combining result sets• Select can complete even very complex queries over

multiple iterations

Page 7: Amazon SimpleDB

Select Count(*)• Counts number of items that qualify predicate

• Server side counting much more efficient

• Count all items in domain: select count(*) from MyDomain

• Count blue eyes in domain: select count(*) from MyDomain where EyeColor = 'blue'

• Count up to 500 blue eyes in domain: select count(*) from MyDomain where EyeColor = 'blue' limit 500

Page 8: Amazon SimpleDB

Count(*) and timeouts• 5 second timeout enforced for Count(*) as well

• Select will return NextToken together with partial count

• Partial counts must be accumulated by client1. Client issues “select count(*) from MyDomain” with no token2. SimpleDB returns 20,000 and NextToken T13. Client issues “select count(*) from MyDomain” with NextToken T14. SimpleDB returns 50,000 and NextToken T25. Client issues “select count(*) from MyDomain” with NextToken T26. SimpleDB returns 35,000 and no NextToken7. Final count is 20,000 + 50,000 + 35,000 = 105,000

Page 9: Amazon SimpleDB

Interchangeable NextToken• NextToken returned by Count(*) can be used for Select

• WHERE and ORDER BY clauses must match

• Can be used to efficiently bypass records in result set• Return 100 items after the first 100,000 for

select * from MyDomain where EyeColor = 'blue' and Age > '30’ order by Age1. Client issues with no token

select Count(*) from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 100000

2. SimpleDB returns 65,000 and NextToken T13. Client issues with NextToken T1

select Count(*) from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 35000

4. SimpleDB returns 35,000 and NextToken T25. Client issues with NextToken T2

select * from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 100

Page 10: Amazon SimpleDB

SimpleDB Tutorial

AWS Evangelist Mike Culver

Page 11: Amazon SimpleDB

Questions?