current position:Home>Precautions for AWS serverless design dynamodb

Precautions for AWS serverless design dynamodb

2022-04-29 07:57:07zoobuzas

AWS serverless Design -DynamoDB

Overall concept map

 Insert picture description here

Primary key

I think the first thing to pay attention to is DynamoDB Not suitable for “ In two or more columns ( attribute ) Query for conditional search in , Its record ( project ) Primary keys that cannot always be uniquely identified by those specifications ” Take out frequently as required .
This allows you to specify... For each table Hash Key Or add another Sort Key

  1. Hash key only

  2. Hash key and sort key

    Set the primary key in one of the modes .Hash Key Also known as Partition Key, It can be understood as each Partition Key Fragmentation . therefore , It is recommended to set the partition key as the key for evenly distributed queries . Similar to the traditional database PK key .

    Sort Key Sort keys are also called range keys . A lot of times there are hashkey I think it's enough . If the table structure requires a lot of order , I suggest setting this key additionally , Otherwise, don't set , It's best to set less . More settings will increase RCU
     Insert picture description here

then HashKey&SortKey Must be a unique key

  1. Since it's a primary key , Naturally, through separate Hash Key or Hash Key & Sort Key( Composite primary key ) To uniquely identify records .
  2. If you insert a duplicate unique key , The corresponding record will be overwritten ( to update ). This feature is similar to most Nosql The nature of is the same . such as redis MongoDB
  3. Scan Performance degrades as the number of records increases ,Read Capacity Unit Bigger , Cost increase , So it's best to query accurately . Don't move scan, Actually DynamoDb The cost of is very high .
  4. DynamoDB Project size and format

Global index

GSI Is one that can create different Hash Key and Sort Key Function of the table . You can freely add or delete it later , Not just when creating tables . allow hashkey and sortkey coincidence , Use GSI Reading will RCU halve . Use GSI Writing to the table will make WCU double .

In addition to the global index, there are local secondary indexes (LSI)
Can only be created when creating a table
In addition to the global index, there are local secondary indexes (LSI)
Can only be created when creating a table

copyright notice
author[zoobuzas],Please bring the original link to reprint, thank you.

Random recommended