Refactor S3 Transfer Manager uploadDirectory to limit the number of c… #5031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…oncurrent upload file requests.
Motivation and Context
Currently, there's no limit on the number of uploadFileRequets in parallel; it depends on how fast it traverses the file and all futures are kept in memory. This could cause memory issues for users who upload a directory that has millions of files because millions of futures will be in memory until upload directory finishes.
See #5023
Modifications
Set a limit on the number of concurrent upload file requests for upload directory by using
AsyncBufferingSubscriber
that controls the request concurrency (it's used in downloadDirectory as well).Only keep the request futures that are in flight by not storing all futures in a list and not keeping reference through
CompletableFutureUtils.forwardExceptionTo
Testing
Existing tests passed.
Tested on EC2 instance to upload a large directory and verified memory usage.
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License