Bobcares

Launching an ElastiCache for Redis Cluster

by | May 23, 2023

Let us learn more on Launching an ElastiCache for Redis Cluster with the support of our Server management support services at Bobcares.

Launching an ElastiCache for Redis Cluster: Part1

Using the AWS Management Console, CLI, or SDKs, we can quickly and simply start a new Redis cluster using ElastiCache.

Using the Management Console, we’ll create a new cluster and enable cluster mode:

Navigate to ElastiCache in the AWS Management Console using the preferred browser. In the middle of the page, click the blue “Create” button. We will use the Redis engine and enable Cluster Mode for this cluster.

Next, give the cluster a name and a description. We may also choose an engine version, however we normally advocate utilizing the most recent Redis engine version. We may also define how many shards and replicas each shard has.

The cluster will be made up of the number of shards supplied (up to 90), each with the number of replicas specified. In this case, three shards with two replicas each result in a total of nine nodes in the cluster (three primary + two copies of each).

Launching an ElastiCache for Redis Cluster: Part2

ElastiCache offers a range of cache instance types based on storage and performance requirements. We may vertically scale the capacity of the nodes in each shard as well as the overall capacity of the cluster by using different node types.

By employing Cluster Mode instead of scaling a single node, we limit the frequency of scaling disturbances and may better meet the changing demands of our workload, potentially saving money. All nodes in the cluster will be the same sort of node.

Under “Advanced Redis settings,” we may customize the key space distribution in the cluster. ElastiCache will distribute keys evenly between shards by default, but we can specify a custom distribution if necessary.

If we expect a limited number of key-value pairs in the cluster that will be considerably bigger than others, a tailored distribution may be advantageous.

We could push one or more of those bigger things to their own shard by adjusting the distribution.

After setting the cluster’s networking, backup, and security, click “Create” at the bottom of the page to begin the cluster’s formation.

How to Connect to the Cluster?

When the cluster is marked as “available,” it is ready for usage. We may connect to the cluster via the AWS Management Console’s Configuration Endpoint.

For example, we can use the Redis CLI to connect to the cluster and ask for information on the cluster’s key space / slots:

Launching an ElastiCache for Redis Cluster

According to the answer, keys with hash slots ranging from 0 to 5461 are saved on a Redis node accessible at IP address 172.31.26.164 (the following entries are the port and unique identifier for that node).

IP addresses 172.31.49.34 and 172.31.8.200 are replicas of that node. The data for the other two shards in our cluster is similar. The slot ranges can also be seen in the Management Console:

While we will seldom need to directly engage with this information, it is essential for the Redis client: a map between hash slots and nodes. Any Redis SDK we use, such the Redis CLI, must allow clustering.

Clustering is not supported by many SDKs, but the Amazon ElastiCache team is striving to improve support.

An SDK must, in particular, enable two features: (1) support for the key hashing technique and (2) the ability to maintain the slot to node mapping. Clustering is now supported in Java, Ruby, Go, Python, and other computer languages.

connecting to ElastiCache for Redis in Cluster Mode in Python

Connecting to ElastiCache for Redis in Cluster Mode is straightforward in Python. Follow the set of command line given below for the stup process:

Launching an ElastiCache for Redis Cluster

How to Scale the Cluster?

We may need to expand the capacity of the ElastiCache cluster as the application grows or becomes more popular. In contrast to vertical scaling, Cluster Mode allows us to grow horizontally by adding or deleting shards.

This strategy enhances cluster availability because no restart is necessary, while performance may suffer throughout the process.

On the server side, horizontal scalability of the cluster is simple – a shard is simply added or withdrawn. Once the new node is operational, the cluster must reallocate or balance the key space across the nodes as specified. The re-balance is automated when using ElastiCache for Redis.

As previously stated, the client is responsible for maintaining its own key space-to-node mapping.

Clients react differently to the re-balance since there is no notice that the key mapping has changed. Instead, the cluster will tell the client that the key has migrated during the following operation:

$ redis-cli -c -h mycluster.cache.amazonaws.com -p 6379
mycluster:6379- GET foo
-MOVED 12182 172.31.8.18:6379

While the procedure in this scenario is a two-step process that may incur some additional delay to complete, the client is now aware of the new key mapping.

Going forward, the client may continue to operate as before, fully exploiting the cluster’s available shards.

Before and after: Testing the cluster’s scalability

ElastiCache broadcasts a number of metrics to Amazon CloudWatch that may be used to monitor the cluster’s utilization. Among them are a few that provide strong insight into ElastiCache performance and can be beneficial in determining when the cluster might benefit from scaling with an understanding of the workload.

[Need assistance with similar queries? We are here to help]

Conclusion

To sum up we have now seen more on Launching an ElastiCache for Redis Cluster with the support of our tech support team.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.