Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: add --sftp-concurrency to improve high latency transfers

Nick Craig-Wood78120d40d9bd
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index ae617069d..a228dece1 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -292,6 +292,16 @@ a large file, try lowering this number.
`,
Default: 32 * fs.Kibi,
Advanced: true,
+ }, {
+ Name: "concurrency",
+ Help: `The maximum number of outstanding requests for one file
+
+This controls the maximum number of outstanding requests for one file.
+Increasing it will increase throughput on high latency links at the
+cost of using more memory.
+`,
+ Default: 64,
+ Advanced: true,
}},
}
fs.Register(fsi)
@@ -325,6 +335,7 @@ type Options struct {
DisableConcurrentWrites bool `config:"disable_concurrent_writes"`
IdleTimeout fs.Duration `config:"idle_timeout"`
ChunkSize fs.SizeSuffix `config:"chunk_size"`
+ Concurrency int `config:"concurrency"`
}
// Fs stores the interface to the remote SFTP files
@@ -503,6 +514,7 @@ func (f *Fs) newSftpClient(conn *ssh.Client, opts ...sftp.ClientOption) (*sftp.C
sftp.UseConcurrentReads(!f.opt.DisableConcurrentReads),
sftp.UseConcurrentWrites(!f.opt.DisableConcurrentWrites),
sftp.MaxPacketUnchecked(int(f.opt.ChunkSize)),
+ sftp.MaxConcurrentRequestsPerFile(f.opt.Concurrency),
)
return sftp.NewClientPipe(pr, pw, opts...)
}