Skip to content

This simple library provides a list of available read replica's for a given ElastiCache ReplicationGroupId and provides options to load balance against them by randomly selecting a node that you can connect to.

Notifications You must be signed in to change notification settings

mikelabib/ElastiCacheRedisLoadBalancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElastiCacheRedisLoadBalancer

Summary

Version: 0.0.1
Notes: To be used in a non-sharded redis version.

This simple library provides a list of available read replica's for a given ElastiCache ReplicationGroupId and provides options to load balance against them by randomly selecting a node that you can connect to.

static ReadReplicaBalancer readReplicaBalancer = new ReadReplicaBalancer();

Example: ArrayList endpoints = readReplicaBalancer.getReadReplicaEndpoints(replicationGroupId, elastiCacheClient);

Option 1: Randomly select a node from the available replica's

Example 1: String node = readReplicaBalancer.loadBalance(endpoints);

Option 2: Randomly select a node from the available replica's excluding a node

Example 2: String node = readReplicaBalancer.loadBalance(endpoints, NodetoExclude);

Demo code shows how it can be used with Jedis but any Redis Java Library will work.

The code loops through the library so you can test against it.

Jedis jedis = new Jedis(node, 6379);

About

This simple library provides a list of available read replica's for a given ElastiCache ReplicationGroupId and provides options to load balance against them by randomly selecting a node that you can connect to.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages