timothy_k has asked for the wisdom of the Perl Monks concerning the following question:

Perl NET::FTP upload took around 50% or twice longer than via DOS prompt ftp
Hi,

I tried with the simple perl script to upload 3mb file to the FTP server in the cloud, and noticed it took almost twice longer than manual On the same PC WinXP, network, Server, ... everything, the different is using Perl script (NET::FTP) and DOS Prompt 'ftp ftp.server.com' follow username and password then put a 3mb file (upload).
I got Wireshark to capture in both scenarios one at a time, NET::FTP and Dos Prompt. Noticed that using NET::FTP client mostly upload 5-6 packets of 1314 bytes at a time then almost a 600-800 milliseconds later FTP server responds, then another 5-6 packets upload and another almost 600-800 milliseconds from Server and so on till end of file.
With Dos Prompt, I see, client upload 2 packets of 1314 bytes at a time and FTP server responds in less than 100-200 milliseconds then upload 2 packets again then FTP server responds withing 100 millisec again.
Maybe same FTP server would better and faster process or take 2 packets a time? Can we modify NET::FTP or ftp.pm to set upload less packets at a time?
Anyhelp would be very appreciated.
==============
use Net::FTP; $ftp = Net::FTP->new("some.host.name", Debug => 0) or die "Cannot conn +ect to some.host.name: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->m +essage; $ftp->cwd("/pub") or die "Cannot change working directory ", $ftp->mes +sage; $ftp->put ("that.file") 13. or die "get failed ", $ftp->message; $ftp->quit;
----
I try to read the ftp.pm but no clue whether on how, if can be changed, and what value of buff or lenght to be changed
This is an issue of (Net::FTP) I guess people using Net::FTP mainly not concern about thruput.

Replies are listed 'Best First'.
Re: Net::FTP Upload much slower than Dos prompt command ftp
by marto (Cardinal) on Jan 12, 2011 at 13:19 UTC

    Try altering the Blocksize to 4k (4096): see this for details.

Re: Net::FTP Upload much slower than Dos prompt command ftp
by Anonyrnous Monk (Hermit) on Jan 12, 2011 at 13:20 UTC

    Try adjusting the BlockSize parameter:

    $ftp = Net::FTP->new($host, BlockSize => ... );
Re: Net::FTP Upload much slower than Dos prompt command ftp
by Khen1950fx (Canon) on Jan 12, 2011 at 15:18 UTC
    I'd recommend Net::FTP::Throttle. What's most interesting for me is the way it enables you to experiment with different bandwidths. The documentation gives a starting bandwidth example of a MegabitsPerSecond => 2. I experimented and took it up to 6. It works for me, and it's superfast.
    #!/usr/bin/perl use strict; use warnings; use Net::FTP::Throttle; use constant HOST => 'ftp.cpan.org'; use constant DIR => '/pub/CPAN'; use constant FILE => 'README'; my $ftp = Net::FTP::Throttle->new( HOST, Debug => 1, Passive => 1, Timeout => 1, Bytes_read => 8192, BlockSize => 8192, MegabitsPerSecond => 6) or die "Couldn't connect: $@\n"; $ftp->login('anonymous'); $ftp->cwd(DIR); $ftp->binary; $ftp->get(FILE); $ftp->quit;
    Also, you adjust Bytes_read and BlockSize to meet your needs.

        Thanks Marto, Monk, and Khen,

        I will try your suggestion tomorrow.

        The problem / slow thruput only when Uploading to FTP server, when download from server to local PC using Net::FTP no problem, the thruput of download same and closely same as DOS prompt command.

        It's interesting that NET::FTP introduces thruput problem in upload.