Open Closed

Regarding long login lead time #10148


User avatar
0
rexhxiao created

We are using Angular + AuthServer (OpenIddict) for authentication, but the client reported that it takes 3-5 seconds from opening the application to reaching the login page. Is this normal, or how can we speed up this process?


6 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution
    • 3–5 seconds is longer than typical for ABP Angular + AuthServer/OpenIddict in a healthy local/prod setup. The delay usually comes from one or more of:
      • Angular initial bundle load and first-time OIDC discovery/token round-trip
      • Database/permission seeding or permission grant lookups on first call
      • Redis or distributed cache not running/misconfigured (cache misses → DB hits)
      • CORS/middleware misconfig or connection issues causing retries
    • Apply these concrete checks and optimizations:

    Backend (AuthServer/OpenIddict + HttpApi.Host)

    1. Ensure distributed cache is up and reachable
    • If you configured Redis for the solution template, make sure Redis is running and the connection string is correct. ABP’s permission store and app configuration endpoints benefit from cache; without it, first load hits DB repeatedly and slows login/redirect.
    • Verify no connection errors in logs and that cache keys get set.
    1. Pre-seed tenants/permissions outside of the login request
    • Avoid heavy work (migrations, bulk permission grants, role creation, etc.) in the same request chain as login/authorize. Move tenant creation/permission seeding to a background process, domain event handler, or an administration workflow, not during the OIDC redirect flow. Long-running DB work inside the account/register/login flow directly increases the time to reach Angular.
    1. Check DB performance and timeouts
    • Ensure DB indexes exist for ABP tables heavily used during login/first load (e.g., AbpPermissionGrants).
    • Increase DB command timeout only if you’ve addressed query slowness. If you see command timeouts for batched PermissionGrants, reduce batch size or defer them outside the request.
    1. Verify CORS and endpoints
    • Ensure AuthServer CORS origins include the Angular URL. Misconfigured CORS can add delays due to retries/preflight patterns. After successful auth, Angular calls:
      • /.well-known/openid-configuration and /.well-known/openid-configuration/jwks
      • /connect/token
      • /api/abp/application-configuration Make sure these are fast and not blocked by any middleware or reverse proxy.
    1. Keep the OpenIddict server lean
    • Disable unnecessary middleware in the auth host during login (excess logging at Trace, heavy health checks on every request, etc.).
    • Ensure production build settings for the server (Release build, response compression enabled).

    Angular 6) Use production build and lazy loading

    • Build Angular in production mode (ng build --configuration production) and serve gz/br compressed assets on the hosting side to reduce initial load.
    • Keep routes lazy-loaded and avoid heavy synchronous work in app initializers.
    1. Cache the discovery document
    • Angular’s OAuth client will fetch the OIDC discovery document on app start. Make sure the issuer URL is stable and fast. Hosting the AuthServer on the same LAN/region and enabling HTTP/2 helps.
    1. Confirm redirectUri and silent refresh timing
    • Ensure redirectUri points to a fast-loading route and that silent refresh/initial auth sequence isn’t configured to re-load app multiple times.

    Checklist to validate quickly

    • Start AuthServer and verify logs: no timeouts, no Redis errors, no CORS warnings.
    • Hit /.well-known/openid-configuration directly in the browser: must respond quickly (<100 ms locally).
    • Check /api/abp/application-configuration latency right after login: should be fast (<300–500 ms). If slow, it indicates cache/DB pressure.
    • Run Angular in production mode and serve compressed bundles.

    This approach aligns with common ABP conventions, but specific official documentation for this exact performance scenario is not available.

    1. Sources
    • https://abp.io/docs/latest/modules/openiddict
    • https://abp.io/support/questions/3587
    • https://abp.io/support/questions/102
    • https://abp.io/support/questions/565

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What is your abp framework version?

    Can you test with a new and latest template project?

    Thanks.

  • User Avatar
    0
    rexhxiao created

    Using ABP 8, here is the online URL: https://imm.koimpact.tw/

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you set the log level to Debug and share the full login process logs?

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems

    liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    rexhxiao created

    Let’s check it again ourselves to make sure.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok, You can share debug logs later. Thanks.

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.1.0-preview. Updated on December 03, 2025, 13:19
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.