· Jay Smith · Articles  · 9 min read

Amazon DynamoDB - NoSQL Database in the Cloud

Exploring the principles and tools of Continuous Integration and Continuous Deployment (CI/CD) in AWS environments.

Exploring the principles and tools of Continuous Integration and Continuous Deployment (CI/CD) in AWS environments.

Amazon DynamoDB is a fully managed NoSQL database service provided by Amazon Web Services (AWS). DynamoDB is a key-value and document database that delivers reliable performance at scale.

Key features of DynamoDB include:

  • Managed service - no servers to provision, patch or manage
  • Scalability - seamless scaling to handle any workload
  • Availability - spread across multiple Availability Zones
  • Performance - consistent, low-latency response times
  • Security - encryption, access control, compliance

DynamoDB is a great choice for modern applications that need a flexible NoSQL database with intuitive APIs and solid SLAs. It’s used by many large-scale cloud applications due to its predictable scaling and throughput.

DynamoDB Architecture

DynamoDB uses a hybrid architecture that blends elements of key-value stores and document databases.

Data Model

The core components of the DynamoDB data model are:

  • Tables - A collection of data
  • Items - A group of attributes that makeup an object
  • Attributes - A fundamental data element (key-value pair)

Each table contains zero or more items, and each item is composed of one or more attributes.

DynamoDB is schemaless, so items in the same table can have different attributes.

Primary Keys

Each item in a table is uniquely identified by a primary key. This can be either:

  • Partition key - Uniquely identifies an item
  • Partition key + Sort key - Combination that identifies an item

The partition key determines which partition an item is stored in.

The sort key orders items with the same partition key.

Secondary Indexes

DynamoDB supports two kinds of secondary indexes:

  • Local secondary index - Has the same partition key as the table but a different sort key.
  • Global secondary index - Has a different partition and sort key combination. Allows querying on attributes other than the table’s primary key.

Secondary indexes allow you to query data in different ways and can help improve query performance.

Partitions

Behind the scenes, DynamoDB partitions data in a table based on its primary key attributes.

The number of partitions is transparent to users but factors like throughput and table size determine how many partitions a table has.

This partitioning and horizontal scaling allows DynamoDB to handle extremely high read and write loads.

Streams

DynamoDB Streams provide an ordered stream of changes to items in a table. This allows capturing inserts, updates, and deletes so they can trigger workflows and notifications.

Overall, DynamoDB combines elements of key-value and document databases with proprietary partitioning and infrastructure techniques to deliver a managed NoSQL database that can scale smoothly.

DynamoDB Performance

DynamoDB delivers reliable performance by allowing you to specify your capacity requirements upfront.

Read/Write Capacity Units

When you create a table, you specify your capacity requirements in terms of read and write capacity units:

  • Read capacity units (RCUs) - Throughput for read operations per second
  • Write capacity units (WCUs) - Throughput for write operations per second

You can scale up or down anytime to meet changing demands.

DynamoDB will evenly partition and allocate your requested RCUs and WCUs across partitions.

If your requests exceed provisioned capacity, requests will be throttled with exceptions.

Scaling

DynamoDB handles scaling seamlessly:

  • Scale up/down via API calls
  • New partitions added transparently
  • Data distributed automatically

Scalability is a key benefit of DynamoDB - no downtime required to grow or shrink capacity.

Availability

Availability is also built into DynamoDB’s architecture:

  • Data replicated across multiple AZs
  • Spread across partitions
  • No single point of failure

Your minimum read and write capacity are guaranteed with financial SLAs.

By allowing you to provision read and write throughput and handling scalability and availability automatically, DynamoDB provides consistent, fast performance at any scale.

DynamoDB Data Model

The DynamoDB data model is flexible but uses some core building blocks.

Items

An item is a collection of attributes that makes up an object or record. For example, a Book item could have ISBN, Title, and Author attributes.

Items in DynamoDB are schema-less so each item can contain different attributes.

