2017-11-08 16 views
0

[C#] CacheManager에 Redis Server 풀 크기를 설정하는 방법은 무엇입니까?CacheManager에서 Redis Server 풀 크기를 설정하는 방법은 무엇입니까?

높은 동시성으로 오류가 발생했습니다.이 작업을 서비스 할 수있는 연결이 없습니다 : HMGET, 연결 풀 크기를 설정하는 방법?

No connection is available to service this operation: HMGET U 

at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) 
    at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) 
    at StackExchange.Redis.RedisDatabase.HashGet(RedisKey key, RedisValue[] hashFields, CommandFlags flags) 
    at CacheManager.Redis.RedisCacheHandle`1.<>c__DisplayClass25_0.<GetCacheItemInternal>b__0() 
    at CacheManager.Redis.RetryHelper.Retry[T](Func`1 retryme, Int32 timeOut, Int32 retries) 
    at CacheManager.Redis.RedisCacheHandle`1.Retry[T](Func`1 retryme) 
    at CacheManager.Redis.RedisCacheHandle`1.GetCacheItemInternal(String key, String region) 
    at CacheManager.Redis.RedisCacheHandle`1.GetCacheItemInternal(String key) 
    at CacheManager.Core.Internal.BaseCache`1.GetCacheItem(String key) 
    at CacheManager.Core.BaseCacheManager`1.GetCacheItemInternal(String key, String region) 
    at CacheManager.Core.BaseCacheManager`1.GetCacheItemInternal(String key) 
    at CacheManager.Core.Internal.BaseCache`1.GetCacheItem(String key) 
    at CacheManager.Core.Internal.BaseCache`1.Get(String key) 
    at CacheManager.Core.Internal.BaseCache`1.Get[TOut](String key) 

======================= Stackexchange.Redis 연결 풀링을 사용하지 않는

 var cache = CacheFactory.Build("RuntimeCache", settings => 
     { 
      settings.WithSystemRuntimeCacheHandle("RuntimeCache") 
      .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(10)) 
      .And 
      .WithRedisConfiguration("RedisCache", config => 
      { 
       config.WithAllowAdmin() 
       .WithDatabase(1) 
       .WithPassword(password) 
       .WithEndpoint(host, port); 
      }) 
      .WithMaxRetries(100) 
      .WithRetryTimeout(50) 
      .WithRedisBackPlate("RedisCache") 
      .WithRedisCacheHandle("RedisCache", true) 
      .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(30)); 
     }); 

답변

1

대신, multiplexing을 사용합니다.

configuration => syncTimeout을 통해 라이브러리가 동기화 호출을 대기하는 시간 (기본값은 1000ms)을 변경할 수 있습니다. CacheManager와 함께 사용하려면 연결 문자열 기반 구성을 사용하거나 Multiplexer을 직접 만드십시오. 이로 인해 경험이 향상 될 수 있습니다.

어쨌든 시간 초과 및 연결 오류는 대부분 클라이언트와 관련이 없으며 특히 서버의 메모리 제한에 도달하고 Redis가 키를 제거하려고하는 경우 Redis 서버의 단일 스레드 특성으로 인해 발생합니다. 레디 스 디스크에 백업 ...하려고하면 이러한 문제는 당신이 시도되고 레디 스 서버가 사용하고있는에 크게 의존으로

나는 당신에게

... 당신에게 더 명확한 대답을 줄 수 없습니다 그 오류에 대한 다른 많은 q/a를 발견 할 것입니다. StackExchange.Redis timeout and "No connection is available to service this operation"

참조