Hands-on Configuration of ElastiCache on AWS

Introduction

In my previous article, we talk a little bit about ElastiCache. Let’s recap that ElastiCache is an AWS web caching service that helps improve the performance of web application. It supports both Memcached and Redis. In this article, we will try to create an ElastiCache cluster, authorize access to ElastiCache cluster and connect to ElastiCache cluster and run commands.

Create an Amazon ElastiCache

In ElastiCache dashboard, click Redis and then create.

In Redis settings, we type cache-demo in Name, choose t2.micro in node type, and type 0 in number of replicas.

If we have no preference, we could create a new subnet in the default VPC.

The default security group should open for all traffic, if not just create a new one (please see the next part first if you want to create a new security group).

For others, just leave it as default, and then click create.

Then we can see the ElastiCache is creating.

Authorize Access to ElastiCache Cluster

If you are not using the default firewall group, you can create security group in EC2 page=>Security Groups=>Create security group.

The other things are up to you, but you should have at least these two inbound rules to allow EC2 to connect ElastiCache.

Connect to EC2 Instance

Go to instances then launch instances.

Choose a Windows Server 2019.

Click Next.

Choose the same subnet as ElastiCache and enable auto-assign IP. Then click next.

Click Next.

And Next.

For demonstration, we could choose either the default security group or the group you just created before. Then click Review and launch.

Create a new key pair or use existing key, it is up to you. If you want to create a new one, please download the key pair and store it in a secure location. Then launch instance.

Choose the instance we just create and click connect.

Firstly, download the remote desktop file. Then we just copy the username and password and paste into remote windows server.

We are able to connect the windows server now.

Obtain the ElastiCache Endpoint

Back to ElastiCache and copy the primary endpoint, but please do not copy “:6379”. In my case, it is “cache-demo.gket9a.0001.use1.cache.amazonaws.com”

Install Redis Client and Interact With Cache Cluster

Back to windows server, and search for server manager.

We turn of Internet Explorer Enhanced Security as shown as above.

Open IE in remote server, then click OK for setup.

Then type the below URL in remote desktop and click run:

https://github.com/uglide/RedisDesktopManager/releases/download/0.9.3/redis-desktop-manager-0.9.3.817.exe

Install the Redis Desktop Manager.

After installation, click connect to Redis Server.

Type the name and address. Address is Primary Endpoint of ElastiCache we just copied before. Then click OK.

Click the command prompt icon, and we see “connected”. We are now connected to cache node and we can test something.

Then we will try some commands:

  1. set a “hello” – set key a with a string value and no expiration.
  2. get a – get the value of a.
  3. get b – get the value of b, but no cache here so return null.
  4. set b “Good-bye” EX5 – set key with 5 seconds cache.
  5. get b – return “Good-bye” if it is within 5 seconds.
  6. get b – return null if exceed 5 seconds.

Cleanup

Delete ElastiCache without backup.

Terminate the windows server.

Leave a Reply