Attributes

Attributes are fundamental data elements in DynamoDB. Each attribute has a name and a value.

For example, an ISBN attribute could have a name of “ISBN” and a value of “978-3-16-148410-0”.

Attribute values can be strings, numbers, binary data, or sets. Nested attributes up to 32 levels deep are also supported.

Keys

Each item in a table is uniquely identified by the primary key attribute(s). A primary key can be:

  • Partition key - A simple primary key (e.g. UserId)
  • Partition key and sort key - A composite key (e.g. UserId + CreateDate)

The partition key determines which partition the item will be stored in.

The optional sort key orders items with the same partition key value.

Secondary Indexes

You can define secondary indexes on attributes other than the table’s primary key:

  • Local secondary index - Alternative key for table queries
  • Global secondary index - Fully separate index for queries Proper indexes optimize query performance while maintaining flexibility.

The DynamoDB data model allows you to keep related data together in an item while maintaining high performance querying through judicious use of keys and secondary indexes.

DynamoDB Query Language

DynamoDB provides a simple yet powerful JSON-based query language.

JSON Documents

Requests to read, write, update, or delete data are expressed as JSON documents that are sent to DynamoDB endpoints.

Operations

The main DynamoDB operations include:

  • PutItem - Write new item
  • UpdateItem - Update existing item
  • DeleteItem - Delete item
  • GetItem - Read single item
  • Query - Read multiple items
  • Scan - Read entire table

These simple CRUD-style operations provide the building blocks for data access.

Query Expressions

More complex read queries can be constructed using KeyConditionExpressions and FilterExpressions.

These allow constructing relational-style queries on attributes, indexes, and values while still using the JSON document structure.

Transactions

For use cases that require “all-or-nothing” updates, DynamoDB supports ACID transactions to group conditional writes and reads together.

The DynamoDB query language combines simplicity and power for manipulating data in a scalable key-value store.

DynamoDB Streams

DynamoDB Streams provide a time-ordered sequence of item-level changes in a table.

Stream Contents

Each stream record contains:

  • An image of the item before and after the change
  • Insert, update, or delete operation type
  • Timestamp

Stream records are organized by partition key order.

Use Cases

Streams enable powerful patterns such as:

  • Replication - replicate data between tables
  • Analytics - analyze changes for metrics
  • Triggers - trigger workflows on data changes
  • Archival - log changes to another data store

Reading Streams

Applications can read streams using the DynamoDB API:

  • GetShardIterator retrieves pointer to stream
  • GetRecords reads batch of stream records

Results are paginated using limit and exclusive start shard key parameters.

Ordering Guarantees

DynamoDB streams provide an ordered sequence within a shard but only eventual ordering across shards.

Applications should be designed for at-least-once delivery.

Limits

There are some limits to be aware of:

  • Only one stream per table
  • Pay per read stream throughput
  • Records expire after 24 hours

Overall, DynamoDB Streams allow capturing changes for downstream processing while introducing minimal performance impact on the source table.

DynamoDB Security

DynamoDB provides robust security capabilities to protect data.

Authentication

Access control is managed through AWS Identity and Access Management (IAM).

IAM allows managing:

  • Users, groups, roles
  • Fine-grained permissions
  • Multi-factor authentication
  • Temporary security credentials

All access to DynamoDB must be authenticated and authorized through IAM.

Authorization

IAM policies determine what DynamoDB actions a user can perform.

Policies can be applied at multiple levels:

  • User policies
  • Group policies
  • Resource policies

For example, user policies could restrict production access.

Encryption

Encryption at rest encrypts data on the servers that host DynamoDB.

Encryption uses AES-256 and is enabled by default.

Encryption in transit via TLS secures all data to DynamoDB endpoints.

Compliance

DynamoDB is compliant with standards including:

  • SOC, PCI DSS, ISO
  • HIPAA, FedRAMP

This allows using DynamoDB for regulated workloads.

Backup

