QubOps

Day 22 - Elasticache

AWS Cost Optimisation Advent Calendar 2024

3 min read time

#aws #elasticache

Welcome to day 22 of the unofficial AWS Cost Optimisation Advent Calendar 2024, where every day we will be sharing new tips or tricks to help you optimise your cloud costs before Christmas 2024.

Today we are going to talk about cost optimisation in Elasticache.

Elasticache is a fully managed in-memory data store service that supports two of the most popular open-source in-memory data stores: Redis and Memcached. It is great service for caching and session management, and it can help you reduce the load on your databases.

However, Elasticache can be expensive if not used correctly.

1. Use Reserved Instances

Like Databases, Elasticache servers are often long-lived. If you know you will be using an Elasticache server for a long time, you can save money by purchasing Reserved Instances.

We spoke about Reserved Instances extensively on Day 15

2. Expire Your Cache

By definition, a cache is a temporary data store. If you are not expiring your objects in the cache it is very possible you are overpaying for Elasticache.

Monitor your cache growth and make sure it is not growing due to unexpired objects that may no longer be needed.

To monitor your cache growth, you can use CloudWatch watching metrics like ObjectCount and BytesUsedForCache.

3. Data Tiering

If you are using Redis or Valkey, you could benefit from Data Tiering.

Data Tiering is a strategy where you store your most frequently accessed data in memory and less frequently accessed data on disk. This can save you money as disk storage is significantly cheaper than memory storage.

AWS will automatically move data between memory and disk based on your access patterns.

This allows you to have smaller instances and save money.

4. Read Replicas

If you are using Redis, you can use Read Replicas in a very similar way to RDS.

We explained on Day 5 how you can use Read Replicas to save money on RDS, and the same applies to Elasticache.

You can use Read Replicas for read-heavy workloads to spread them out across a few smaller instances rather than one large expensive instance to handle everything - with the added benefit of redundancy.

5. Validate your Use Cases

Finally, make sure you are using Elasticache for the right reasons.

As a key-value store is very convenient for many use cases, it is often the go to for common problems that already have very efficient solutions elsewhere.

Some examples are:

Using Elasticache for request caching when you could be using CloudFront for a fraction of the cost and benefit from the global distribution.

Using Elasticache for session management in medium sized businesses when you are already paying for a database instance that is also capable of handling the sessions.

Using Elasticache as a queue when you could be using SQS for a fraction of the price and benefit from the built-in scaling, monitoring and features like FIFO.

PubSub is another common use case for Elasticache that could be replaced with SNS.

Conclusion

Elasticache is a great service but it can be expensive if not used correctly as it relies on memory which is one of the more expensive commodities in computing.

For that reason it is important to consider whether a memory store is the right tool for the job and that you are using it correctly.

That's it for today, see you tomorrow for another tip!

To be the first to know when the next edition is published, follow us on LinkedIn, X, BlueSky or subscribe to the RSS feed.

Join our newsletter for Cost Optimization tips and tricks

By subscribing you agree to our Privacy Policy and provide consent to receive updates from our company.