Lesson 1 of 4 Amazon DynamoDB and DAX

Choosing DynamoDB Capacity Modes and Auto Scaling

This lesson explains how capacity governs the performance of Amazon DynamoDB, a serverless key-value and document database, and how operating it well means choosing the right capacity mode and watching for throttling.

Learning outcomes

After completing this lesson, you will be able to:

  • Calculate read and write capacity units.
  • Choose between on-demand and provisioned capacity with auto scaling.
  • Account for global secondary index capacity.

Read and write capacity

Capacity is measured in read capacity units (RCUs) and write capacity units (WCUs). One RCU provides one strongly consistent read per second, or two eventually consistent reads, of an item up to 4 KB; transactional reads cost twice as much. One WCU provides one write per second of an item up to 1 KB; transactional writes cost twice as much. Larger items consume more units, rounded up. For example, reading 100 items of 6 KB per second with strong consistency needs 200 RCUs (each 6 KB read rounds up to 8 KB, two units).

4KB

Item size covered by one RCU

1KB

Item size covered by one WCU

Fill in the value

Capacity units

Exam skills 2.1.3

Calculate the capacity units a workload needs.

Log in to try this activity Interactive activities are free with an account.

On-demand and provisioned modes

In on-demand mode, the default for new tables, you pay per request and DynamoDB accommodates traffic up to double the previous peak instantly, scaling further over time; an optional maximum throughput protects against runaway cost, and warm throughput can be pre-warmed before a known event. In provisioned mode you set RCUs and WCUs, which is cheaper for steady, predictable traffic, and auto scaling (Application Auto Scaling target tracking) adjusts them to keep consumed capacity near a target utilisation such as 70%. Auto scaling reacts in minutes, so sudden spikes can still be throttled; burst capacity (up to 5 minutes of unused capacity) absorbs short spikes. Tables can switch modes, with limits on how often.

ModeBillingBest for
On-demandPer requestNew, unpredictable or spiky workloads; low operational effort
Provisioned with auto scalingPer provisioned unit-hourSteady or gradually changing traffic; lower cost at scale
Provisioned with reserved capacityUpfront commitmentVery stable, high baseline traffic
Sort into groups

Which capacity mode?

Exam skills 2.1.3

Choose the capacity mode for each table.

Log in to try this activity Interactive activities are free with an account.

Global secondary indexes and capacity

A global secondary index (GSI) has its own capacity in provisioned mode, and every write to the table that affects the index also consumes index write capacity. If a GSI is under-provisioned, it throttles and causes writes to the base table to be throttled too. Auto scaling should therefore be enabled on GSIs as well as the table. Local secondary indexes share the table's capacity.

The following diagram shows an index throttling writes to its table.

How an under-provisioned global secondary index throttles the table. In provisioned mode, every table write that affects the index also consumes the index's write capacity. When the GSI runs out, its throttling backs up and writes to the base table are throttled too, even though the table has capacity to spare.
The capacities are illustrative. The fix is capacity on the GSI, not on the table.
Worked example

Moving to provisioned capacity

A table in on-demand mode has served a steady 2,000 writes and 8,000 eventually consistent reads of 2 KB items per second for six months, with a predictable daily curve. The team switches it to provisioned mode with auto scaling targeting 70% utilisation, minimum 2,500 WCUs and 5,000 RCUs (8,000 eventually consistent reads of up to 4 KB need 4,000 RCUs), and enables the same scaling on the table's GSI. Monthly cost falls significantly. They keep an alarm on WriteThrottleEvents and plan to pre-warm or switch back to on-demand before a marketing campaign with unknown demand.

Check yourself

Why can an under-provisioned GSI throttle the base table?

Show answer

Writes to the table must also be written to the index, so they are throttled when the index lacks capacity.

Exam Tips

Remember for the exam

  • 1 RCU = 1 strongly consistent (or 2 eventually consistent) 4 KB read per second; 1 WCU = one 1 KB write per second.
  • On-demand for unpredictable traffic; provisioned with auto scaling for steady traffic.
  • Under-provisioned GSIs throttle writes to the base table.
  • Auto scaling reacts in minutes; sudden spikes can still throttle.