abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.87k stars 3.43k forks source link

abp identityserver4 pressure test /connect/token super slow! #6351

Closed redcatH closed 3 years ago

redcatH commented 3 years ago

Documentation

my with services: AuthServer.Host MallService.Host

AuthServer.Host

            context.Services.AddStackExchangeRedisCache(options =>
            {
                options.Configuration = configuration["Redis:Configuration"];
            });

            //context.Services.AddClientStoreCache
            // Configure<AbpAuditingOptions>(options =>
            // {
            //     options.IsEnabledForGetRequests = true;
            //     options.ApplicationName = "AuthServer";
            // });

            //TODO: ConnectionMultiplexer.Connect call has problem since redis may not be ready when this service has started!
            var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
            context.Services.AddDataProtection()
                .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys");

MallService.Host

        private async Task<JwtDto> GetToken(IdentityUser abpUser, T_Sys_User user)
        {

            // var disco = await serverClient.GetDiscoveryDocumentAsync(Configuration["AuthServer:Authority"]);
            var tokenEndpoint = await _ids4ClientCacheService.GetAsync();
            var serverClient = HttpClientFactory.CreateClient();
            var result = await serverClient.RequestTokenAsync(
                new TokenRequest
                {
                    Address = tokenEndpoint,
                    GrantType = "MallUser",
                    ClientId = Configuration["AuthServer:ClientId"],
                    ClientSecret = Configuration["AuthServer:ClientSecret"],
                    Parameters =
                    {
                        {"user_id", $"{abpUser.Id}"},
                        {"mall_UserId", $"{user.FUserID}"},
                        {
                            "mall_UserName", $"{user.FUserName}"
                        },
                        {
                            "scope", "MallService offline_access"
                        }
                    }
                });
            var token = result.AccessToken;
            if (token.IsNullOrWhiteSpace()) throw new UserFriendlyException(result.Error);
            return new JwtDto
            {
                AccessToken = token,
                RefreshToken = result.RefreshToken
            };
        }

no batch request qq1

ues web api benchmarks ,batch request qq

@hikalkan The problem is very anxious, I suggest that the company use ABP, if it can not be solved, I may lose my job! Help me thanks!

From what I understand, there are others who have encountered the same problem.

maliming commented 3 years ago
redcatH commented 3 years ago

abp version:3.3.1 download:https://abp.io/get-started

CompanyAndProjectName=ids4test
ProjectType=app
UiFramework=angular
DatabaseProvider=EntityFrameworkCore
Mobile=None
IncludeUi=true
Tiered=false
SeparateIdentityServer=false
Preview=false
IncludeUi=false

url: http://192.168.201.103:44346/connect/token jmteter setting jem request summary report report view results tree view results tree response time graph response time graph

During this period I also tried PostMan postman postman response context

System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)
   at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.CreateDbContextWithTransaction(IUnitOfWork unitOfWork)
   at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.CreateDbContext(IUnitOfWork unitOfWork, String connectionStringName, String connectionString)
   at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.<>c__DisplayClass3_0.
<GetDbContext>b__0()
   at System.Collections.Generic.AbpDictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Func`2 factory)
   at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.GetDbContext()
   at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.get_DbSet()
   at Volo.Abp.IdentityServer.Clients.ClientRepository.FindByCliendIdAsync(String clientId, Boolean includeDetails, CancellationToken cancellationToken)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Abp.IdentityServer.Clients.ClientStore.FindClientByIdAsync(String clientId)
   at IdentityServer4.Stores.ValidatingClientStore`1.FindClientByIdAsync(String clientId)
   at IdentityServer4.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId)
   at IdentityServer4.Validation.ClientSecretValidator.ValidateAsync(HttpContext context)
   at IdentityServer4.Endpoints.TokenEndpoint.ProcessTokenRequestAsync(HttpContext context)
   at IdentityServer4.Endpoints.TokenEndpoint.ProcessAsync(HttpContext context)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
   at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
   at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<
    <UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpJwtTokenMiddlewareExtension.<>c__DisplayClass0_0.<
        <UseJwtTokenMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<
            <UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<
                <UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: jenkins-timestamper-offset=-28800000
Host: 192.168.201.103:44346
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
Origin: chrome-extension://coohjcphdfgbiolnekdpbcijmhambjff
Content-Length: 111
X-Correlation-Id: 9e2f41c538fd49d9bf6796371c51bc9a
redcatH commented 3 years ago

two test Modify the connection string Add Max Pool Size=5000 Server=192.168.201.16,1433; Database=IdentityTest; User=sa; Password=123; Max Pool Size=5000;Min Pool Size=0

jmeter setting unchanging 2 3 微信图片_20201126133252

response time 30000!

redcatH commented 3 years ago

@maliming

maliming commented 3 years ago

You can test the application of Identity Server4(include Identity & EF Core)

https://identityserver4.readthedocs.io/en/latest/quickstarts/5_entityframework.html https://identityserver4.readthedocs.io/en/latest/quickstarts/6_aspnet_identity.html

zhjmao commented 3 years ago

i encountered the same problem。 abp version:4.0.0

https://localhost:44357/connect/token

image

Alexbits commented 3 years ago

i encountered the same problem。 abp version:4.0.0

https://localhost:44357/connect/token

Hi @zhjmao Did you solve this problem?

zhjmao commented 3 years ago

i encountered the same problem。 abp version:4.0.0 https://localhost:44357/connect/token

Hi @zhjmao Did you solve this problem?

after update to version 4.1,it works fine

Alexbits commented 3 years ago

after update to version 4.1,it works fine

Thanks @zhjmao I get >400ms on token,login-callback,authorize