Hi @ismcagdas,
Since my first message I decided to delete all records and the app performance is better. Azure was suggesting to create an index for AbpUserTokens table. I will try to add it and see differences.
But the main question is : don't you think that this table could be really big with time ? For example, if you have 500 users that connects every day, this means arround 200k records in that table at the end of one year... something is wrong here.
Hi @ismcagdas, thank you for this. I will try it and provide feedback on all related issues.
Hi @ismcagdas,
I just tried PerRequestRedisCache with a fresh new redis server.
I'm getting same exception as explained here : Unable to cast object of type 'Abp.MultiTenancy.TenantCacheItem
Here is the status of the redis database before running PerRequestRedisCache and after exceptions occurs :
Thank you @ismcagdas
Hi @ismcagdas,
I just tried with 6.6.1 and it is not working. If I deactivate usePerRequestRedisCache option like below, everything works again :
Configuration.Caching.UseRedis(options =>
{
options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"];
options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId");
}, usePerRequestRedisCache : false);
If I connect to host, I have following error :
ERROR 2021-12-02 16:18:33,653 [28 ] Mvc.ExceptionHandling.AbpExceptionFilter - Unable to cast object of type 'Abp.Authorization.Users.UserPermissionCacheItem' to type 'Abp.Authorization.Roles.RolePermissionCacheItem'.
System.InvalidCastException: Unable to cast object of type 'Abp.Authorization.Users.UserPermissionCacheItem' to type 'Abp.Authorization.Roles.RolePermissionCacheItem'.
at Abp.Runtime.Caching.TypedCacheWrapper`2.GetAsync(TKey key, Func`2 factory)
at Abp.Authorization.Roles.AbpRoleManager`2.GetRolePermissionCacheItemAsync(Int32 roleId)
at Abp.Authorization.Roles.AbpRoleManager`2.IsGrantedAsync(Int32 roleId, Permission permission)
at Abp.Authorization.Users.AbpUserManager`2.IsGrantedAsync(Int64 userId, Permission permission)
at Abp.Authorization.Users.AbpUserManager`2.IsGrantedAsync(Int64 userId, String permissionName)
at Abp.Authorization.PermissionChecker`2.IsGrantedAsync(Int64 userId, String permissionName)
at Abp.Authorization.PermissionChecker`2.IsGrantedAsync(String permissionName)
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetUserAuthConfig()
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetAll()
at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.GetAll()
at lambda_method1396(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
If I connect to a tenant, I have following error :
ERROR 2021-12-02 16:18:54,004 [33 ] Mvc.ExceptionHandling.AbpExceptionFilter - Unable to cast object of type 'Abp.MultiTenancy.TenantCacheItem' to type 'System.Collections.Generic.Dictionary`2[System.String,Abp.Localization.ApplicationLanguage]'.
System.InvalidCastException: Unable to cast object of type 'Abp.MultiTenancy.TenantCacheItem' to type 'System.Collections.Generic.Dictionary`2[System.String,Abp.Localization.ApplicationLanguage]'.
at Abp.Runtime.Caching.TypedCacheWrapper`2.Get(TKey key, Func`2 factory)
at Abp.Runtime.Caching.TypedCacheExtensions.Get[TKey,TValue](ITypedCache`2 cache, TKey key, Func`1 factory)
at Abp.Localization.ApplicationLanguageManager.GetLanguageDictionaryFromCache(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetLanguageDictionary(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetLanguages(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetActiveLanguages(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageProvider.GetActiveLanguages()
at Abp.Localization.LanguageManager.GetActiveLanguages()
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetUserLocalizationConfig()
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetAll()
at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.GetAll()
at lambda_method1396(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Hi @ismcagdas,
I've updated the project to Abp 6.6 to test redis usePerRequestRedisCache option. When I activate redis with this option, I'm getting an Internal Server Error :
ERROR 2021-11-30 18:23:14,135 [36 ] Mvc.ExceptionHandling.AbpExceptionFilter - Unable to cast object of type 'Abp.MultiTenancy.TenantCacheItem' to type 'System.Collections.Generic.Dictionary`2[System.String,Abp.Localization.ApplicationLanguage]'.
System.InvalidCastException: Unable to cast object of type 'Abp.MultiTenancy.TenantCacheItem' to type 'System.Collections.Generic.Dictionary`2[System.String,Abp.Localization.ApplicationLanguage]'.
at Abp.Runtime.Caching.TypedCacheWrapper`2.Get(TKey key, Func`2 factory)
at Abp.Runtime.Caching.TypedCacheExtensions.Get[TKey,TValue](ITypedCache`2 cache, TKey key, Func`1 factory)
at Abp.Localization.ApplicationLanguageManager.GetLanguageDictionaryFromCache(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetLanguageDictionary(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetLanguages(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageManager.GetActiveLanguages(Nullable`1 tenantId)
at Abp.Localization.ApplicationLanguageProvider.GetActiveLanguages()
at Abp.Localization.LanguageManager.GetActiveLanguages()
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetUserLocalizationConfig()
at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetAll()
at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.GetAll()
at lambda_method1396(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
I've followed abp documentation to activate this option : import NuGet package and add depends on. Then, I use it like that :
Configuration.Caching.UseRedis(options =>
{
options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"];
options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId");
}, usePerRequestRedisCache: true);
if I deactivate option usePerRequestRedisCache, the app works again.
Could you please check it ?
Hi @ismcagdas,
Tks for your quick answer. I will do it.
Hi @ismcagdas,
Tks for your answer, I will implement redis then.
I'm seeing more and more questions about multiple instance management for aspnetboilerplate. It is a very common use case to scale out an application according to workload. I'm currently facing these issue with Azure App Service.
When an application is scalled, you can have lots of issues, like :
It will be nice if you guys could create some docs or guidelines about multiple instance management with zero and aspnetboilerplate
Hi @musa.demir,
Thanks for your answer. I'm having issue with backgroundworkers on multiple instances, see https://github.com/aspnetzero/aspnet-zero-core/issues/4103. Thefore, I just wanted to confirm if something similar could happen with webhooks. In fact, background job should not be an issue on multiple instance context.