0 votes
in AWS by

You've been hired as a developer to work on an application.

This application will be making use of an AWS RDS database and ElastiCache.

A requirement is present which states that the cache should always have the most recent data that is present in the database and should not contain stale data. What strategy for ElastiCache can the developer use to implement this?

1 Answer

0 votes
by

Answer - B.

The AWS Documentation mentions the following.

Write Through.

The write-through strategy adds data or updates data in the cache whenever data is written to the database.

Advantages and Disadvantages of Write Through.

Advantages of Write Through.

Data in the cache is never stale.

Since the cache data is updated every time it is written to the database, the cache data is always current.

Write penalty vs.

Read penalty.

Every write involves two trips:

A write to the cache.

A write to the database.

Which adds latency to the process.

That said, end users are generally more tolerant of latency when updating data than when retrieving data.

There is an inherent sense that updates are more work and thus take longer.

Option A is incorrect because lazy loading is a caching strategy that loads data into the cache only when necessary.

Option C and D are incorrect because there are no such strategies.

For more information on different caching mechanisms, please refer to the below link-

https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/Strategies.html

The correct answer is B. Write-through.

Explanation:

ElastiCache is a web service that makes it easy to deploy, operate, and scale an in-memory data store or cache in the cloud. It supports two caching strategies: write-through and lazy loading.

Lazy loading is a caching strategy in which the cache is populated with data only when it is requested. This means that the first request for a particular piece of data will be slow, but subsequent requests will be faster since the data will be stored in the cache. While this strategy can help to conserve memory, it is not suitable for applications that require the cache to be kept up-to-date with the latest data from the database.

Write-through, on the other hand, is a caching strategy in which data is written to both the cache and the database at the same time. This ensures that the cache always contains the most recent data, and there is no possibility of stale data. With write-through caching, when new data is added to the database, it is also added to the cache, and when data is updated or deleted from the database, it is also updated or deleted from the cache. This strategy provides the best performance for applications that require up-to-date data and is the recommended caching strategy for use with AWS RDS databases.

Error retries and exponential backoff are not caching strategies but are techniques used to handle errors when interacting with AWS services. Error retries involve automatically retrying an operation that has failed due to a transient error, such as a network failure, and can help to improve the reliability of an application. Exponential backoff involves increasing the delay between retries exponentially to avoid overwhelming the service with requests. These techniques can be used in conjunction with caching, but they are not caching strategies themselves.

...