본문 바로가기

AWS Database/AWS DynamoDB

[AWS Certificate]-DynamoDB Best Practice

DynamoDB Best Practices

 

Efficient Key Design

 

  • Partition key should have many unique values
  • Distribute reads / writes uniformly across partitions to avoid hot partitions
  • Store hot and cold data in separate tables
  • Consider all possible query patterns to eliminate use of scans and filters
  • Choose sort key depending on your application's needs
  • Use indexes based on when your application's query patterns
  • Use primary key or LSIs when strong consistency is desired
  • Use GSIs for finer control over throughput or when your application needs to query using a different partition key
  • Use shorter (yet intuitive!) attribute names

 

Storing Large Item Attributes

 

  • Use compression (GZIP)
  • Use S3 to store large attributes
  • Split large attributes across multiple items

 

Reading

 

  • Avoid scans and filters
  • Use eventual consistency for reads

 

LSIs

 

  • Use LSIs Sparingly
  • Project fewer attributes
  • Watch for expanding item collections (10GB size limit!)

 

GSIs

 

  • Project fewer attributes
  • Can be used for eventually consistent read replicas