Skip to content

Support redis cluster readfrom strategy#28

Merged
vaibhav-jain-exp merged 3 commits into
mainfrom
support-read-strategy
Jan 22, 2026
Merged

Support redis cluster readfrom strategy#28
vaibhav-jain-exp merged 3 commits into
mainfrom
support-read-strategy

Conversation

@vaibhav-jain-exp
Copy link
Copy Markdown
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
Copy Markdown

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.

Comment thread README.md
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
Copy Markdown
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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This could be extended to support more values if need arises in the future.

@vaibhav-jain-exp vaibhav-jain-exp merged commit e9cc024 into main Jan 22, 2026
5 checks passed
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.

2 participants