Subject: Re: SFTP read buffer size

Re: SFTP read buffer size

From: Tamar Sery (BLOOMBERG/ 120 PARK) <>
Date: Thu, 3 Sep 2020 19:00:45 -0000

Thank you!
Increasing the buffer size to 200 - 300K helped reduce the download time. I didn't consider using such a large buffer before you suggested it.
While using a 80K buffer, downloading files 10M and larger took the program over 20-30 sec at times, but with this change it rarely takes over 10 sec.

From: At: 08/26/20 18:38:22To: Tamar Sery (BLOOMBERG/ 120 PARK ) ,
Subject: Re: SFTP read buffer size

On Wed, 26 Aug 2020, Tamar Sery (BLOOMBERG/ 120 PARK) wrote:

> I'm trying to increase the download speed of files using libssh2_sftp_read .
> I was able to see considerable speed increase by using a larger buffer, up
> to 30000. However, any size over 30000 seem to have no affect on actual
> received packet size, all packets are exactly 30000 (except for the last
> chunk of the file, and an occasional 60000 sized packet). Is there a way to
> increase the download speed, using a larger buffer or otherwise?

You don't increase speed by getting larger packet sizes here, as SFTP has a
restriction on the packet size. But if you provide a large buffer to the read
function, libssh2 can do the read in multiple packets so you'll be able to get
more packets back in less time.

In my testing, years ago, I could easily get increased transfer speeds by
increasing the buffer up to well over 100K. This is of course extra noticable
when working with high-RTT high-bandwidth servers.


Received on 2020-09-03