The real purpose of Elastic Cache is to improve response time. Let us take a mobile gaming app, where user score stores on the database. If every time it hits, this delays response to the user.
AWS uses Redis as in-memory data store, which is a broker to the user and main data store.
The function of Redis is to save user scores for the time being. When the user is done his game the final scores published to the Main database.
How In-Memory Data-Store Resides in AWS.
Application – It is an user gaming application. It can be either mobile app or desktop app.
Cache – This is Redis AWS supports for in-memory use.
Data Store – It is basically the main database. Best example is Oracle, SQL Server etc.
Real Benefits with in-memory Cache layer.
- The read traffic can be served from the caching layer, which frees resources on your data store, for example for write requests.
- It speeds up your application because the caching layer responds more quickly than your data store.
- You can downsize your data store, which can be more expensive than the caching layer.
Data in Cache Memory is temporary, so let us see how Redis manages the Failover.
Most caching layers reside in-memory and that’s why they are so fast. The downside is that you can lose the cached data at any time because of a hardware defect or a restart.
Always keep a copy of your data in a primary data store with disk durability, like the relational database in the mobile game example.
Alternatively, Redis has optional failover support. In the event of a node failure, a replica node will be elected to be the new primary and will already have a copy of the data.
How Cache Layer Talks to Main Data Store.
The lazy-loading strategy (getting data on demand) is implemented like this:
1. The application writes data to the data store.
2. If the application wants to read the data, at a later time it makes a request to the caching layer.
3. The caching layer does not contain the data. The application reads from the data store directly and puts the read value into the cache, and also returns the value to the client.
4. Later, if the application wants to read the data again, it makes a request to the caching layer and finds the value.
The data in Cache memory is temporary. Suppose it could be 5 minutes. When you do not use that data, the data in Cache expires. The Cache again has to talk to the main database to get the latest data.
You must be logged in to post a comment.