-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
refactor: Migrate S3 Client from AWS SDK v2 to v3 #220
Conversation
Thanks for opening this pull request! |
index.js
Outdated
|
||
// Block the event loop until the promise resolves | ||
while (!isDone) { | ||
deasync.sleep(100); // Sleep for 100 milliseconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100ms seems quite long, what is this value based on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 100ms value was an estimate to prevent CPU overload from a tight loop, as there's no specific AWS documentation on the exact timing needed for this function. Reducing it to 10ms might be possible. Additionally, I suggest opening an issue on parse-server to make the getFileLocation function async, eliminating the need for the deasync library altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reduced it to 10ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we estimate the response time for an intra-region call from EC2 to S3 (i.e. Parse Server also running on AWS) to be ~10-100ms, then a 100ms sleep would on avg. double the response time. Maybe setting to 50ms could be a good compromise.
We can only guess a value here, because the best value depends on the actual response times of the specific infrastructure scenario. Using deasync
is really more of a hack and we don't know how this responds under heavy concurrent load given that deasync.sleep
blocks the event loop. Maybe the correct approach here would be to modify Parse Server first to support sync and async calling of getFileLocation
, and then modify the S3 adapter. Would be open to submit a PR to Parse Server? We could add another bounty for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback! I don't currently have a Parse Server test setup, but I can certainly set one up. It might take some time, but I'm definitely up for the task. I'm happy to work on this without needing the bounty.
Could you please create an issue on the Parse Server repository for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, see parse-community/parse-server#9268.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🙏 I'll get started on it. 🚀
How should we proceed here; I suggest to first make the change in Parse Server parse-community/parse-server#9268, release, and then update this PR? |
Yes, I agree that we should update the Parse Server first, release it, and then come back to this PR. I've also fixed the bug when running npm run test on this repo. However, I noticed that the Istanbul configuration might need some adjustments to fully support async functions. I suggest we address that after merging this PR. |
Great, let's take care of parse-community/parse-server#9271 first. |
@vahidalizad How should we proceed? We merged parse-community/parse-server#9271 and released it as part of Parse Server 7.3.0. Can this PR be closed in favor of #221, and can #221 be merged yet? |
Thanks for merging and reaching out! Yes, this PR can be closed in favor of #221. As far as I know, that PR is ready for CI testing, review, and merge. |
Summary
This pull request migrates the S3 client implementation from AWS SDK v2 to v3.
Changes
S3Client
from@aws-sdk/client-s3
package.getObject
,putObject
, etc.) with their v3 equivalents (GetObjectCommand
,PutObjectCommand
, etc.).Notes
getSignedUrl
function in AWS SDK v3 became asynchronous due to new authentication mechanisms. However, because of the wayparse-server
is designed, this function should not be asynchronous. To address this,deasync
was used to make the function synchronous. It might be better to changeparse-server
to support the asynchronous nature of this function in the future.References
Please review the changes and provide feedback. Thank you for your time and consideration.
Closes: #197