Reputation: 5418
I have an AWS Elasticache Redis instance with 2 nodes - primary and a read replica. I'm connecting to the instance using StackExchange.Redis
.
The databases
value passed to the constructor is a comma separated string containing both the primary endpoint and the reader endpoint.
public class RedisCacheConnectionFactory : IRedisCacheConnectionFactory
{
private readonly Lazy<ConnectionMultiplexer> _connector;
public RedisCacheConnectionFactory(string databases)
{
var options = ConfigurationOptions.Parse(databases);
options.AbortOnConnectFail = false;
options.SyncTimeout = 1000;
this._connector = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(options));
}
public ConnectionMultiplexer Connection() => this._connector.Value;
}
It looks like no read requests are going to the read replica and they are all hitting the primary instance.
I was under the impression that read replicas would help share the load of read requests to increase throughput. Why are no read requests showing against the read replica?
Upvotes: 1
Views: 1780
Reputation: 8049
CommandFlags
param to either CommandFlags.PreferSlave
or CommandFlags.PreferReplica
(looks like they are both set to the same value).See here: https://github.com/StackExchange/StackExchange.Redis/issues/1363#issuecomment-590592408
and
Upvotes: 0