Bug #63937 [Com]: Upload speed 10 times slower with PHP

From: Date: Thu, 20 May 2021 10:48:05 +0000
Subject: Bug #63937 [Com]: Upload speed 10 times slower with PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233909@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63937&edit=1

 ID:                 63937
 Comment by:         sudoma at seznam dot cz
 Reported by:        levi_tedder at hotmail dot com
 Summary:            Upload speed 10 times slower with PHP
 Status:             Verified
 Type:               Bug
 Package:            FTP related
 Operating System:   Windows
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Workaround found:

Under php 7.4.19 problem persists.

However, under the very same version and build of php,
 where php function ftp_put() has unsatisfactory performance of 15MBps,
calling cURL to do the same job has performance comparable to other FTP clients i.e. 80MBps.

I therefore believe, this performance regression is limited to FTP extension of PHP

code:
ftp_put($this->FTPHANDLE,$dest,$src,FTP_BINARY)

code (return values checks redacted out):

$curlhandle = curl_init()
$srcfilehandle = fopen($src,'r'))
curl_setopt($curlhandle, CURLOPT_URL, 'ftp://'.$user.':'.$pass.'@'.$url.'/'.$dest);
curl_setopt($curlhandle, CURLOPT_UPLOAD, 1);
curl_setopt($curlhandle, CURLOPT_FTP_USE_EPSV, TRUE);
curl_setopt($curlhandle, CURLOPT_TRANSFERTEXT, FALSE);
curl_setopt($curlhandle, CURLOPT_INFILE, $srcfilehandle);
curl_setopt($curlhandle, CURLOPT_INFILESIZE, filesize($src));
curl_exec($curlhandle);


Previous Comments:
------------------------------------------------------------------------
[2021-05-17 17:27:18] sudoma at seznam dot cz

Bug showed after complete upgrade (kernel, libraries, php) of our production backup-copying system.
System is connecting to FTP inside our LAN and is used to push backup video files (250+TiB in total,
daily throughput approx. 160GiB) to external backup over 1Gbit infrastructure.

Before upgrade, php ftp performance was comparable to midnight commander ftp client
 ie. approx. 80MBps-90MBps.
After upgrade php performance degraded to approx. 1/6 of mc ftp which is approx. 15MBps.

I have serious backlog of 50-60TiB which i need to push through FTP and this performance regression
showing after upgrade is real pain ...

command used in php script is ftp_push
there is no difference in enabling FTP_PASSIVE 
(problem manifests in active and passive mode)
mode used is FTP_BINARY

i have done some tests now and behavior is observed under:
php-7.4.14
php-7.2.34
php-5.6.29
php-5.5.37

i have tried to compile 
php-7.4.14 with FTP_BUFSIZE 65536 in ftp.h
however there seems to be no difference in behavior.

My guess is this may be problem of some underlying library which is being used in php and not being
used in other clients

Any help would be greatly appreciated.

------------------------------------------------------------------------
[2021-02-17 22:57:22] cmb@php.net

I can confirm that ftp_put() uploads are slow on Windows.
Increasing the FTP_BUFSIZE[1] to a value just a bit smaller than
SO_SNDBUF (64KiB on my system), shows a performance improvement of
about 30%.  However, uploading from WSL1 still takes only half the
time.  There might be room for (further) improvements on Windows,
but maybe this is just a Windows limitation.  This needs further
investigation.

Note the ftp_put() relies on select(3), so performance is
certainly not optimal on either operating system.

[1] <https://github.com/php/php-src/blob/php-7.4.15/ext/ftp/ftp.h#L38>

------------------------------------------------------------------------
[2018-03-20 01:20:32] tung12a1 at yahoo dot com

Is there any progress? I have found the same issue.

------------------------------------------------------------------------
[2017-12-04 14:34:08] luk dot krchnak at gmail dot com

Is there any progress? I have the same issue... Thanks.

------------------------------------------------------------------------
[2017-09-10 10:39:55] awlurker at yandex dot ru

The problem still exists and is very annoying.
PHP FTP upload functionality seems to be almost unusable because of this.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=63937


--
Edit this bug report at https://bugs.php.net/bug.php?id=63937&edit=1


Thread (10 messages)

« previous php.bugs (#233909) next »