Skip to main content

Case Studies

Retrieve Your Application Data Using AWS ElastiCache

Internet Infrastructure Concept. Abstract Technology Background.

AWS ElastiCache is a service that improves web application performance by retrieving information from fast-managed in-memory caches.

What is Caching?

Caching is the process of storing data in a cache. A cache is a temporary storage area. Cache are optimized for fast retrieval with the trade off that data is not durable.

The cache is used for reading purposes only, which can access your application data promptly.

ElastiCache supports the following two popular open-source in-memory caching engines:

  • Memcached: A high-performance, distributed memory object caching system well-suited for use cases where simple key-value storage and retrieval are required.
  • Redis: An open-source, in-memory key-value store that supports various data structures such as strings, hashes, lists, sets, and more. Redis is often used for caching, session management, real-time analytics, and messaging.

Which Caching Engine is Best?

Redis has more Advanced features than Memcached. A data structure server stores data in a key-value format to be served quickly. It allows replication, clustering, and configurable persistence. It is recommended if you want a highly scalable data store shared by multiple processes, applications, or servers or just as a caching layer.

On the Other Hand, Memcached is an in-memory key-value store for small chunks of data that fetch data from a database, API calls, or page rendering.

Memcached is used to speed up the dynamic web application.

Both Caching engines have their own usage depending on your requirements. Here, we are going to use Redis Cache.

Architecture Diagram of  AWS ElastiCache

Architecture

According to the Architecture diagram, whenever a read request is generated by the user, information is first searched in ElastiCache. If the data is not available in the Cache, then the request is served from the Database.

If the requested data is present in the cache, then the reply is very quick; otherwise, the Database is responsible for serving the request, which increases the latency.

Why We Need AWS ElastiCache

  • Performance Improvement: ElastiCache stores frequently used data from the database, which helps to improve the Application’s performance.
  • Scalability: ElastiCache can quickly help set up, manage, and scale distributed in-memory cache in the cloud.
  • High Availability and Reliability: ElastiCache supports multi-AZ functionality, which means if one AZ is unavailable, ElastiCache continues to serve data in the other AZ. ElastiCache supports replication and provides automatic failover, in which if the master node fails, one of the read replicas promotes itself as a master node. This is particularly crucial for critical applications that require constant uptime.
  • Cost-Effectiveness: With ElastiCache, There is no upfront cost or long-term commitment. You just pay a simple monthly charge for each Redis node you use. By offloading traffic from databases to cache layers, ElastiCache helps reduce the workload on your databases.
  • Security: ElastiCache comes with various security features, including encryption in transit and at rest, identity and access management (IAM) policies, and integration with Amazon Virtual Private Cloud (VPC), helping to protect your cached data.
  • Compatibility: ElastiCache is compatible with variety of popular frameworks and libraries, it is easy to integrate with existing applications.

Use Cases of AWS ElastiCache

  • Chat Application
  • Media Streaming
  • Session store
  • Gaming Leaderboard’s
  • Real-time analytics
  • Caching

Deployment of  AWS ElastiCache using CloudFormation Template

Let’s Deploy the AWS ElastiCache(Redis Cache) using IaC Tool (AWS CloudFormation)

Step 1: Create a Stack in AWS CloudFormation and upload a Template file.

Template file: In this template file, there is CloudFormation code, which is going to deploy the AWS ElastiCache.

Note: Repository link to download the template file: https://github.com/prafulitankar/AWS-Elasticache

Img 1

Step 2: Mention the Stack Name and Parameter Values. Here, we have provided the CloudFormation Stack name(Elasticache-01) and Parameter Values, which define the Configuration of the AWS ElastiCache Cluster.

Img 2

Img 3

Step 3: Once we’re done with the Parameter Value, let’s configure the Below Stack Options. Provide the Tags and Permissions to the Cluster.

Img 4

Step 4: Configure Stack Failure Options; here we have stack failure options:

  • Preserve successfully provisioned resources: When the stack fails, it preserves all the resources that were successfully created.
  • Delete all newly created resource : Once the stack failed it should be rollback , which means it keep all the old resources which was created previously and delete all the new resource during rollback

Img 5

Once we Submit all the necessary information, the CloudFormation stack will start creating the AWS ElastiCache Cluster.

Now, our AWS ElastiCache Cluster is available.

Img 8

How to Access AWS ElastiCache

  • AWS ElastiCache Cluster must be deployed in VPC.
  • Port Number 6379 is allowed in the Security Group from the source IP from where we access the ElastiCache Cluster.
  • To Access, the Cluster requires a Primary endpoint (master.cluster-test-001.flihgf.use2.cache.amazon.com:6379)

By using AWS ElastiCache, we can speed up our Application performance by caching data in ElastiCache, which is cost-effective, secure, and highly available to reduce the overhead and latency on the database.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Praful Itankar

Praful Itankar is a Senior Technical Consultant with over 9 years of experience in MultiCloud and DevOps technologies. He looks forward to sharing his knowledge on the latest technology trends through blogging.

More from this Author

Categories
Follow Us