SFTP transfer too slow (Java)
Posted by Mohammad Jawwad on 30 April 2010 11:48 PM
SFTP is a packet based protocol and therefore has a significant overhead due to encryption which is essential to the protocol's security. The approach suggested here is to transfer data by managing the connection buffer sizes & transfer block sizes. These factors have a direct effect on transfer rate much more so than the encryption algorithm used in the SFTP protocol.

SshParameters params = new SshParameters("[host]", "[user]", "[pass]");
int buffer = 1024*512;
Sftp sftp = new Sftp(params);
// do transfer

If you notice the send buffer size, receive buffer size, download block size, upload block size is set to 1024*512 (512 KB where 1 KB = 1024 bytes). Take this as a starting point and increase the buffer size to the point where you do not receive any additional benefit.

For example, try incrementing the buffer sizes in increments of 256 bytes :

int buffer = 1024*512;
int buffer = 1024*768;
int buffer = 1024*1024;

What you are essentially doing here is to manage these variables :

1) SSH connection send and receive buffer sizes;
2) Upload & download block sizes;

See if this improves the transfer speed.
(77 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako fusion