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

gcp,s3,azure: make the storage client upload chunk size configurable #80668

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/cloud/amazon/s3_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ func newClient(
sess.Config.Region = aws.String(region)

c := s3.New(sess)
u := s3manager.NewUploader(sess)
u := s3manager.NewUploader(sess, func(uploader *s3manager.Uploader) {
uploader.PartSize = cloud.WriteChunkSize.Get(&settings.SV)
})
return s3Client{client: c, uploader: u}, region, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/azure/azure_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (s *azureStorage) Writer(ctx context.Context, basename string) (io.WriteClo
defer sp.Finish()
_, err := azblob.UploadStreamToBlockBlob(
ctx, r, blob, azblob.UploadStreamToBlockBlobOptions{
BufferSize: 4 << 20,
BufferSize: int(cloud.WriteChunkSize.Get(&s.settings.SV)),
},
)
return err
Expand Down
9 changes: 9 additions & 0 deletions pkg/cloud/cloud_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ var httpCustomCA = settings.RegisterStringSetting(
"",
).WithPublic()

// WriteChunkSize is used to control the size of each chunk that is buffered and
// uploaded by the cloud storage client.
var WriteChunkSize = settings.RegisterByteSizeSetting(
settings.TenantWritable,
"cloudstorage.write_chunk.size",
"controls the size of each file chunk uploaded by the cloud storage client",
8<<20,
)

// HTTPRetryOptions defines the tunable settings which control the retry of HTTP
// operations.
var HTTPRetryOptions = retry.Options{
Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/gcp/gcs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (g *gcsStorage) Writer(ctx context.Context, basename string) (io.WriteClose
path.Join(g.prefix, basename))})

w := g.bucket.Object(path.Join(g.prefix, basename)).NewWriter(ctx)
w.ChunkSize = int(cloud.WriteChunkSize.Get(&g.settings.SV))
if !gcsChunkingEnabled.Get(&g.settings.SV) {
w.ChunkSize = 0
}
Expand Down