Skip to content

NoSQL: Dynamo

David Liu edited this page Nov 1, 2022 · 15 revisions
  • A table is a collection of items. Works as a collection of documents.
    • Other than the primary key, table is schemaless. Neither the attributes nor their data types need to be defined beforehand.
  • Each item is a collection of attributes.
  • item is uniquely identified by primary keys.
    • Type: Partition key: A simple primary key, composed of one attribute
    • Type: Partition key and sort key: a 2-attribute composite primary key. The first attribute is the partition key, and the second attribute is the sort key. Storage Affinity: All items with the same partition key value are stored together, in sorted order by sort key value.
  • Item represents a single document. Items in DynamoDB are similar in many ways to rows, records or tuples in other database systems.
    • Each item can have its own distinct attributes.
  • Attribuite is a field in document.
    • An attribute is a fundamental data element, something that does not need to be broken down any further.
    • Attributes in DynamoDB are similar in many ways to fields or columns in other database systems.
    • Some of the items have a nested attribute (List, Map, String Set, Binary Set, Number Set). nested attributes support up to 32 levels deep.
  • Beside primary key, secondary indexes provide more querying flexibility and accelaration

Secondary indexes

DynamoDB supports two kinds of indexes:

  • Global secondary index – An index with another attributes as 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. Similar to set another sort key only

Every index belongs to a table, which is called the base table for the index

  • When you create an index, you have to specify which attributes will be copied, or projected, from the base table to the index, otherwise base table attributes will not found in result of query on index. At a minimum, DynamoDB projects the key attributes of the base table into the index.

DynamoDB Accelerator (DAX) for microseconds level response time

DAX addresses three core scenarios:

  • As an in-memory cache, DAX reduces the response times of eventually consistent read workloads by an order of magnitude from single-digit milliseconds to microseconds.
  • DAX reduces operational and application complexity by providing a managed service that is API-compatible with DynamoDB. Therefore, it requires only minimal functional changes to use with an existing application.
  • For read-heavy or bursty workloads, DAX provides increased throughput and potential operational cost savings by reducing the need to overprovision read capacity units. This is especially beneficial for applications that require repeated reads for individual keys.

Dynamo Upstream

You can use DynamoDB Streams to capture data modification events in DynamoDB tables.

  • A CDC for Dynamo
  • Can natively invoke Lambda

In addition to the Amazon DynamoDB web service, AWS provides a downloadable version of DynamoDB that you can run on your computer and is perfect for development and testing of your code.

Usage metrics

Request unit sizes (for on-demand tables)

  • One read request unit = one strongly consistent read, or two eventually consistent reads, for items up to 4 KB in size.
  • Transactional read requests require two read request units to perform one read for items up to 4 KB.
  • One write request unit = one write, for items up to 1 KB in size.
  • Transactional write requests require two write request units to perform one write for items up to 1 KB.

Resource

Samples

Value and Advantages

  • Seamless Data Replication
    • By default, DynamoDB replicates table data in 3 availability zones within a single region. It allows you to easily recover from any disaster and avoid service disruptions.
    • In addition, you can use DynamoDB global tables to replicate data across multiple regions (different geolocations) to achieve a higher level of redundancy.
    • The data replication takes place in near real-time to ensure seamless failover during a disaster while minimizing the data lost.
  • Fast Response Times: single-digit millisecond at any scale. And furthermore with DAX optimized-caching

Limits

  • Limited Querying Options
    • Each table in DynamoDB has a quota of 20 global secondary indexes (default quota) and 5 local secondary indexes.
    • Dynamo relies on the indexes for querying tasks and does not allow querying if no indexes are available
    • Dynamo restricts the complexity of the queries. It does not support table joins
  • Limited Storage Capacities For Items
    • The size limit for an item is 400KB. And it is hard limit
Clone this wiki locally