Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Amazon DynamoDB is a fully managed NoSQL database built for applications whose data model and queries can be designed around known access patterns. The central design decision is the primary key: it identifies each item and determines how the table supports reads and writes. Capacity mode, indexes, Streams, transactions, TTL, and multi-Region settings build on that foundation.

What is DynamoDB?

DynamoDB organizes data into tables, items, and attributes. A table contains items; each item is a collection of attributes, and its primary key uniquely identifies it. Unlike a relational design centered on joins between normalized tables, DynamoDB asks developers to choose keys and indexes that support the reads and writes an application needs.

That makes data modeling part of application design, not a step to postpone until after tables are created. Before settling on a table, list the important queries, the items each query needs, and how frequently those reads and writes occur. Then decide whether the table’s primary key alone can serve those queries or whether secondary indexes are justified.

How do partition keys and sort keys work?

Partition key

The partition key is the primary key attribute used to organize and distribute items. A table with a partition key alone requires each item to have a unique value for that key. Choose values that fit the application’s query patterns and distribute activity sensibly; a design that directs too much traffic to a narrow set of key values can undermine the benefits of distributing work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Composite primary key

A composite primary key combines a partition key and a sort key. The partition key identifies a group of related items, while the sort key distinguishes items within that group and gives the application an ordered key dimension. For example, an illustrative order table might use a customer identifier as its partition key and an order timestamp or order identifier as its sort key. That can support retrieving a customer’s orders as a group and ordering or narrowing them by the sort-key design.

Choose key values to match actual access patterns rather than merely echoing an entity diagram. A useful design exercise is to write each query in plain language—such as “get all orders for one customer in date order”—and check whether the planned key can answer it directly. If a required query depends on an attribute that is not part of an appropriate key, consider a secondary index or a different model before implementation.

When should you use a secondary index?

A secondary index creates an additional key path for reading items whose access pattern is not served by the table’s primary key. A global secondary index can span the table’s partitions; a local secondary index stays within the base table’s partition-key scope. This difference matters: an index is not just a convenient field lookup, but a commitment to a particular query shape.

  • Use an index when an important, recurring read needs a different key than the base table provides.
  • Account for its costs in storage and write maintenance: changes to indexed data must be reflected in the index.
  • Avoid speculative indexes for queries that are not established requirements; each extra access path adds design and operational complexity.

For each proposed index, record the query it enables, the key attributes it uses, and the reason the base-table key cannot serve that query. That simple mapping helps keep indexes tied to concrete application needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On-demand or provisioned capacity?

DynamoDB offers two throughput modes. On-demand automatically manages throughput and bills read and write requests by use. Provisioned capacity requires the developer to configure read and write capacity and bills for the provisioned amount. There is no universal cheaper choice: workload shape, predictability, region, table class, request size, and additional features affect total cost.

Consideration On-demand Provisioned
Capacity planning Throughput is managed automatically. Configure read and write capacity.
Billing basis Pay per read and write request used. Pay for configured provisioned capacity.
Workload fit Useful when traffic is variable or difficult to forecast. Useful when capacity is predictable and can be governed.
Operational trade-off Less capacity planning; still monitor usage and cost. More direct capacity control; requires planning and adjustment as workload changes.

Use on-demand when avoiding capacity forecasting is valuable or traffic is uneven. Consider provisioned mode when demand is sufficiently predictable for the team to plan and manage configured capacity. Compare actual workload and regional pricing rather than assuming either mode is always less expensive.

What are DynamoDB Streams used for?

DynamoDB Streams captures table item changes—insertions, updates, and deletions—near real time. Stream records are retained for 24 hours, and a stream can invoke AWS Lambda for event-driven processing. This makes Streams useful when another part of an application needs to react to a change without waiting for a separate polling process.

  • Projections: update a derived view when source items change.
  • Notifications: start a notification workflow after a relevant write.
  • Audit or integration pipelines: pass change events to a downstream consumer.

Design the consumer with the retention window in mind: a consumer that falls behind beyond the 24-hour record lifetime cannot rely on those old stream records still being available. Streams support event-driven workflows, but they do not remove the need to handle consumer failures and lag deliberately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do DynamoDB transactions work?

DynamoDB transactions provide ACID behavior for coordinated operations: the participating changes succeed together or fail together. APIs including ExecuteTransaction and TransactWriteItems support coordinated writes across items and tables. Use a transaction when correctness depends on multiple related changes being treated as one operation—for example, keeping two records consistent when a business action changes both.

Transactions address atomicity across those operations; they do not replace thoughtful key design, eliminate throughput considerations, or make every write transactional by default. Apply them where all-or-nothing behavior is a real correctness requirement, and include their workload and cost implications in capacity planning.

What does DynamoDB TTL do?

Time to Live (TTL) lets a table use a configured attribute containing an epoch timestamp to mark items for expiration. DynamoDB deletes expired items asynchronously, so TTL is appropriate for lifecycle cleanup, not for scheduling deletion at an exact instant. AWS documents that deletion of expired items does not consume write capacity on the source table.

Global tables have an additional cost consideration: replicated TTL deletes can consume write capacity in replica tables. Account for that effect when estimating costs for data that expires across Regions, and do not treat TTL as a precise-time mechanism.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What changes when you use global tables?

Global tables require an explicit consistency choice. AWS distinguishes multi-Region eventual consistency from multi-Region strong consistency; replication behavior, Streams behavior, transaction semantics, conflict handling, supported Regions, latency, and cost depend on the selected mode. Do not assume that a single-Region design’s consistency or transaction behavior transfers unchanged to a global-table configuration.

Before choosing a mode, verify that the Regions you need are supported and evaluate the application’s tolerance for latency, conflicting changes, and replication behavior. Then check how the chosen mode affects the transactions and stream consumers on which the application depends. The right choice follows from those requirements rather than from a blanket preference for stronger or faster consistency.

Is DynamoDB a good fit for your workload?

DynamoDB is a strong candidate when the application has identifiable access patterns that can be served by carefully chosen keys and indexes, and when the team values a managed NoSQL service with automatically managed throughput available as an option. It is a less natural fit when requirements depend on queries that cannot be planned around the available keys and indexes or when the team has not yet established its important access patterns.

  • Start with the queries: enumerate the reads and writes the application must support.
  • Model the keys: show how the primary key serves each important access pattern.
  • Justify indexes: add them for specific read paths and include their storage and write-maintenance effects.
  • Choose capacity deliberately: compare request-based billing and managed throughput with configured capacity and its planning needs.
  • Decide how changes and data lifecycle work: determine whether consumers need Streams, operations need transactions, or records need TTL expiration.
  • Review regional requirements: select a global-table consistency mode only after checking its implications for replication, streams, transactions, conflicts, and cost.

DynamoDB’s scalability does not make modeling decisions optional. Its fit depends on whether the application’s access patterns, correctness needs, and operating model can be expressed clearly through its keys, indexes, capacity mode, and selected features.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.