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.


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.

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.

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).
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.

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.

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.

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.

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.

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.
Links and references
- Amazon DynamoDB Documentation
- DynamoDB Global Tables
- DynamoDB Transactions
- Amazon DAX (DynamoDB Accelerator)
- AWS Backup and cross-region backup patterns
- Amazon Route 53 documentation