Proper Jedis configuration for working with AWS Elasticache

2,701 views
Skip to first unread message

Shane Witbeck

unread,
Mar 13, 2017, 8:54:29 PM3/13/17
to Jedis
I've been struggling to figure out how to configure Jedis for use in an AWS Elasticache non-clustered (master/slave) environment.

At first, I just configured JedisPool with something like 

JedisPool jedisPool = new JedisPool("primary_node_host", 6379);


then did some operations like:

try (Jedis jedis = jedisPool.getResource()) {
 
// ops here
} catch (JedisException e) {
 
// handle exception here
}


But later realized that the replica nodes (I have 3) should be used for reads while the primary should be used for writes.

How should I be instantiating Jedis to work with this setup?

Second, do I need to specifically select a random replica node in order to do read ops or will the client handle this for me depending on what kind of operation I'm doing?

I'm somewhat new to Redis so any hints here are much appreciated.

Shane Witbeck

unread,
Apr 4, 2017, 6:12:40 PM4/4/17
to Jedis
Replying to my own post. I wrote an abstraction on top of Jedis that interrogates the AWS Elasticache API to get the master/slave endpoints. Then I configured two JedisPools, one for master (writes) and one for slaves (reads).

S Ahmed

unread,
Apr 4, 2017, 6:23:40 PM4/4/17
to jedis...@googlegroups.com
aws has their own java library, it is a fork of the spymemcached lib.

--
You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcos Lilljedahl

unread,
Apr 4, 2017, 6:25:31 PM4/4/17
to Jedis
This is Redis, not memchaced

sent from mobile

S Ahmed

unread,
Apr 4, 2017, 7:12:24 PM4/4/17
to jedis...@googlegroups.com
oops sorry about that.

Allan Wax

unread,
Apr 5, 2017, 1:35:40 PM4/5/17
to Jedis
What happens when a master fails, or a slave fails, or a slave becomes a master?  Do you have to recreate the pools?

abhi

unread,
Apr 24, 2018, 8:22:45 AM4/24/18
to Jedis

Has there been any update in the jedis library to handle this scenario since the last post? Configuration for connecting to one master (for writes) and multiple slaves(for reads)?

Sazzadul

unread,
Apr 24, 2018, 3:45:13 PM4/24/18
to Jedis
@abhi, If you mean any update apart from writing an abstraction on top of Jedis, then NO update.

Paul Leddy

unread,
Feb 12, 2019, 7:39:35 AM2/12/19
to Jedis
Care to share the code? I have the same issue to solve this week.
Reply all
Reply to author
Forward
0 new messages