Skip to main content
Welcome, students. This lesson covers Amazon DynamoDB, core NoSQL concepts, and high-availability (HA) patterns you should know for interviews and exams. Read through the examples and architecture patterns to understand how DynamoDB supports scalable, resilient applications.

NoSQL vs SQL — a quick refresher

  • SQL (Structured Query Language): used for relational data with rigid schemas, joins, and normalized tables.
  • NoSQL (“Not Only SQL”): supports flexible schemas and alternative data models—key-value, document, column-family, and graph—designed for large volumes, rapid changes, and horizontal scaling.
A side-by-side diagram comparing SQL (left) shown as a grid/table of rows and columns, and NoSQL (right) illustrated as key–value pairs with arrows from keys to values.
NoSQL covers several common data models. The table below summarizes them with typical use cases:
A slide titled "NoSQL" showing four colorful icons and labels for database types: Key-Value Stores, Document Stores, Column-Family Stores, and Graph Databases. Each icon visually represents the corresponding data model (keys/values, a document, a column grid, and a node-link graph).
Tip: When designing for DynamoDB, always start with access patterns. Model your partition and sort keys to match your most frequent queries to minimize expensive scans and to keep latency predictable.

DynamoDB overview

Amazon DynamoDB is AWS’s fully managed NoSQL database service optimized for performance at scale. It primarily serves as a key-value and document store and integrates tightly with the AWS ecosystem (Lambda, API Gateway, CloudWatch, IAM). Key points:
  • Fully managed with automatic replication across Availability Zones (AZs) within a region for high availability.
  • Use Amazon DAX (DynamoDB Accelerator) for microsecond-read caching; standard DynamoDB typically achieves low-millisecond latency with good design.
  • DynamoDB Streams provide ordered, item-level change capture for triggers, analytics, and event-driven systems.
A presentation slide titled "Features" with a central blue database/server icon. Surrounding circular icons and labels list capabilities like Stream Integration, Integrated with AWS Ecosystem, Performance at Scale, Fully Managed, Seamless Scalability, and High Availability and Durability.

Transactions and ACID support

Although DynamoDB is a NoSQL store, it supports transactions that provide ACID guarantees across multiple items and tables when needed:
  • Atomicity: group writes succeed together or not at all.
  • Consistency: transactional constraints ensure valid results or failure.
  • Isolation: in-flight transaction changes are not visible until commit.
  • Durability: committed changes persist despite failures.
Use DynamoDB transactions when you require cross-item consistency beyond standard single-item operations.
A presentation slide titled "DynamoDB Transactions – ACID Properties" showing four colored panels labeled Atomicity, Consistency, Isolation, and Durability with simple icons beneath each (toggles, scales, locked database, and servers with a shield).

DynamoDB data model basics

  • Table: a collection of items.
  • Item: a single record in a table.
  • Attributes: fields on an item; DynamoDB is schema-flexible—items in the same table can have different attributes.
  • Primary key:
    • Simple primary key (partition key only).
    • Composite primary key (partition key + sort key) for one-to-many modeling and range queries.
  • Attributes may be nested documents (Map) and lists (List).
Example item (JSON):
Design composite keys to match access patterns—for example, use EmployeeID for direct lookups or a composite key like Department#EmployeeID to query by department with employee range sorting.

Global Tables and multi-region replication

  • DynamoDB Global Tables replicate tables across multiple AWS Regions and enable multi-region, multi-master (active-active) writes.
  • Replication is asynchronous and eventually consistent across regions; typical lag is small but not synchronous—design with eventual consistency in mind.
  • Global Tables lower latency for geographically distributed users and improve resilience and disaster recovery.
Global Tables enable local reads and writes in the nearest region and then asynchronously replicate to other regions. If your application requires strict, immediate consistency across regions, design accordingly—Global Tables provide eventual consistency across regions.
A diagram titled "DynamoDB Global Table" showing three replicated database nodes (Replica 1, Replica 2, Replica 3) connected in a triangle to illustrate replication and multi-active writes. The right side lists benefits: low latency for global users, multi-active write capability, and disaster recovery/fault tolerance.

Backups and point-in-time recovery (PITR)

  • On-demand backups and continuous PITR are supported.
  • PITR uses incremental backups so you can restore to any second within the retention window.
  • Cross-region and cross-account backups improve compliance and disaster recovery strategies.
A diagram titled "Cross-Region and Cross-Account Backup (CRAB)" showing an AWS architecture where a DynamoDB table in a source account/region is backed up via AWS Backup into an AWS Backup vault in a destination account/region. Arrows indicate the cross-account, cross-region backup flow between the vaults.

Single-region vs multi-region deployment patterns

  • Single-region common pattern: API Gateway -> Lambda -> DynamoDB.
  • For global traffic: use Global Tables + Route 53 (or AWS Global Accelerator) for regional routing and health checks to reduce latency and increase resilience.
  • Trade-offs: Global Tables add complexity and cost; cross-region replication is eventually consistent.
An AWS architecture diagram showing Amazon Route 53 performing application recovery controller health checks and routing traffic to two regions (us-east-1 and us-west-1). Each region contains an Amazon API Gateway calling AWS Lambda functions that read/write to an Amazon DynamoDB Global Table replicated between regions.

Benefits for mission-critical applications

  • Fault tolerance across AZs and (when used) across regions with Global Tables.
  • Reduced latency for global users via local reads/writes.
  • Built-in resilience via backups, PITR, and cross-account recovery options.
A presentation slide titled "Benefits" showing four rounded items with colorful icons: Fault tolerance, Global replication, improved regional performance, and resilience for mission-critical apps. The slide is branded © Copyright KodeKloud.

Active-active and multi-region architecture pattern

  • Active-active (multi-master) reduces latency and improves availability when combined with Global Tables and regional application stacks (ALB/ELB, ASG, app servers, APIs).
  • Typical pattern: users connect to a regional front-end (CloudFront, ALB), which invokes regional application servers that operate on local DynamoDB replicas. Changes asynchronously replicate across regions; PITR and continuous backups provide recovery options.
A diagram titled "Active-Active Setup" showing an AWS multi-region architecture. It depicts two mirrored regions with VPCs and availability zones, each using Elastic Load Balancers, auto-scaling front-end and application servers, DynamoDB (with continuous backup and global tables), and Route 53 for routing.

Summary and best practices

  • DynamoDB is a scalable, fully managed NoSQL service for high-throughput, low-latency workloads.
  • Always design table keys and secondary indexes based on access patterns to avoid scans.
  • Use DynamoDB transactions when ACID guarantees across multiple items or tables are required.
  • Global Tables provide multi-region replication and active-active writes but are eventually consistent—plan application semantics accordingly.
  • Combine Global Tables, backups/PITR, regional routing (Route 53 or Global Accelerator), and caching (DAX or application-level caches) to build highly available, resilient global applications.

Watch Video