You can enable automatic on-demand backups or point-in-time recovery.

Backups can be retained for up to 35 days.

DynamoDB provides robust security capabilities to protect critical production data at scale.

DynamoDB Pricing

DynamoDB uses a pay-per-use model with no upfront costs.

Read/Write Units

You are charged for the read and write throughput capacity you provision:

  • Per provisioned read capacity unit
  • Per provisioned write capacity unit

Unused read/write capacity is not charged.

Storage

You are charged for storage used per month:

  • Per GB of data stored
  • Minimum storage of 10 GB per table

Infrequent Access and On-Demand capacity modes can lower costs.

Streams

Reading stream records incurs normal DynamoDB read charges:

  • Per read capacity unit
  • Items returned

Global Tables

Multi-region replication incurs:

  • Normal DynamoDB charges in each region
  • Data transfer charges between regions

Free Tier

The DynamoDB free tier includes:

  • 25 GB storage
  • 25 RCUs
  • 25 WCUs

This allows experimenting at low cost.

Cost Optimization

Strategies to optimize costs include:

  • Provision throughput carefully
  • Use on-demand capacity sparingly
  • Delete unused tables
  • Archive old data

The pay-per-use model lets you get started at any scale and pay only for what you use.

DynamoDB Use Cases

DynamoDB’s flexible data model and predictable performance make it well-suited for many applications.

High Volume Apps

DynamoDB handles extreme read and write loads for high volume applications such as:

  • Mobile apps
  • Real-time analytics
  • Ad tech
  • Gaming backends
  • IoT systems

The auto-scaling and provisioned capacity model shine for spiky or unpredictable workloads.

Session Storage

DynamoDB’s low latency read and writes work very well for storing user session data and user profiles.

Its simple API makes it easy to store session data at scale.

Serverless Apps

DynamoDB is accessible via API calls making it a natural fit for serverless applications built on AWS Lambda.

Functions can directly access DynamoDB for data storage and retrieval.

Gaming

DynamoDB’s performance make it ideal for mobile, social, and multiplayer games that require:

  • Low latency data access
  • User data storage
  • Leaderboards
  • Live game data

Gaming platforms like GameSparks use DynamoDB for its scale and speed.

IoT

For IoT use cases, DynamoDB easily ingests and processes streams of data from devices.

It can act as an operational data store directly handling writes at scale from many devices.

DynamoDB supports a wide variety of demanding, large scale applications thanks to its flexible data model and lean operations.

Conclusion

Amazon DynamoDB provides a fully managed, highly scalable NoSQL database optimized for internet-scale applications.

Key capabilities include:

  • Flexibility - Schemaless JSON data model
  • Performance - Predictable throughput and latency
  • Scalability - Auto sharding and partitioning
  • Availability - Multi-AZ redundancy
  • Security - Encryption, IAM, and compliance

Its simple APIs make it easy for developers to get started while its enterprise-grade features ensure DynamoDB can power mission-critical systems.

Use cases where DynamoDB excels include:

  • High volume apps
  • Mobile apps
  • Gaming backends
  • IoT systems
  • Serverless applications

DynamoDB delivers an innovative serverless database offering combining powerful functionality with ease-of-use and built-in scalability and durability.

For modern applications with demanding data requirements, DynamoDB is an ideal fully managed cloud database. Here is a concluding paragraph with a call to action for readers to contact God Particle IT Group for enterprise-level IT services:

Looking for help with Amazon DynamoDB or other advanced cloud technologies? The IT professionals at God Particle IT Group have the skills and experience to architect, build, and manage complex systems at scale. We specialize in cloud platforms like AWS and can provide enterprise-level support to develop and operate DynamoDB-based applications. Whether you need assistance with design, implementation, optimization, or managed services, contact us to see how we can help launch your next innovating using DynamoDB. With deep expertise across today’s leading technologies, God Particle IT Group offers responsive, high-touch services to innovate faster.

Back to Blog

Related Posts

View All Posts »