Redis-py Version: 4.2.0
How can we enable redis-py to read from the LOWEST_LATENCY node? We are using AWS global datastore so we want to enable redis-py to read from the nearest node from the geo-distributed nearest node?
Redis-py Version: 4.2.0
How can we enable redis-py to read from the LOWEST_LATENCY node? We are using AWS global datastore so we want to enable redis-py to read from the nearest node from the geo-distributed nearest node?
Copyright © 2021 Jogjafile Inc.
I think you can't.
The Python library, according to this Amazon article, integrated cluster support originally implemented in this project, so users did not need a 3rd party library for cluster support. However, at the time of writting there is no support for lowest latency mode. The supported modes are
PRIMARIES
,REPLICAS
,ALL_NODES
andRANDOM
. Note that some of these are covered in the Java library, such asREPLICAS
, that I think isANY_REPLICA
in Lettuce.The
LOWEST_LATENCY
mode is implemented in the Java library, it does not seem to be a parameter supported or provided by AWS and from what I could see, it is not present in the Python library.This apparently was called NEAREST, which might mean it was somehow initially linked to geospacial proximity (but this is just a guess):
Looking at
ReadFromLowestCommandLatency()
, here's the definition. Comment has important information about the latency mesurements:All these Readxxx methods somehow use
getNodes()
, which returns nodes sorted by latency. But this sorting occurs in the library. The library seems to implement the latency sorting, which is not done in the Python implementation.I did not perform a full code analysis, but for example this method in
TopologyComparators.java
seems to confirm this:Sorry if you already know some of this, but as I took a look I thought I would post it as an answer.