Amazon DynamoDB
A fully managed NoSQL database service that guarantees single-digit millisecond latency and automatically scales to handle any level of traffic
Overview
Amazon DynamoDB is a fully managed NoSQL database service that supports both key-value and document data models. It consistently delivers single-digit millisecond response times regardless of data volume or request count. After creating a table, you can choose between two billing modes: on-demand mode, which delegates capacity management to AWS, and provisioned mode, which lets you specify throughput in advance. With the Global Tables feature, data is automatically replicated across multiple regions, enabling a multi-region, multi-active configuration with read and write access in each region. DynamoDB Streams captures table changes in real time, allowing you to run event-driven processing with Lambda functions.
Partition Key Design and Avoiding Hot Partitions
A DynamoDB table has a primary key consisting of a partition key and an optional sort key. Data is internally distributed across storage partitions based on the partition key value, making partition key design the single most important factor for performance. Choosing a high-cardinality attribute (such as user ID, order ID, or device ID) as the partition key ensures even distribution of data and requests across partitions. Conversely, using a low-cardinality attribute (such as date, status, or category) as the partition key causes the hot partition problem, where read and write traffic concentrates on a small number of partitions, leading to throttling even when overall table capacity is sufficient. For access patterns that inherently have low cardinality, a common mitigation is to append a random suffix to the partition key (write sharding) and fan out reads across the sharded keys. Global Secondary Indexes (GSIs) enable efficient queries on attributes other than the primary key, but each GSI consumes additional storage and write throughput proportional to the projected attributes, so it is important to keep them to a minimum and project only the attributes you need.
Criteria for Choosing Between On-Demand and Provisioned Modes
DynamoDB offers two capacity modes with fundamentally different cost and scaling characteristics. On-demand mode delegates capacity management entirely to AWS, automatically scaling to handle any level of traffic with no capacity planning required. It costs approximately $1.25 per million read request units and $6.25 per million write request units, making it ideal for unpredictable or spiky workloads, new applications where traffic patterns are unknown, and development/test environments. Provisioned mode lets you specify read and write capacity units in advance, with Auto Scaling adjusting capacity based on utilization targets. It is significantly cheaper for steady-state workloads - up to 5-7x less expensive than on-demand at sustained high throughput. The decision criteria are straightforward: use on-demand when traffic is unpredictable or bursty, and switch to provisioned mode once traffic patterns stabilize and you can forecast capacity needs. Unlike Azure Cosmos DB's RU (Request Unit) based billing where the cost per operation varies with data size and query complexity, DynamoDB's pricing is more predictable since read and write costs are fixed per request unit regardless of item size (up to 4 KB for reads, 1 KB for writes). Specialized books (Amazon) are a great resource for deepening your practical knowledge.
Operational Optimization with DAX, TTL, and Backups
DynamoDB Accelerator (DAX) is an in-memory caching layer purpose-built for DynamoDB that reduces read latency from single-digit milliseconds to microseconds. DAX is fully compatible with the DynamoDB API, requiring minimal code changes - you simply point your client to the DAX cluster endpoint. It is most effective for read-heavy workloads with repeated access to the same items, such as session stores, product catalogs, and leaderboards. The TTL (Time to Live) feature automatically deletes expired items at no additional cost, making it essential for managing time-sensitive data like session records, temporary tokens, and event logs without manual cleanup scripts. For data protection, Point-in-Time Recovery (PITR) allows you to restore a table to any second within the past 35 days, providing fine-grained recovery from accidental writes or deletes. Combining PITR with on-demand backups (which are retained indefinitely until explicitly deleted) provides comprehensive data protection. DynamoDB Streams captures item-level changes in real time, enabling event-driven architectures where Lambda functions react to data changes for tasks like updating search indexes, sending notifications, or replicating data to other stores.