Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delays in Amplify SDK requests #1035

Closed
jbelkins opened this issue Jun 9, 2023 · 12 comments
Closed

Delays in Amplify SDK requests #1035

jbelkins opened this issue Jun 9, 2023 · 12 comments
Assignees
Labels
amplify Related to aws-amplify/amplify-swift bug This issue is a bug.

Comments

@jbelkins
Copy link
Contributor

jbelkins commented Jun 9, 2023

Describe the bug

Amplify reports that Cognito auth requests sent via the SDK for Swift are being delayed about 2 sec:
aws-amplify/amplify-swift#3007

Investigate to see if this can be reproduced, and what the potential cause might be.

Expected Behavior

Requests are made immediately when the SDK operation is called

Current Behavior

Requests are delayed about 2 sec (see logs in attached Amplify ticket)

Reproduction Steps

Not immediately known, will investigate

Possible Solution

No response

Additional Information/Context

No response

AWS SWIFT SDK version used

0.13.0

Compiler and Version used

See attached

Operating System and version

See attached

@jbelkins jbelkins added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 9, 2023
@jbelkins jbelkins changed the title (short issue description) Delays in Amplify SDK requests Jun 9, 2023
@jbelkins jbelkins added the amplify Related to aws-amplify/amplify-swift label Jun 9, 2023
@jbelkins
Copy link
Contributor Author

Time box to a day of investigation

@jbelkins jbelkins removed the needs-triage This issue or PR still needs to be triaged. label Jun 19, 2023
@jbelkins jbelkins self-assigned this Jun 19, 2023
@jbelkins
Copy link
Contributor Author

Was unable to reproduce. Awaiting further reproduction code samples or instructions from the reporters.

@jbelkins jbelkins added the needs-reproduction This issue needs reproduction. label Aug 1, 2023
@jbelkins
Copy link
Contributor Author

jbelkins commented Aug 1, 2023

Attempt to reproduce using sample code provided in the linked Amplify ticket.

@dayaffe
Copy link
Contributor

dayaffe commented Aug 2, 2023

It looks like I am able to reproduce the issue using the provided amplify project AmplifySlowLogin

@jbelkins
Copy link
Contributor Author

Investigated, and the reason is that HTTP connection pools are never being reused, and a new HTTP connection must be established prior to every HTTP request.

I will work with CRT to ensure that we reuse connection pools appropriately, and that we manage connections per the Smithy Reference Architecture.

@sichanyoo sichanyoo removed the needs-reproduction This issue needs reproduction. label Oct 9, 2023
@fzy-github
Copy link

hey, do you have any update on the issue above?

@jbelkins
Copy link
Contributor Author

@fzy-spyro I am working on the solution now. We have a significant amount of work to do on the SDK's connection pooling logic but prior to that, I will find an interim solution that fixes this performance issue without causing problems elsewhere.

I will update here when a fix has been applied to the AWS SDK for Swift. Once that happens, Amplify will have to integrate it into an amplify-swift release.

@jbelkins
Copy link
Contributor Author

jbelkins commented Nov 2, 2023

The fix for this issue is expected to ship in AWS SDK for Swift next week. Once that happens, a new amplify-swift version will have to be shipped as well, incorporating the fixed version of this SDK.

Thanks for your patience while we addressed this issue.

@fzy-github
Copy link

this is great news, thanks!

@jbelkins
Copy link
Contributor Author

jbelkins commented Nov 7, 2023

Released in aws-sdk-swift 0.31.0.

Note that HTTP connections are not used across AWS clients; i.e. if you create two S3 clients, they do not share HTTP connections between them. We recommend that customers create one AWS service client per service per app launch, and keep a reference to the client for future use.

@harsh62
Copy link
Member

harsh62 commented Jan 30, 2024

@jbelkins Can we please reopen the issue? The customer has reported that the issue is still not fixed and they are still facing the same problem.

@jbelkins
Copy link
Contributor Author

jbelkins commented Feb 2, 2024

@harsh62 AWS SDK for Swift 0.34.0 makes a new, URLSession-based HTTP client the default on all Apple platforms. That client does not use the connection pooling mechanism that was at fault in this original issue, and should overall be better suited to use on the platforms supported by amplify-swift.

Best solution to the problem would be to update amplify-swift to use version 0.34.0+ of this SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amplify Related to aws-amplify/amplify-swift bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants