adesso Blog

In today's digital landscape, the efficient management and processing of data is crucial to the success of applications and services. In the area of NoSQL databases in particular, Amazon Web Services (AWS) has established itself as one of the leading providers, with DynamoDB playing a central role. DynamoDB is a fully managed NoSQL database known for its high performance and scalability. However, when working with large amounts of data, even the most powerful database can reach its limits, especially when it comes to reducing latency and increasing access speed. This is where caching comes into play. Caching is a proven method for optimising data access times by caching frequently accessed data to enable faster access. In this blog post, I'll take a closer look at AWS's caching extension, DynamoDB Accelerator (DAX), which is specifically designed to further boost DynamoDB performance to improve the efficiency and user experience of your applications.

DAX – an overview

The DynamoDB database service returns results in the single-digit millisecond range for data queries. However, there are applications that require even faster response times. This is where the DynamoDB Accelerator Service can help. DAX is an in-memory cache extension for DynamoDB. DAX sits between the querying application and the database and caches frequently accessed data in-memory. This reduces the need to read data from disk, which can be slower, and significantly reduces the latency of read-intensive workloads. The accelerator provides up to a tenfold increase in performance, even with millions of requests per second. This means that query times in the double-digit microsecond range can be achieved.

DAX is compatible with the existing DynamoDB API calls, so application code does not need to be changed. This makes it easy to integrate DAX into existing applications.


AWS-DAX architecture image, source: docs.aws.com

DAX architecture

DAX clusters consist of multiple nodes running on AWS infrastructure that work together to accelerate queries. Typically, a DAX cluster consists of at least three nodes to provide high availability and fault tolerance. These nodes are distributed across multiple Availability Zones within a region, meaning that even if one node or Availability Zone fails, the other nodes can continue to maintain the service. This ensures continuous availability and a high level of fault tolerance for the caching system.

Each node within a DAX cluster stores data in RAM, which results in extremely low latencies, since accessing data held in RAM is significantly faster than accessing data that has to be read from a hard drive or SSD.

Within DAX, there are two main cache components: the item cache, which stores all items in the DAX, and the query cache, which stores all query-related data and query parameters in memory.

Caching Strategies

The DynamoDB Accelerator (DAX) uses three main caching strategies to optimise the performance of the DynamoDB database: read-through caching, write-through caching and write-back caching. Each of these strategies fulfils specific requirements and helps to increase efficiency.

  • Read-through caching is used to accelerate read operations. With this strategy, the requested data is first searched for in the DAX cache. If a data object is found in the cache (cache hit), the data is returned directly from the cache, which significantly reduces latency. If the data set is not available in the cache (cache miss), a request is sent to the underlying DynamoDB database. The returned data is then stored in the DAX cache to be available faster for future requests. This method reduces the load on the DynamoDB and improves response times for repeated reads.
  • Write-through caching is used to ensure consistency between the cache and the DynamoDB database. With this strategy, data changes that are submitted to DynamoDB are simultaneously updated in the DAX cache. This ensures that the cache always contains up-to-date data. As soon as a write operation is performed, the changes are written to both DynamoDB and the cache. This strategy minimises the risk of inconsistencies between the cache and the database, as both sources are kept in sync.
  • Write-back caching, on the other hand, initially stores write operations only in the cache instead of immediately transferring them to the DynamoDB database. The cached changes are written back to the DynamoDB database at regular intervals or when certain conditions are met. This method can reduce the write load on DynamoDB because the database is not contacted immediately for each write operation. However, this strategy requires careful management to ensure that data consistency is maintained and that changes are transferred to the database in a timely manner.

Using DAX

The use of DAX is particularly beneficial for read-intensive workloads that require frequent and fast data access. A typical example is an e-commerce platform that processes high visitor numbers and a large number of product queries per second. In such a scenario, users could be constantly searching for product information, reviews or availability. The integration of DAX into the architecture of this platform makes it possible to quickly retrieve these repeated reads from the in-memory cache instead of burdening the underlying DynamoDB database for each request. This not only significantly reduces response times, but also the number of database queries and thus costs, since DynamoDB costs are often determined by the number of reads and writes. By offloading intensive reads to the DAX cluster, companies can achieve significant cost savings while improving the user experience through faster queries.

However, DAX should not be used if the application is write-heavy or if another caching solution is already used with its own client-side logic. Similarly, DAX is not suitable if microsecond-level read response time guarantees are not required or if highly consistent reads are needed.

Limitations

While DAX offers significant performance improvements, it also has some limitations. DAX supports only certain DynamoDB operations, specifically GetItem, Query, and Scan. More complex operations such as UpdateItem or BatchWriteItem, which involve heavy data manipulation or consistent write operations, are not covered by the DAX cache. Furthermore, DAX is not suitable for all DynamoDB table properties. Tables with time-to-live (TTL) or global secondary indexes that are not based on the primary key are currently not compatible with DAX. The cost structure must also be taken into account, since DAX is a separate managed service that incurs additional fees on top of the regular DynamoDB costs. Using DAX also requires precise configuration and continuous monitoring, as configuration errors or insufficient scaling can lead to suboptimal performance and increased latency. Furthermore, integrating DAX can add additional complexity to the system architecture, especially with regard to data consistency management and error diagnosis, as the interaction between cache and database can pose particular challenges.

Conclusion

In summary, the DynamoDB Accelerator is an effective solution for improving query speed in Amazon DynamoDB. Through in-memory caching, DAX enables a significant reduction in read latency and can thus significantly increase application performance. DAX's architecture, which is based on a cluster of nodes in different availability zones, provides high availability and fault tolerance.

However, DAX also has limitations, including limited support for certain DynamoDB operations and table properties, as well as additional costs. The implementation requires careful configuration and monitoring to ensure optimal results. Therefore, DAX should be considered especially for applications that require intensive read operations, while other scenarios are better covered by alternative solutions.

Would you like to learn more about exciting topics from the adesso world? Then take a look at our previously published blog posts.

Picture Yannik Rust

Author Yannik Rust

Yannik Rust is a Data Engineer n the Line of Business Data and Analytics at adesso.



Our blog posts at a glance

Our tech blog invites you to dive deep into the exciting dimensions of technology. Here we offer you insights not only into our vision and expertise, but also into the latest trends, developments and ideas shaping the tech world.

Our blog is your platform for inspiring stories, informative articles and practical insights. Whether you are a tech lover, an entrepreneur looking for innovative solutions or just curious - we have something for everyone.

To the blog posts

Save this page. Remove this page.