“Try clearing your cache” has been one of the most popular solutions that we hear about in a computer crisis. But what exactly is “Caching”?
TABLE OF CONTENT
1. Introduction to Caching2. Cache Evictions Use Cases of Caching4. AWS ElastiCache5. AWS ElastiCache6 Use Cases Conclusion7. CloudThat8. FAQs 1. Introduction to Caching
Caching is the practice of storing frequently requested items closer to those who are looking for them. “Algorithm to Live By,” explains how to cache in a library setting. Let’s say we need to read a book. It would take us a week to finish it. It is impossible to travel daily to the library to get the book. To have daily access, we would either borrow the book for a week or purchase it completely and keep it on our desk. Caching is a term that refers to the practice of keeping frequently accessed data in memory faster than our Database. Caching is a technique that allows us to improve performance and provide better user experiences in all applications on a daily basis. Browser Caching is a technique that caches components of a website. This reduces load time. The browser caches the majority of the content on a website to speed up page load times. It also saves a copy to the device’s hard drive. These files are stored by the browser until their time-to live (TTL) expires, or until the hard disk cache is full. The Cache can be cleared by users.
2. Cache Evictions
Eviction refers the amount of data that can be removed from the Cache. This allows the Cache to keep within a memory budget. Cache Evictions can also be required when there is a significant update to the databases or new entries. Multiple methods can be used to accomplish cache evictions. These are some of the options:
LRU (Least Recently Used): All resources in Cache that haven’t been used in a long time are discarded.
FIFO, LIFO
Random Replacement: Items are discarded randomly
LFU (Least Frequent Use): All items that are not used often are thrown out.
There are many other cache eviction policies that could be used in similar situations. Eviction policies can make a significant difference in performance and can be a significant boost to it. We are familiar with caching and the policies that can be used to expel Cache. Let’s look at how Caching works in AWS. What benefits will it bring to our application?
3. Use Cases of Caching:
Let’s say we create an app that calls our DB via our backend code to retrieve profiles of actresses and actors around the world. There will be many calls to retrieve the profile of actors who have large fan followings. Every call to the database must fetch the results every time, which could strain our database. How about storing the profile of this actor in temporary memory? We could then retrieve it from there whenever a call is made. This would improve our application performance and reduce the cost of DB. Caching is used in such cases. There are many types and types of Caching.
Browser Caching
DNS Caching
Database Caching
Session Management
Image Source: https://images.app.goo.gl/q3fRvUm4MCRiQ3YbALet us now learn about Amazon’s cloud service for caching: ElastiCache.
4. AWS ElastiCache:
Amazon Web Services provides us with a caching technology that can be used in our applications. ElastiCache is a fully managed, in-memory caching service that accelerates application and Database performance or as a primary data store for use cases that don’t require durability like session stores, gaming leaderboards, streaming, and analytics.ElastiCache is compatible with both Redis and Memcached.
5. Use Cases for AWS ElastiCache
Accelerate Application Performance
Ease Backend Database Load
Create low-latency data stores
The above diagram shows Caching. Our Node Application on EC2 uses ElastiCache for caching data that i
