top of page

Amazon ElastiCache vs Jewelry Store

This article explains about what Amazon ElastiCache is, how it works, its flavours and benefits in lay-person's perspective.


As usual, before we move into this article, I would like to set your mind on a specific analogy.

Lets assume that you and your fiance are going to buy wedding rings for your wedding. The Jewelry store will have wedding rings of all designs. They normally stock up in store shelf, the rings with most popular designs and models or a celebrity ring design that has been sought after by many customers. They also know that many customers visit the store for occasions like wedding, birthdays etc. During festival seasons, the store will need to gear up to handle huge crowds to buy gifts.


Now lets move into the article and relate ElastiCache with this Analogy.


What is Amazon ElastiCache?


In AWS:

  • Amazon ElastiCache is a fully managed, globally distributed in-memory data store.

  • ElastiCache is a scalable, high performance and secure service.

  • ElastiCache supports Redis and Memcached engines.


In Jewelry Store:


  • We can compare the Shelf storage of Jewels with ElastiCache.

  • Jewelry Shelf has all popular, repeated, sought after latest designs in it and can quickly help the customer in selection.

  • Shelf storage can be quickly increased with additional rack(s) if there are some other designs preferred by customers.


 

Why do I need Amazon ElastiCache?


  • Imagine you have a web application and it has been picking up more user traffic lately.

  • You also notice that many customers seek some specific information repeatedly.

  • If the user traffic seeking these repeated information increases extensively, your application servers send the request to database multiple times for the same information that they have already queried before.

  • As a result, your database may end up responding slowly due to regular searches. Also, you are charged every time your application servers send the query to database and get the results.

  • To avoid these type of costs and latency due to repetitive requests or queries, Amazon ElastiCache is used.

 

How does Amazon ElastiCache work?


In AWS:

  • Amazon ElastiCache sits between your application servers and database.

  • This will store all the data pertaining to repetitive or frequently asked queries in Cache memory to provide speedy response. This not only stores frequently asked queries, it also stores infrequent requests so that there is less load to database.

  • Now, when a request comes in from customers, the Application server sends the request first to ElastiCache to check if it has the data to respond. If the data is present, the response is sent immediately to the Application Servers and in turn provides the response to customers.

  • If the data is not present in ElastiCache, then the request is sent to the database and fetched.

  • With ElastiCache in Redis engine, this happens in a millisecond latency. Yes, literally within milliseconds.

In the above diagram, you can see two web-servers are asking for same repeated information (A) and the data is supplied by ElastiCache. While the other Web Server requiring information (B) is not available in ElastiCache and hence this information is fetched from Database. ElastiCache will store this data as well so that next time if a similar request comes, it need not go to database for results overwhelming the database.


In Jewelry Store:

  • Customers walk in to the store and ask for what they need for their occasion (Say Wedding rings).

  • The Jewelry salesman/saleswoman shows them the wedding rings as per their budget and choice of design.

  • Some customers may ask for popular designs that have been bought by many other customers recently.

  • So the salesman/saleswoman checks the required designs in the store shelf. If the design is available, immediately the sale is done.

  • If the design is not available in the shelf, the Salesman/saleswoman checks the stock in the shop's main storage room. Here the main storage room can be referred to Database.

In the above diagram, you can see the design asked by Customer A has been provided from the Shelf storage. This will save the customers time and time required for staff going to the main storage unit. However, the design asked by Customer B is not available in Shelf storage and hence it has been brought from the shop's main storage.

 

Flavours of ElastiCache

  • MemCached

  • Redis

 

Components of ElastiCache for Redis


Nodes: These are the individual units of RAM with a specific engine and version, attached to a network. There can be multiple nodes in a cluster.


Shards: A shard is a group of related nodes (to a maximum of 6 nodes).


Clusters: A logical group of shards. Data is partitioned across the shards in a Redis (cluster mode enabled) cluster. A Redis cluster can have up to 90 shards.


Components of ElastiCache for MemCached


Nodes: These are the individual units of RAM with a specific engine and version, attached to a network. Each node runs an instance of MemCached.


Cluster: A cluster is a logical grouping of one or more ElastiCache Nodes. Data is partitioned across the nodes in a Memcached cluster.

 

High level Use-cases


Redis

  • Can be used where information required to be processed very quickly like leader boards

  • Applications involving data structure server

  • Can be used for Caching and session management

  • Can be used for publisher, subscriber based messaging

  • Can be used where operations includes data types such as hash tables, strings and linked lists.

MemCached

  • Can be used for Caching and session management

  • Can be used for websites with high database load

  • Can be used where there is no replication involved

  • Can be used where there is no major configuration required

 

Benefits

 

I hope this provides you with a very high level understanding of ElastiCache in lay-person's perspective. There are lots more that you still need to learn in depth about ElastiCache and you could refer to the best documentation provided by Amazon.


Kindly provide your feedback on this article in the comments section and press like if it is useful to you. Thank You.

677 views3 comments
bottom of page