DuendeSoftware / IdentityServer

The most flexible and standards-compliant OpenID Connect and OAuth 2.x framework for ASP.NET Core
https://duendesoftware.com/products/identityserver
Other
1.4k stars 317 forks source link

Investigate EF Core 8 performance issues #1564

Open AndersAbel opened 1 month ago

AndersAbel commented 1 month ago

EF Core 8 introduced the usage of OpenJSON for SQL Server query generation to improve query plan caching. That turned out to give unexpected performance because of how the SQL Server query engine handles the result of OpenJSON. See https://github.com/dotnet/efcore/issues/32394 for details.

This has been reported to give performance issues for customers that are using our EF implementations.

Investigate if this has such a high impact that we need to apply any kind of workaround in our implementation.

luckyboykg commented 2 weeks ago

I also have a perfromance issue when using Identity Server with .NET 8. Firstly, I used Identity Server 4 + .NET 6, and everything was OK, but after upgrading to .NET 8, I saw the response time slower. (from ~400ms to ~2s). My Identity Server even throws crash exceptions 3 times a day. (System out of memory exception)

After that, I upgraded from IS4 to Duende Identity Server 7 + .NET8, but the perfromance issue is still there. The performance issue was gone when I downgraded to .NET 6 + Duende Identity Server 6.3.

AndersAbel commented 2 weeks ago

@luckyboykg Do you have any performance metrics that indicates that your issue does indeed relate to the EF core issues? Or have you found something else?

luckyboykg commented 2 weeks ago

I can assure you the code base has stayed the same. Only the .NET and Duende Identity Server versions were downgraded, which fixed my issue. (.NET 6 + Identity Server 4 or Duende Identity Server 6.3)

I run Identity Server 4 or Duende Identity Server 7 in .NET 8 on Azure App Service, and the API response time generally is still slower, around ~1s-2s. I can't reproduce this issue from my local side. This issue only occurs in the Prod environment.

I wonder if this performance issue relates to EF Core 8 or anything else from .NET 8 that is incompatible with the Duende Identity Server.