Amazon DynamoDB is a NoSQL key-value datastore with support for JSON documents.
It can deliver single-digit millisecond performance at large scale.
DynamoDB is serverless and fully managed. It's easy to set up, operate and scale. You don't have to worry about
capacity scaling, hardware & VM provisioning, database setup, patching and more.
It's multi-active, replicated across multiple Availability Zones, durable and secure. It also supports in-memory
caching.
DynamoDB doesn't have it's own query language. Instead, you can use aws-sdk to access the database.
Under the hood
Dynamo DB Table is an abstraction for Amazon Dynamo DB NoSQL database service.
When to use
Advantages
Performance at scale - DynamoDB supports some of the world’s largest scale applications by providing consistent,
single-digit millisecond response times at any scale. You can build applications with virtually unlimited throughput
and storage.
Auto-scalable - DynamoDb has a support for auto-scaling of both read/write capacity and storage.
IAM access - You can manage the access to your DynamoDb database with AWS Identity and Access management rules.
Connection-less - You don't have to worry about connection pool exhaustion.
Serverless - DynamoDb supports "pay-as-you-go" pricing. If there's no database load, it's essentially free.
Disadvantages
Relatively unmature - Not as mature as relational (SQL) databases. It has a significantly less rich ecosystem.
Proprietary - DynamoDb is a proprietary AWS database.
Not feature rich - DynamoDb is more of a data-store, not a fully-featured database such as Postgres or MongoDb.
For a detailed comparison (even tho arguably slightly biased), refer to
MongoDb comparison.
Even in provisioned mode, you can configure throughput scaling based on load.
The table throughput scales up or down once the specified thresholds are met.
Compared to on-demand mode (default, if you don't specify provisionedThroughput), you have more control
of how your table will scale and can save costs. However, your table might not be able to scale enough for an unpredictable load.
You must configure stream type. It determines what information is written to the stream for this table when the item
in the table is modified. Allowed values are:
KEYS_ONLY - Only the key attributes of the modified item are written to the stream.
NEW_IMAGE - The entire item, as it appears after it was modified, is written to the stream.
OLD_IMAGE - The entire item, as it appeared before it was modified, is written to the stream.
NEW_AND_OLD_IMAGES - Both the new and the old item images of the item are written to the stream.
Copy
resources:
myDynamoDbTable:
type: dynamo-db-table
properties:
primaryKey:
partitionKey:
name: this_attribute_will_be_id
type: string
streamType: NEW_AND_OLD_IMAGES
Access control
DynamoDb uses AWS IAM (Identity and Access Management) to control who can access the table.
To interact with the DynamoDb table, your resources must have the sufficient permissions. You can give these
permissions in 2 ways:
listing table in connectTo list of your compute resource
configuring iamRoleStatements on your compute resource
Copy
resources:
myDynamoDbTable:
type: dynamo-db-table
properties:
primaryKey:
partitionKey:
name: id
type: string
myFunction:
type: function
properties:
packaging:
type: stacktape-lambda-buildpack
properties:
entryfilePath: path/to/my/lambda.ts
environment:
-name: TABLE_NAME
value: $ResourceParam('myDynamoDbTable', 'name')
connectTo:
- myDynamoDbTable
Copy
resources:
myDynamoDbTable:
type: dynamo-db-table
properties:
primaryKey:
partitionKey:
name: id
type: string
myFunction:
type: function
properties:
packaging:
type: stacktape-lambda-buildpack
properties:
entryfilePath: path/to/my/lambda.ts
environment:
-name: TABLE_NAME
value: $ResourceParam('myDynamoDbTable', 'name')
iamRoleStatements:
-Resource:
- $ResourceParam('myDynamoDbTable', 'Arn')
Effect:'Allow'
Action:
-'dynamodb:Get*'
-'dynamodb:Query'
-'dynamodb:Scan'
-'dynamodb:Delete*'
-'dynamodb:Update*'
-'dynamodb:PutItem'
Pricing
You are charged for:
Read and Write operations:
PROVISIONED mode:
You configure how much read/write capacity table has at any moment:
WCU (write capacity unit) - $0.00065 - $0.000975 per WCU per hour
RCU (read capacity units - $0.00013 - $0.000195 per RCU per hour