AWS DynamoDB Accelerator DAX
- DynamoDB Accelerator (DAX) is a fully managed, highly available, in-memory cache for DynamoDB that delivers up to a 10x performance improvement – from ms to µs – even at millions of requests per second.
- DAX as a managed service handles the cache invalidation, data population, or cluster management.
- DAX provides API compatibility with DynamoDB. Therefore, it requires only minimal functional changes to use with an existing application.
- DAX saves costs by reducing the read load (RCU) on DynamoDB.
- DAX helps prevent hot partitions.
- DAX is intended for high-performance read applications. As a write-through cache, DAX writes directly so that the writes are immediately reflected in the item cache.
- DAX only supports eventual consistency and strong consistency requests are passed through to DynamoDB.
- DAX is fault-tolerant and scalable.
- DAX cluster has a primary node and zero or more read-replica nodes. Upon a failure for a primary node, DAX will automatically failover and elect a new primary. For scaling, add or remove read replicas.
- DAX supports server-side encryption.
- DAX supports encryption in transit, ensuring that all requests and responses between the application and the cluster are encrypted by TLS, and connections to the cluster can be authenticated by verification of a cluster x509 certificate.
DAX Cluster
- DAC cluster is a logical grouping of one or more nodes that DAX manages as a unit.
- One of the nodes in the cluster is designated as the primary node, and the other nodes (if any) are read replicas.
- Primary Node is responsible for
- Fulfilling application requests for cached data.
- Handling write operations to DynamoDB.
- Evicting data from the cache according to the cluster’s eviction policy.
- Read replicas are responsible for
- Fulfilling application requests for cached data.
- Evicting data from the cache according to the cluster’s eviction policy.
- Only the primary node writes to DynamoDB, read replicas don’t write to DynamoDB.
- For production, it is recommended to have DAX with at least three nodes with each node placed in different Availability Zones.
- Three nodes are required for a DAX cluster to be fault-tolerant.
- A DAX cluster in an AWS Region can only interact with DynamoDB tables that are in the same Region.
DynamoDB Accelerator Operations
- Eventual Read operations
- If DAX has the item available (a cache hit), DAX returns the item without accessing DynamoDB.
- If DAX does not have the item available (a cache miss), DAX passes the request through to DynamoDB. When it receives the response from DynamoDB, DAX returns the results to the application. But it also writes the results to the cache on the primary node.
- Strongly Consistent Read operations
- DAX passes the request through to DynamoDB. The results from DynamoDB are not cached in DAX. but simply returned.
- DAX is not ideal for applications that require strongly consistent reads (or that cannot tolerate eventually consistent reads).
- For Write operations
- Data is first written to the DynamoDB table, and then to the DAX cluster.
- Operation is successful only if the data is successfully written to both the table and to DAX.
- Is not ideal for applications that are write-intensive, or that do not perform much read activity.
DynamoDB Accelerator Caches
- DAX cluster has two distinct caches – Item cache and Query cache
- Item cache
- item cache to store the results from
GetItem
andBatchGetItem
operations. - Item remains in the DAX item cache, subject to the Time to Live (TTL) setting and the least recently used (LRU) algorithm for the cache
- DAX provides a write-through cache, keeping the DAX item cache consistent with the underlying DynamoDB tables.
- item cache to store the results from
- Query cache
- DAX caches the results from
Query
andScan
requests in its query cache. - Query and Scan results don’t affect the item cache at all, as the result set is saved in the query cache – not in the item cache.
- Writes to the Item cache don’t affect the Query cache
- DAX caches the results from
- Item and Query cache has a default 5 minutes TTL setting.
- DAX assigns a timestamp to every entry it writes to the cache. The entry expires if it has remained in the cache for longer than the TTL setting
- DAX maintains an LRU list for both Item and Query cache. LRU list tracks the item addition and last read time. If the cache becomes full, DAX evicts older items (even if they haven’t expired yet) to make room for new entries
- LRU algorithm is always enabled for both the item and query cache and is not user-configurable.
DynamoDB Accelerator Write Strategies
Write-Through
- DAX item cache implements a write-through policy
- For write operations, DAX ensures that the cached item is synchronized with the item as it exists in DynamoDB.
Write-Around
- Write-around strategy reduces write latency
- Ideal for bulk uploads or writing large quantities of data
- Item cache doesn’t remain in sync with the data in DynamoDB.
DynamoDB Accelerator Scenarios
- As an in-memory cache, DAX increases performance and reduces the response times of eventually consistent read workloads by an order of magnitude from single-digit milliseconds to microseconds.
- DAX reduces operational and application complexity by providing a managed service that is API-compatible with DynamoDB. It requires only minimal functional changes to use with an existing application.
- For read-heavy or bursty workloads, DAX provides increased throughput and potential operational cost savings by reducing the need to overprovision read capacity units.
AWS Certification Exam Practice Questions
- Questions are collected from Internet and the answers are marked as per my knowledge and understanding (which might differ with yours).
- AWS services are updated everyday and both the answers and questions might be outdated soon, so research accordingly.
- AWS exam questions are not updated to keep up the pace with AWS updates, so even if the underlying feature has changed the question might not be updated
- Open to further feedback, discussion and correction.
- A company has setup an application in AWS that interacts with DynamoDB. DynamoDB is currently responding in milliseconds, but the application response guidelines require it to respond within microseconds. How can the performance of DynamoDB be further improved?
- Use ElastiCache in front of DynamoDB
- Use DynamoDB inbuilt caching
- Use DynamoDB Accelerator
- Use RDS with ElastiCache instead
This page is out of date, DAX does support TLS https://aws.amazon.com/about-aws/whats-new/2021/06/amazon-dynamodb-accelerator–dax–now-supports-encryption-in-tra/
Thanks Joby, updated.