CDP:Inmemory DB Cache Pattern

From AWS-CloudDesignPattern
Jump to: navigation, search

Caching High-Frequency Data


Problem to Be Solved

The majority of the database load usually is involved with reading. Because of this, you can improve the performance of the system as a whole by improving the performance of reading from the databases.

Explanation of the Cloud Solution/Pattern

You can use this pattern to improve the performance of reading from databases by caching in memory data that is read frequently. This is a technique where data that has been used is placed in a cache, so that it can be read in from memory (rather than from the disk) the next time it is used. Typical examples of data that are cached are results of time-consuming queries, results of complex calculations, and so forth, in database operations.


"ElastiCache" in AWS is a memory cache service. This service is provided with an automatic recovery function for the case of a failure.

  • Prepare the memory cache. You may use ElastiCache, or you may use the open source memcached in an EC2 instance.
  • When data is read in, data in the memory cache is referenced first. If the data is not there, it is read in from the database and stored in the cache.




  • You can use high-speed memory for the cache to reduce the load of reading from the database, improving overall system performance.
  • You can use ElastiCache to streamline the operation, and ElastiCache is robust to failures.


  • You should consider the trade-offs when caching query results. The proportion of reading in performing specific queries and writing the queries to the related tables is important. For example, if references are extremely frequent (many times per minute), but updates to the data are not so often (daily or even hourly), caching will be of value. On the other hand, you must be clever to prevent old data from remaining as-is in the cache. Reference Information:
  • Using the cache may require you to modify the program that accesses the database.
Personal tools