Skip to content

What is ElastiCache and how we can use it to optimize databases?

For high-end performance for databases, we can use ElastiCache which basically is an In-memory database cache for high performance. 

Databases store data persistently on disk because of this they have a limit to a certain amount of performance level that they can provide. In-memory database cache holds data in memory that can provide high performance in terms of throughput and latency however the data are not persistent and can only be used for temporary data. 

ElastiCache has two different engines:

  • Redis: (This is the most advanced form of Elasti Cache)
    • Advanced Structures. For Eg. Lists, Sets, Sorted Sets, Hashes, etc. 
    • Replication in Multi- AZ 
    • Backup & Restores
    • Used for Transactions
  • Memcached: 
    • Simple Data Structure only. For eg. Strings
    • No Replication
    • No Backups
    • Can be Multi-Threaded

For read-heavy workloads with low latency requirements, we can use ElastiCache and also reduces database workloads that can save cost. This can also be used to store Session Data or can be very useful for Stateless Server architecture. 

The Architecture of using Elastic Cache Will be as follows: 

  1. Cache Miss: First time when we access the data then the Cache doesn’t have any data so it will have to fetch from the database and so it is called Cache Missed. 
  2. Cache hit: If the same query is called again from the application then the data is fetched from the in-memory Elasticache which is called Cache Hit which will be a lot faster than Cache Miss. 

 

Leave a Reply

Your email address will not be published. Required fields are marked *