Using DynamoDB to build WebAppsAmazon DynamoDB 1013 min

Amazon DynamoDB 101

Amazon DynamoDB is a fast, flexible, serverless NoSQL database service that delivers single-digit millisecond performance at any scale.

Data Models

DynamoDB supports two main data models: key-value and wide-column. These data models are highly efficient for retrieving items.

The key-value data model allows you to retrieve one item at a time using a primary key. It functions like a massive hash, enabling fast retrieval when the primary key is known.

For more complex access patterns, you can use the wide-column data model provided by DynamoDB. In this model, the hash is still required, but the value for each hash record is a B-tree. A B-tree is a data structure that enables quick element retrieval and range queries.

Main Components

DynamoDB organizes data into tables. You can create or delete a table with a simple API call. Each table contains items, and each item has attributes. Every item requires at least one attribute, which is the partition key. Optionally, you can define a sort key, which becomes another required attribute for each item.

The combination of the partition key and sort key (if defined) forms the primary key, which must be unique. Each item can also have additional attributes, and the set of attributes can vary from item to item.

DynamoDB also supports secondary indexes. While primary keys allow access to data, secondary indexes provide alternative ways to retrieve data efficiently. There are two types of secondary indexes: local secondary indexes and global secondary indexes.

Operations

DynamoDB offers three main types of operations:

  1. Item-based operations: These operations are performed on individual items in a table.
  2. Queries: Queries operate on a group of items that share the same partition key in a table or secondary index. This group is referred to as an item collection.
  3. Scans: Scans retrieve all items in a table, which can be useful when you need to analyze or process the entire dataset.

Pricing

DynamoDB is a cloud-based NoSQL database service that charges customers based on the amount of data stored and the amount of data read and written. The pricing is as follows:

  • Storage costs: Based on the amount of data stored per month, measured in GB-month. This includes data and indexes.
  • Read capacity units (RCUs): Charged for data read from DynamoDB. One RCU is charged for each strongly consistent read per second, two for transactional reads, and half for each eventually consistent read per second (up to 4 KB).
  • Write capacity units (WCUs): Charged for data written to DynamoDB. One WCU is charged for each write per second (up to 1 KB), and two WCUs for each transactional write per second.

For detailed information on DynamoDB pricing, refer to the Amazon DynamoDB Pricing page.


Created by:

Marcia Villalba
Marcia VillalbaMarcia hosts the FooBar Serverless YouTube channel where she publishes content every week related to serverless and the cloud. She has been designing and developing software professionally for 15 years and worked in all the different stages of building scaling and performant software.