skip to Main Content

.Net core 2.1 web-api uses below redis nuget package "StackExchange.Redis" Version="2.1.55" and connects to Azure Redis P1 tier, Redis version 4.0.14

On appsettings.config,

"RedisConfiguration": {
"ConnectionString": "mycache.redis.cache.windows.net:6380,password=$$$$$$$$$F543shkerXXXXXg=,ssl=True,abortConnect=False",
"DatabaseNumber": 1 }

While performing load test,

Receiving below exception very frequently especially when maintaining 50requests/sec. Our application deployed on Azure service fabric cluster with 3 nodes. No processor/memory pressure observed on any of the server nodes.

Message":"Redis exception while setting the value to cache: An unknown
error occurred when writing the
message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException

"Message":"Redis exception while getting the value from cache: An
unknown error occurred when writing the
message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException"
Complete stack trace for your reference:

"StackTrace":" at
StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message
message, ResultProcessor1 processor, ServerEndPoint server) in
//src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2800rn at
StackExchange.Redis.RedisBase.ExecuteSync[T](Message message,
ResultProcessor1 processor, ServerEndPoint server) in
/
/src/StackExchange.Redis/RedisBase.cs:line 54rn at
MyApplication.RedisCacheAdapter.<>c__DisplayClass21_1.b__0() in
M:work27ae5cc7915b5f803MyApplicationRedisCacheAdapter.cs:line
199rn at Polly.Policy.<>c__DisplayClass144_0.b__0(Context
ctx, CancellationToken ct)rn at
Polly.RetrySyntax.<>c__DisplayClass5_1.b__1(Context ctx,
CancellationToken ct)rn at
Polly.Retry.RetryEngine.Implementation[TResult](Func3 action, Context
context, CancellationToken cancellationToken, IEnumerable1
shouldRetryExceptionPredicates, IEnumerable1
shouldRetryResultPredicates, Func1 policyStateFactory)rn at
Polly.RetrySyntax.<>c__DisplayClass5_0.b__0(Action2 action,
Context context, CancellationToken cancellationToken)rn at
Polly.Policy.ExecuteInternal(Action2 action, Context context,
CancellationToken cancellationToken)rn at
Polly.Policy.Execute(Action2 action, Context context,
CancellationToken cancellationToken)rn at
MyApplication.RedisCacheAdapter.Put(String key, Byte[] bytes, TimeSpan
expirytime) in
M:work27ae5cc7915b5f803MyApplicationRedisCacheAdapter.cs:line
196","Exception":"An unknown error occurred when writing the
message","LoggerName":"MyApplication.RedisCacheAdapter","Message":"Redis
exception while setting the value to cache: An unknown error occurred
when writing the
message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException"`

What would be reason for such error & how to fix this "StackExchange.Redis.RedisConnectionException"? Any change in redis connection string properties or redis version update would be useful?

Sometimes, below exception timeout exception as well when maintaining 50requests/sec on 3 nodes cluster

"Message":"Redis Timeout exception occurred.

2

Answers


  1. It could be a problem with serializing and/or deserializering of cache items.

    The first thing to do would be to check if it is allways the same cache items that fail. If that is the case what is special about these items.

    Login or Signup to reply.
  2. You could put ‘syncTimeout’ parameter in ConnectionString like this

    "RedisConfiguration": {"ConnectionString": "mycache.redis.cache.windows.net:6380,password=$$$$$$$$$F543shkerXXXXXg=,ssl=True,abortConnect=False,**syncTimeout=150000** "," DatabaseNumber ": 1}.
    

    This parameter sets the "Time (ms) to allow synchronous operations", as can be seen at https://stackexchange.github.io/StackExchange.Redis/Configuration.html.

    I had this problem when I stored items that took more than 5 seconds to be processed, since this is the default value. You can try increasing this value using the parameter inserted in the connection string. I hope I can help you with this, regards.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search