Understanding Amazon DynamoDB

Sep 9, 2019

Share this post


Amazon DynamoDB is one of the non-relational and No-SQL database products from AWS. It supports both key-value and document store. It is serverless and fully managed database service. AWS takes care of all management tasks such as hardware provisioning, setup and configuration, throughput capacity planning, replication, software patching, or cluster scaling. Within few clicks you can setup DynamoDB for your application.

DynamoDB Components

    • Tables, Items, and Attributes
    • Primary Key
    • Secondary Indexes
    • DynamoDB Streams
    • Global Tables
    • DynamoDB Accelerator (DAX)
    • Tables, Items, and Attributes:

      DynamoDB stores data in tables like other database systems. Items can be referred as rows and Attributes can be referred as columns.

    • Primary Key:

      The primary key is used to uniquely identify each item in the table. When creating DynamoDB table, you must specify primary key of that table. There are two types of Primary keys in DynamoDB as …

      • Partition Key:

        It is a simple primary key and has only one part called, Partition key which is used to uniquely locate record in the table.

      • Partition and Sort Key

        : This is a composite primary key which contains partition key and sort key for providing sorting flexibility in addition to unique record identification.

    • Secondary Indexes:

      In addition to primary keys, you can specify secondary key on other attributes to query data. Each table in DynamoDB has a limit of 20 global secondary indexes (default limit) and 5 local secondary indexes per table. There are two types secondary indexes as …

      • Global secondary index:

        An index with a partition key and sort key that can be different from those on the table.

      • Local secondary index:

        An index that has the same partition key as the table, but a different sort key.

      • Each table in DynamoDB has a limit of 20 global secondary indexes (default limit) and 5 local secondary indexes per table.
    • DynamoDB Streams:

      It is an optional feature that supports data modification capture in the name of stream record (undo/redo record). These stream records have like time of 24 hours and after that they will be removed from stream.

    • Global Tables:

      You can create multi-region and multi-master databases with DynamoDB. When you need Global tables, you need to specify regions and DynamoDB takes care of creating identical copies in all the specified regions and applying data changes to copies of tables.

    • DynamoDB Accelerator (DAX):

      DAX is a DynamoDB-compatible caching service for supporting fast in-memory performance for demanding applications.

How It Works?

    • DynamoDB is created by creating table and primary key. You can create DynamoDB table with a few clicks. You need to specify the desired read and write throughput for your table, and DynamoDB handles the rest.
    • DynamoDB has two read/write capacity modes for processing reads and writes on your tables as …
    • On-Demand Mode:

      This mode offers pay-per-request pricing for read and write requests so that you pay only for what you use. When you choose this mode, DynamoDB instantly accommodates your workloads as they ramp up or down to any previously reached traffic level. If a workload’s traffic level hits a new peak, DynamoDB adapts rapidly to accommodate the workload.

    • Provisioned Mode:

      When you choose this mode, you specify the number of reads and writes per second that you require for your application. You can use auto scaling to adjust your table’s provisioned capacity automatically in response to traffic changes. This helps you govern your DynamoDB use to stay at or below a defined request rate in order to obtain cost predictability.

      • Read Request Units:

        It represents one strongly consistent read request, or two eventually consistent read requests, for an item up to 4 KB in size. Transactional read requests require 2 read request units to perform one read for items up to 4 KB. If you need to read an item that is larger than 4 KB, DynamoDB needs additional read request units.

      • Write Request Units:

        It represents one write for an item up to 1 KB in size. If you need to write an item that is larger than 1 KB, DynamoDB needs to consume additional write request units. Transactional write requests require 2 write request units to perform one write for items up to 1 KB.

    • DynamoDB protects user data stored at rest and data in transit between on-premises clients and DynamoDB, and between DynamoDB and other AWS resources within the same AWS Region.
    • On-demand backups and point-in-time recovery is supported with DynamoDB.
    • Table operations are split into four categories as …
      • Control Plane:

        You can create and manage DynamoDB tables with commands “CreateTable, DescribeTable, ListTables, UpdateTable, and DeleteTable”.

      • Data Plane:

        You can create, read, update, and delete actions on data in a table with commands “PutItem, BatchWriteItem, GetItem, BatchGetItem, Query, Scan, UpdateItem, DeleteItem, and BatchWriteItem”.

      • DynamoDB Streams:

        You can enable or disable a stream on a table with commands “ListStreams, DescribeStream, GetShardIterator, and GetRecords”.

      • Transactions:

        Using “TransactWriteItems, TransactGetItems”, batch operations for Put, Update, and Delete on both within and across tables are allowed.