Dynamo Basic APIs

Some of the APIS for DynamoDB

  • PutItem: create or replace an item. Consumes WCUs
  • UpdateItem: edit an item's attributes
  • Conditional Writes:
    • accept write, update, delete only condition is met, else returns error
    • Good for concurrency
    • No performance impact
    • See: DynamoDB Optimistic Locking
  • GetItem
    • Read based on Primary Key
    • Eventually Consistent (default)
    • Strongly Consistent might take longer and consumes more RCU
    • ProjectionExpression can be specified to receive only certain attributes
  • Query
    • To query item, using
      • KeyConditionExpress:
      • FilterExpression
        • Additional filtering after query is executed (before data is return to you)
        • use only with non-key attribute (no HASH or RANGE key)
        • happening in client-side
    • Return the number of items specified in Limit or up to 1 MB of data
    • Ability to do pagination
    • Can query table, local secondary index or global secondary index
  • Scan :
    • read entire table and then filter out data (inefficient)
    • Returns up to 1 MB of data - use pagination to read more
      • Use Limit to reduce size of result and pause
    • Consumes a lot of RCU
    • For faster performance, can use Parallel Scan
    • Can use ProjectionExpression & FilterExpression (no changes to RCU)
  • DeleteItem
    • Delete an individual item
    • Ability to perform a conditional delete
  • DeleteTable
    • Delete whole table and all its items
    • Ntoe: Much quicker deletion than calling DeleteItem on all items

Batch Operations

Save latency by reducing number of APIs. Operations are done in parallel for better efficiency

Part of batch can fail, we can try again for the failed items

  • BatchWriteItem
    • up to 25 PutItem and/or DeleteItem in one call
    • Up to 16 MB of data written, 400 KB of data per item
    • can't update items (you need to use UpdateItem)
  • BatchGetItem
    • Return items from one or more tables
    • Up to 100 items, up to 16 MB of data
    • items are retrieved in parallel to minimize latency