abp
abp copied to clipboard
Redis Cache verry slow
Description
When I create an application netcore combine with Redis Cache + db mssql it request verry fast approximately 24k req/second?? But When I use redis in abp in service it very slow 1.8k req/second ?? it similary request from db?? I already debug it ok get value from redis, But it very slow???
Configuration
Net 7 and Abp Version 7.0.0
Regression?
My Code
// var cacheDb = await _cache.GetOrAddAsync(
// id, //Guid type used as the cache key
// async () => ObjectMapper.Map<FileItem, FileItemDto>(await _fileManager.GetFileInfoAsync(id)),
// () => new DistributedCacheEntryOptions
// {
// AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
// }
// );
var cacheDb = await _cache.GetAsync(id);
if (cacheDb != null)
{
return cacheDb;
}
else
{
var data = ObjectMapper.Map<FileItem, FileItemDto>(await _fileManager.GetFileInfoAsync(id));
await _cache.SetAsync(id,data);
return data;
Analysis
Please set Debug as your log level and check the logs.
Please set Debug as your log level and check the logs.
it ok no error. But It can not process a lot of request base redis, very slow?? I tried it with oha just over 1.8k request/second
[13:40:43 ERR] A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Volo.Abp.Threading.SemaphoreSlimExtensions.LockAsync(SemaphoreSlim semaphoreSlim, CancellationToken cancellationToken)
at Volo.Abp.Caching.DistributedCache`2.GetOrAddAsync(TCacheKey key, Func`1 factory, Func`1 optionsFactory, Nullable`1 hideErrors, Boolean considerUow, CancellationToken token)
at Becamex.ArchiveCenter.DictionaryAppService.GetAsync(Guid id) in /home/nemo/apps/source/develop/archive-center-backend/src/Becamex.ArchiveCenter.Application/Dictionaries/DictionaryAppService.cs:line 31
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
Can you share the detailed steps so I can reproduce this?
Can you share the detailed steps so I can reproduce this?
When I reduce (remove) middlewares default by abp, It better over 7k req/sec?? May be middlewares leading to performance??
You can check your app logs.
You can check your app logs.
I already checked app logs, But no special problems??
I also met this issue. I think when too much request the method semaphoreslim.lockasync lock cache key. I deploy on cluster with load balancer