Skip to content

Conversation

@vaibhav-jain-exp
Copy link
Contributor

Add configurable Redis read routing strategy

Changes

  • Added readFrom configuration field for Redis Cluster mode
  • Default changed from hardcoded REPLICA_PREFERRED to ANY for better load distribution
  • Supports two options:
    • ANY (default): Distributes reads across all nodes (masters + replicas)
    • REPLICA_PREFERRED: Prefers replicas, falls back to master

Configuration

redis:
uri: "redis://cluster:6379"
useCluster: true
readFrom: "ANY" # or "REPLICA_PREFERRED"

@macroscopeapp
Copy link

macroscopeapp bot commented Jan 21, 2026

Add Redis Cluster read routing control and document configuration in com.amplitude.util.redis.createRedisConnections

Introduce readFrom in com.amplitude.RedisConfiguration, read AMPLITUDE_REDIS_READ_FROM in fromEnv, parse values with com.amplitude.util.redis.parseReadFrom, and apply the strategy in cluster connections; update docs in README.md.

📍Where to Start

Start with com.amplitude.util.redis.createRedisConnections in core/src/main/kotlin/util/redis/RedisConnections.kt.


Macroscope summarized 8283e8c.

redis:
uri: "YOUR REDIS URI" # e.g. "redis://localhost:6379"
useCluster: false # Set to true for Redis Cluster
readFrom: "ANY" # Read routing: "ANY" (default) or "REPLICA_PREFERRED"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have two options ANY and REPLICA_PREFERRED can we just make this a boolean that defaults false. E.g. readFromReplica where false=ANY and true=REPLICA_PREFERRED?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants