in reply to Net::FTP Upload much slower than Dos prompt command ftp

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.

Replies are listed 'Best First'.
Re^2: Net::FTP Upload much slower than Dos prompt command ftp
by Anonymous Monk on Jan 12, 2011 at 15:24 UTC

      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.


        I believe the slowdown is caused by the default blocksize used (10k):

        ${*$ftp}{'net_ftp_blksize'} = abs($arg{'BlockSize'} || 10240);

        You can easily test this hypothesis by supplying a parameter BlockSize => 4096 to the constructor.

        I'd step through 1024, 2048, 4096 etc. and see what difference if any that makes to your throughput.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        Hi Khen,


        my $ftp = Net::FTP::Throttle->new(
        HOST,

        ...

        Bytes_read => 8192,

        In above Net::FTP::Throttle, is there something like

        Bytes_write => 1024 or 2048 ?

        Since the issue is uploading only.

        -- Uploading the thruput is twice slower when using NET::FTP vs. Dos Prompt command ftp ftp.server.com 'put'

        -- Downloading: the thruput when using either NET::FTP or Dos Prompt command are closely same.

        The ftp server is on the WAN (in the cloud)

        Everything the same, configuration, settings, PC, and HW. The different is NET::FTP and Dos Prompt, and the time is about 10 minutes apart between these 2 scenarios, as 3mb file Upload with Dos Prompt it took about 2-3 minutes, and with NET::FTP it took 4-5.30 minutes each time. I did over 10 times.


        <Thanks everyone for help>

        Hi Everyone,

        Thanks very much for yours input. I did try and found that adding BlockSize => 2518 (just right fit to 2 packets) and the Upload thruput of uploading 3mb now is around 82-94 sec, even better than Dos Prompt -

        By the way, ActivePerl does not have NET::FTP::Throttle

        Thanks!!!
        Remember, also, that upload speed depends on the capabilites of your host or provider. For example, a common ADSL configuration would be 1.54 Megabits per second for downloads, whereas uploads would be 640 Kilobits per second. That might explain the difference in thruput:).