Open Closed

ABP 5.0 - very slow when using the Startup Template #2303


User avatar
0
scottie.tang@cpy.com.hk created
  • ABP Framework version: v5.0.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi, we recently upgraded our project to 5.0 from 4.x, however we found that the performance is slower than before.
So we tried to start from scratch using the provided startup template project (new project from abp suite), but we still experienced the same performance issue. Especially when we are loading users / add user at the admin portal. Please help, thanks.

Here is a gif to illustrate the issue:

TemplateUIAction.gif <---- ABP 5.0 performance old-ABP4.gif <---- ABP 4.X performance


8 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I have to try testing with a new startup template, but can't reproduce the problem, can you provide full steps? thanks.

  • User Avatar
    0
    scottie.tang@cpy.com.hk created

    Hi , Our steps are :

    1. abp suite
    2. create a "application" startup template
    3. modify the SQL connection string
    4. start the three programs (identityServer, host, blazer)

    This is our video screen recording.

    http://hkio.net/video.mp4

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I will check it , thanks.

  • User Avatar
    0
    scottie.tang@cpy.com.hk created

    Additional Info:

    Database - latest mssql server docker image ( image: mcr.microsoft.com/mssql/server ) Redis - disabled ( also tried enabled using image: redis:6.0.10-alpine )

    Except appsetting.config, we haven't done any code change.

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    Did you try it in an other PC? Do you get the same result?

    It seemed like a cpu issue to me. At the end, you are hosting and debugging on same machine.

    at 15:01:46 you are making a login request and you got response at 15:01:51. AccountController.Login action takes 4770ms doesn't seem normal.

    Seems to me, it is related with your local server hardware. Maybe you can check if there is also some other live high priority process is also running when you start debugging the projects.

  • User Avatar
    0
    scottie.tang@cpy.com.hk created

    Hi,

    I have deployed the same project to a dedicated server. It has the same result (slow). I do not think it is a CPU related issue, because at version 4.X, the speed is significantly faster. (same server machine)

    Please help.

    Many Thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I have reproduced the problem, thank you, we will fix it. see https://github.com/abpframework/abp/pull/11006

    PS: your ticket refunded.

    For now, you can try:

    [ExposeServices(
        typeof(ICachedApplicationConfigurationClient),
        typeof(IAsyncInitialize)
    )]
    public class MyMvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
    {
        protected IHttpContextAccessor HttpContextAccessor { get; }
        protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; }
        protected ICurrentUser CurrentUser { get; }
        protected IDistributedCache<ApplicationConfigurationDto> Cache { get; }
    
        public MyMvcCachedApplicationConfigurationClient(
            IDistributedCache<ApplicationConfigurationDto> cache,
            AbpApplicationConfigurationClientProxy applicationConfigurationAppService,
            ICurrentUser currentUser,
            IHttpContextAccessor httpContextAccessor)
        {
            ApplicationConfigurationAppService = applicationConfigurationAppService;
            CurrentUser = currentUser;
            HttpContextAccessor = httpContextAccessor;
            Cache = cache;
        }
    
        public async Task InitializeAsync()
        {
            await GetAsync();
        }
    
        public async Task<ApplicationConfigurationDto> GetAsync()
        {
            var cacheKey = CreateCacheKey();
            var httpContext = HttpContextAccessor?.HttpContext;
    
            if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
            {
                return configuration;
            }
    
    
            configuration = await Cache.GetOrAddAsync(
                cacheKey,
                async () => await ApplicationConfigurationAppService.GetAsync(),
                () => new DistributedCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable.
                }
            );
    
            if (httpContext != null)
            {
                httpContext.Items[cacheKey] = configuration;
            }
    
            return configuration;
        }
    
        public ApplicationConfigurationDto Get()
        {
            var cacheKey = CreateCacheKey();
            var httpContext = HttpContextAccessor?.HttpContext;
    
            if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
            {
                return configuration;
            }
    
            return AsyncHelper.RunSync(GetAsync);
        }
    
        protected virtual string CreateCacheKey()
        {
            var userKey = CurrentUser.Id?.ToString("N") ?? "Anonymous";
            return $"ApplicationConfiguration_{userKey}_{CultureInfo.CurrentUICulture.Name}";
        }
    }
    
  • User Avatar
    0
    scottie.tang@cpy.com.hk created

    Thank you.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11