-
Notifications
You must be signed in to change notification settings - Fork 913
Create design doc for cross-region S3 client #3937
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
**Design:** New Feature, **Status:** [In Development](../README.md) | ||
|
||
# Cross-Region S3 Client Design | ||
|
||
## Overview | ||
|
||
The [cross-region S3 client](https://github.com/aws/aws-sdk-java-v2/issues/52) is a feature supported in the AWS SDK for Java 1.x that automatically routes requests to the correct bucket region. This is useful for customers who do not know the region of the bucket beforehand. Without this support, customers would need to write their own logic to retrieve the region of a specific bucket for each request and redirect the request accordingly, which could be complex and error prone. This documentation proposes the design to implement it in the AWS SDK for Java 2.x. | ||
|
||
## Specification | ||
|
||
The SDK 2.x will support this feature in the S3 sync client, S3 async client and the AWS-CRT based S3 client. | ||
|
||
### Usage Examples | ||
|
||
#### Example 1: enabling cross-region access in the S3 sync client | ||
|
||
``` | ||
S3ClientBuilder s3ClientBuilder = S3Client.builder() | ||
.crossRegionAcccessEnabled(true) | ||
.build(); | ||
``` | ||
|
||
#### Example 2: enabling cross-region access in the S3 async client | ||
|
||
``` | ||
// Java S3 async client | ||
S3AsyncClient s3Client = S3AsyncClient.builder() | ||
.crossRegionAcccessEnabled(true) | ||
.build(); | ||
|
||
// AWS CRT-based S3 async client | ||
S3AsyncClient s3CrtClient = S3AsyncClient.crtBuilder() | ||
.crossRegionAcccessEnabled(true) | ||
.build(); | ||
``` | ||
|
||
### Client Configuration | ||
|
||
Users can enable this feature through a client configuration on the client builder, `crossRegionAccessEnabled`. It is default to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small typo: |
||
|
||
### Implementation Notes | ||
|
||
The region retrieval and redirect logic is implemented in a customized `S3EndPointProvider`. If `crossRegionAccessEnabled` is true, the SDK will add this customized endpoint provider to the client, which will first attempt to retrieve the region of the bucket by sending a HeadObject request and then configure the region for that request. It uses an [LRU cache](https://github.com/aws/aws-sdk-java-v2/blob/master/utils/src/main/java/software/amazon/awssdk/utils/cache/lru/LruCache.java) to bypass HeadObject API call for frequently used buckets and access points for performance optimization. | ||
|
||
## Alternatives Considered | ||
|
||
The alternative is to create a standalone S3 client that maintains a pool of S3 client instances configured with different regions. This approach is not recommended because 1) using multiple S3 clients means more resources will be used, which could confuse users 2) the implementation is more complex. | ||
|
||
## Appendix: Java SDK v1 customer experience | ||
|
||
``` | ||
AmazonS3ClientBuilder.standard() | ||
.withRegion(region) | ||
.withForceGlobalBucketAccessEnabled(enableGlobalBucketAccess) | ||
.build(); | ||
``` | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.
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
crossRegionAcccessEnabled
API will be made available to only "S3Client.builder" and not toAwsClientBuilder
, right ? since it will make it available for all the clients even if its not supported.Thus we might need to add Customization for S3 only to show this API.
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.
Yes, alternatively, we could consider adding it to
S3Configuration
, I don't have strong opinions. We still need to addcrossRegionAcccessEnabled
to the top level S3CrtAsyncClient builder though.