Lesson 3 of 4 Amazon DynamoDB and DAX

Offloading Reads with DynamoDB Accelerator

This lesson explains DynamoDB Accelerator (DAX), an in-memory cache built for DynamoDB that reduces read latency from milliseconds to microseconds and offloads read traffic from tables.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how a DAX cluster serves reads.
  • Decide when to use DAX and when not.
  • Scale and monitor a DAX cluster.

How DAX works

A DAX cluster runs in your VPC with a primary node and up to ten read replica nodes across AZs. Applications use the DAX client (a drop-in replacement for the DynamoDB client for supported SDKs) and connect to the cluster endpoint. DAX keeps an item cache for GetItem and BatchGetItem results and a query cache for Query and Scan results, each with a TTL (5 minutes by default). It is a write-through cache: writes go through DAX to DynamoDB and update the item cache. Strongly consistent reads and transactional operations are passed directly to DynamoDB and are not cached.

5min

Default TTL of the item and query caches

When to use DAX and when not

DAX suits read-heavy workloads that need microsecond latency, repeated reads of the same items (for example a product catalogue or game leaderboard during an event), and reducing provisioned read capacity. It does not help write-heavy workloads, applications that require strongly consistent reads, or workloads whose reads rarely repeat. ElastiCache is the alternative when caching data from several sources or needing data structures such as sorted sets. The following table compares them for DynamoDB caching.

DAX
IntegrationAPI-compatible DynamoDB client; no cache code
Caching patternWrite-through and read-through for DynamoDB
LatencyMicroseconds for cached reads
Strongly consistent readsPassed through, not cached
ElastiCache
IntegrationApplication implements caching logic
Caching patternAny pattern, any data source
LatencySub-millisecond
Strongly consistent readsDepends on application logic
Sort into groups

Is DAX a good fit?

Exam skills 2.1.2 · 2.1.3

Decide whether DAX suits each workload.

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

Operating DAX

Scale DAX out by adding nodes for more read throughput, or up with larger node types for a bigger cache. Monitor ItemCacheHits and ItemCacheMisses, QueryCacheHits and QueryCacheMisses, CPUUtilization and EvictedSize. A DAX cluster needs an IAM role to access DynamoDB, a subnet group and a security group allowing port 8111 (or 9111 with encryption in transit) from clients. Use at least three nodes in different AZs for production.

Worked example

A flash sale

A retailer expects a flash sale where 50,000 users per second read the same 200 product items. Without caching, those reads would concentrate on a few partitions. The team deploys a three-node DAX cluster in three AZs, switches the product service to the DAX client and keeps eventually consistent reads. During the sale the item cache hit rate exceeds 99%, table read consumption stays low, and latency stays under 1 millisecond. Stock-level checks that need strong consistency still go directly to DynamoDB.

Check yourself

Are strongly consistent reads served from the DAX cache?

Show answer

No. They pass through DAX to DynamoDB.

Exam Tips

Remember for the exam

  • DAX is a write-through, in-memory cache for DynamoDB with microsecond reads.
  • Strongly consistent reads bypass DAX.
  • DAX helps read-heavy, repetitive access; not write-heavy workloads.
  • Run at least three nodes across AZs in production.