In this guide, we’re going to learn about Amazon Web Services ElastiCache. One of the best ways to optimize a website or application is to implement a cache system. As a Solutions Architect, you’ll be responsible for creating and managing infrastructure based on the needs of an application. This means knowing how to implement different services in a variety of ways for the best possible results. This is a guide on ElastiCache for Solutions Architects or those studying for the certification.
What is ElastiCache?
ElastiCache is a cloud cache service hosted on the Amazon Web Services platform. You can choose between two technologies – Redis and Memcached. ElastiCache offers a scalable cache system that runs on instances starting with 1 vCPU and 0.55 GB of memory, and ranging up to 40 vCPUs and 154.64 GB of memory (there are also memory-optimized instances with up to 32 vCPUs and 237 GB).
What is Redis?
Redis is an in-memory key-value store created by Salvatore Sanfilippo in May 2009. Redis is known for being fast, flexible, and having built-in persistence, and for its use by some well-known companies, such as Stripe and Uber. Redis’s features include geospatial indexes, Lua scripting, and HyperLogLogs. Redis is often used for caching and message queue systems.
What is Memcached?
Memcached is a high-performance caching system created by Danga Interactive in May 2003. Memcached is known for being general-purpose, high-performance, and distributed, and for its use by some well-known companies, such as YouTube and Wikipedia. Memcached features include cache invalidation, expiration time and data structure flexibility.
Like the majority of AWS products, ElastiCache is charged at an hourly rate. The price can change depending on the location and the hardware of the instance – vCPU and Memory. You can find detailed and up-to-date ElastiCache pricing here.
Benefits of ElastiCache
The main benefit of ElastiCache is its ease of management. It offers a selection of features such as replication, scaling, clusters and backups. It boasts flexible pricing, especially with on-demand node reservation.
Administering your own Redis or Memcached instance can be a full-time job – you must worry about keeping the server secure, up to date, online and able to handle high load/traffic. You also have to perform management operations such as scaling and backing up.
Getting started with ElastiCache is simple. AWS offers an easy to use dashboard that allows you to configure an instance to your exact requirements. To get started with ElastiCache:
- Log in to your AWS console
- Click on the Services dropdown menu
- Click on ElastiCache under the Database section
You are now in the ElastiCache dashboard, which should look something like this:
On the left hand side of the dashboard, you will notice a menu with options related to ElastiCache. Click onto the Redis link to learn more about the Redis instance of ElastiCache.
If it’s your first time using a Redis instance, there will not be much to see here:
You would normally see a list of ElastiCache Redis instances and information such as the number of shards, nodes, and the status of the instance. You may click on an instance to get more information, stop the instance, or create a backup of the current state.
Creating a Redis ElastiCache instance
Let’s create a new Redis instance:
- Click on the blue Create button
- Select the Redis option
- Fill out the form to match your requirements. Enter a helpful name and useful description (this is important to help keep track if you have many instances)
- For now, it’s okay to leave the default settings such as engine version, port and parameter group, but change the number of replicas to “none”
- You can use a smaller instance type while testing to keep the cost low (the t2.micro instance is part of AWS’s free tier)
Your instance will now be created by AWS. You can see the status update in the Redis instance dashboard:
Once your instance has been created, the status will be updated to “available”. Once the instance is available you will be given a unique endpoint address used to interact with the instance. This could be via application code, which updates the view counter for a website. You will need to have correctly set up permissions and VPC’s to interact with ElastiCache (usually through an EC2 instance). To avoid any future costs for this instance, you can delete it from the Redis dashboard.
That’s it! ElastiCache is a powerful and flexible way to manage a cache through the AWS console, and is a great way to avoid the headaches of administering your own Redis or Memcached instance. Now that you’ve got a hold on the basics, you can start using ElastiCache to speed up your site and get the most out of your infrastructure.
Want to know more about how Elasticache works in the real world? Check out our post on how to boost performance with caching.