Open Closed

AbpApplicationConfigurationAppService GetAsync is slow when redis cache is enabled #9363


User avatar
0
sinancondo created

In reference to this thread : https://abp.io/support/questions/9088/API-become-slow-after-enabling-Redis-server

I have overridden the AbpApplicationConfigurationAppService and find the worst offender is : await GetAuthConfigAsync(); As it takes sometimes on intial call 8 seconds, on subsequent calls it get down to around 3 second, which is still have. So in total GetAsync call takes, I am using local docker Redis and the CPU and others are all look very good, no pressure on the server and no physical network, can you please advise ?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    How many policies of abpPolicyNames and otherPolicyNames?

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    sinancondo created

    We have around 190 permission in the [dbo].[AbpPermissions] table with 5 roles, we dont use explicitly claims , it is more users/roles/permissions structure .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    190 permission should be pretty quick. I think the issue still has to do with Redis.

    You can try to disable the cache in PermissionStore?

    using System.Linq;
    using System.Threading.Tasks;
    using Volo.Abp.Authorization.Permissions;
    using Volo.Abp.Caching;
    using Volo.Abp.DependencyInjection;
    using Volo.Abp.Domain.Repositories;
    
    namespace Volo.Abp.PermissionManagement;
    
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IPermissionStore), typeof(PermissionStore), typeof(MyPermissionStore))]
    public class MyPermissionStore : PermissionStore
    {
        public MyPermissionStore(
            IPermissionGrantRepository permissionGrantRepository,
            IDistributedCache<PermissionGrantCacheItem> cache,
            IPermissionDefinitionManager permissionDefinitionManager)
            : base(permissionGrantRepository, cache, permissionDefinitionManager)
        {
        }
    
        public async override Task<bool> IsGrantedAsync(string name, string providerName, string providerKey)
        {
            using (PermissionGrantRepository.DisableTracking())
            {
                var permissionGrant = await PermissionGrantRepository.FindAsync(name, providerName, providerKey);
                return permissionGrant != null;
            }
        }
        
        public async override Task<MultiplePermissionGrantResult> IsGrantedAsync(string[] names, string providerName, string providerKey)
        {
            Check.NotNullOrEmpty(names, nameof(names));
    
            var result = new MultiplePermissionGrantResult();
    
            if (names.Length == 1)
            {
                var name = names.First();
                result.Result.Add(name, await IsGrantedAsync(names.First(), providerName, providerKey)
                    ? PermissionGrantResult.Granted
                    : PermissionGrantResult.Undefined);
                return result;
            }
    
            using (PermissionGrantRepository.DisableTracking())
            {
                var permissionGrants = await PermissionGrantRepository.GetListAsync(names, providerName, providerKey);
                foreach (var name in names)
                {
                    result.Result.Add(name,
                        permissionGrants.Any(x => x.Name == name)
                            ? PermissionGrantResult.Granted
                            : PermissionGrantResult.Undefined);
                }
    
                return result;
            }
        }
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.