aws / aws-sdk-net-extensions-cognito

An extension library to assist in the Amazon Cognito User Pools authentication process
Apache License 2.0
102 stars 49 forks source link

`CognitoAuthHelper.GetAssemblyFileVersion` Expensive CPU Wise #107

Closed theobalestra closed 1 year ago

theobalestra commented 1 year ago

Describe the bug

We’ve noticed some issues with the AWS Cognito Dotnet Library in terms of performance. We were having some performance issues on our server, and upon investigation, every Cognito call that we make calls a function CognitoAuthHelper.GetAssemblyFileVersion that is rather expensive since it reads an Assembly to get the version and send it back to AWS for metrics. As shown in the flame graph below, it’s taking around 77ms of CPU time, (which in the case of this endpoint we make 3 cognito calls, which accounts for 90%+ of the CPU time). It also reads it every single time we make a call instead of caching the version, which would stay unchanged if the process is never restarted. Cognito Flame Graph

Expected Behavior

Not have a CPU expensive call everytime there is a Cognito Call

Current Behavior

Every Cognito API call causes a large block when attempting to read an assembly file

Reproduction Steps

Any call to Cognito SDK will cause the issue

Possible Solution

Disable the call to get the AssemblyFileVersion, or cache the version

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.Core v3.7.13.10

Targeted .NET Platform

.NET Core 3.1

Operating System and version

Windows Server 2019, Mac OS Ventura

ashishdhingra commented 1 year ago

Caching assembly version seems to be a good idea rather than making call every time. Needs review with the team.

@mojotheo Thanks for opening the issue. Would you be willing to contribute a PR to fix the issue?

theobalestra commented 1 year ago

@ashishdhingra Yep! Here you go: https://github.com/aws/aws-sdk-net-extensions-cognito/pull/108

theobalestra commented 1 year ago

@ashishdhingra When do you expect the team to have a path forward with this? We need to know if we should pursue a work around in the mean time.

ashishdhingra commented 1 year ago

Released in Amazon.Extensions.CognitoAuthentication version 2.3.1

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.