Certopolis

AWS Certified Solutions Architect – Associate

DynamoDB on-demand vs provisioned capacity, and when to use DAX

On-demand mode is the default: you pay per request and DynamoDB scales for you, instantly up to double the previous peak. Provisioned mode charges for the reads and writes per second you set, usually with auto scaling, and suits steady, predictable traffic. DAX is an in-memory cache that cuts eventually consistent reads from milliseconds to microseconds; it does not cache strongly consistent reads.

On-demand mode

On-demand is the default and recommended mode for most workloads. You do not plan capacity, and with zero traffic you pay nothing for throughput. A new on-demand table can sustain up to 4,000 writes and 12,000 reads per second. It instantly handles up to double its previous peak. Going beyond double within 30 minutes can cause throttling, so AWS recommends pre-warming the table or spreading the growth over at least 30 minutes.

Pre-warming means raising the table's warm throughput, the number of reads and writes it can support instantly, before an event such as a launch. You can also set a maximum read or write throughput on an on-demand table to cap cost. Requests above that maximum are throttled. Separately, an account has a default table-level quota of 40,000 read and write units, which you can ask to raise.

Provisioned mode and capacity units

In provisioned mode you set reads and writes per second and pay for that capacity hourly, used or not. It fits steady workloads with predictable growth. Auto scaling adjusts capacity toward a target utilization; AWS recommends 70%. It is turned on by default when you create a table in the console.

One read capacity unit is one strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB. One write capacity unit is one write per second for an item up to 1 KB. Sizes round up, so reading 80 items of 3 KB per second with strong consistency needs 80 RCUs.

You can switch a table from provisioned to on-demand up to four times in a rolling 24 hours. You can switch from on-demand to provisioned at any time.

DynamoDB Accelerator (DAX)

DAX is a managed, DynamoDB-compatible cache. It suits read-heavy or bursty workloads, hot keys and apps that need microsecond reads. You use the DAX client in your application and point it at the cluster endpoint; the API calls stay the same.

DAX passes strongly consistent reads and TransactGetItems straight to DynamoDB and does not cache the results. It is not a good fit for apps that need strongly consistent reads, write-heavy apps, or apps with few repeated reads. AWS says DAX performs best when the cache hit rate is above 90%.

DAX has two separate caches. GetItem results go in the item cache. Query and Scan results go in the query cache. Writes through DAX update the item cache only. A cached query result does not change until its TTL expires.

Where the exam catches people

  • Believing DAX speeds up strongly consistent reads: DAX passes them to DynamoDB and caches nothing.
  • Believing a write through DAX refreshes cached Query results: writes update the item cache only; the query cache waits for its TTL.
  • Believing on-demand absorbs any spike instantly: more than double the previous peak within 30 minutes can throttle; pre-warm the table.
  • Believing an on-demand table has no ceiling: a maximum throughput you set, or the account quota, throttles requests above it.
  • Believing one RCU covers any read: it covers one strongly consistent read of up to 4 KB, rounded up by item size.

Written from Amazon Web Services's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A read-heavy application reads the same small set of items from an Amazon DynamoDB table thousands of times a second. Every read sets ConsistentRead to true, although the application can tolerate data that is a few seconds old for all but one of its operations. The team puts a three-node DAX cluster in front of the table and measures no improvement in read latency. The team needs read latency to improve while the one operation that requires current data still receives it. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design High-Performing Architectures building.

    Not that one: A is right. In the game your Design High-Performing Architectures building would lose a little Renown, and this question would come back later.

  2. A leaderboard page runs the same DynamoDB Query through a DAX cluster every time a player opens it. Scores are written through the same DAX client. Players report that a score they have just posted does not appear on the leaderboard for several minutes, although reading the score item directly returns the new value at once. The team needs a newly posted score to appear on the leaderboard promptly. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design High-Performing Architectures building.

    Not that one: C is right. In the game your Design High-Performing Architectures building would lose a little Renown, and this question would come back later.

  3. An Amazon DynamoDB table in on-demand mode has a maximum write throughput of 3,000 write request units per second, set as a cost guard. Its previous peak was about 2,500 writes per second of 1 KB items. A product launch will send about 20,000 writes per second from its first minute. The table must stay in on-demand mode, and launch writes must not be throttled. Which combination of steps should a solutions architect take to meet these requirements? (Select TWO.)

    Right. In the game that’s Renown for your Design High-Performing Architectures building.

    Not that one: A,B is right. In the game your Design High-Performing Architectures building would lose a little Renown, and this question would come back later.