tus-php icon indicating copy to clipboard operation
tus-php copied to clipboard

Slow upload speed to server

Open sQty opened this issue 4 years ago • 11 comments

all visible here ...

139915611-eed53174-87dd-4b61-a056-d792fd712ff4

upload to uppy demo server tus ( are they using this server implementation ? dunno )

so i downloaded uppy js client and this tus php server and have similar speeds on lan upload like on uppy test server .... ( issue like https://github.com/ankitpokhrel/tus-php/issues/246 )

@@@ uppy team said https://github.com/transloadit/uppy/issues/3292 that their demo server is capable up to 2Gbit/s

so that not likely bandwidth problem....

can u check this ????

sQty avatar Nov 03 '21 06:11 sQty

Hi @sQty, If I get you right, you are getting similar upload speed on both uppy js demo server and tus-php server locally. I am pretty sure uppy demo page is not using PHP implementation in the server. So its not clear if this is an issue with tus-php since multiple server implementation is giving you same upload speed.

What is the upload speed you are expecting?

ankitpokhrel avatar Nov 07 '21 15:11 ankitpokhrel

using local uploads ( server, lan ) more that 100Mb ..... and get only up to 40Mbps .... ( upload from server browser to server disk .... lan usage 0 so all fly local .... )

sQty avatar Nov 09 '21 11:11 sQty

I will keep this issue open to see if someone else is also facing a similar issue. And can hopefully provide us with a clue to move ahead with debugging.

So far, with the information I have, I am not even sure if this is the issue with tus-php or something else (eg: server conf, network).

ankitpokhrel avatar Nov 17 '21 10:11 ankitpokhrel

Are you using PHP fpm? If so, did you try to change pm.max_children to a higher value?

darthf1 avatar Nov 22 '21 19:11 darthf1

Hello,

I am facing a similar issue. I think the source for this problem is the fact that S3 does not support seekable streams and file appends only in a very limited fashion.

So the streamWrapper implementation of the AWS S3 SDK is supporting seekable streams by fetching the whole file content from the S3 API because. I have not complelty debugged myself through the tus-php servers code but my assumption is that due to this limitation of the S3 streamWrapper there is a high bandwith overhead between the tus-server and the S3 server.

Maybe there is a possibility to cache the file contents somewhere before streaming it into S3.

leipsfur avatar Nov 23 '21 15:11 leipsfur

Slow upload issue exist also on simple Nginx server (4GB KVM VPS / NVMe drives). No matter nginx configuration, but files larger then ~10 MB tend to upload insanely slow. Specially upload start stalling. Use demo and standard Nginx on Debian or Alma 8 in order to recreate issue.

ponasromas avatar Jan 11 '22 14:01 ponasromas

Update on the problem: when file uploading without chunking, it uploads much faster.

This:

$bytesUploaded = $client->setKey($uploadKey)->file($fileMeta['tmp_name'], $file_uid . '_' . $file_prefix . '_' . $fileMeta['name'])->upload();

Vs this:

$client->setKey($uploadKey)->file($fileMeta['tmp_name'], $file_uid . '_' . $file_prefix . '_' . $fileMeta['name']);
$bytesUploaded = $client->upload(10000000); // Chunk of 10 MB

Is around 11 times faster. So yea, there is place form improvements.

ponasromas avatar Jan 19 '22 08:01 ponasromas

I am experiencing slow uploads as well, both locally and on our servers, any idea?

in /usr/local/var/log/php-fpm.log:

/usr/local/var # tail /usr/local/var/log/php-fpm.log
[15-Mar-2022 08:00:14] ERROR: failed to ptrace(ATTACH) child 35: Operation not permitted (1)
[15-Mar-2022 08:00:14] WARNING: [pool www] child 35, script '/var/www/html/basic/upload.php' (request: "POST /basic/upload.php") executing too slow (33.033399 sec), logging
[15-Mar-2022 08:00:45] ERROR: failed to ptrace(ATTACH) child 38: Operation not permitted (1)
[15-Mar-2022 08:00:45] WARNING: [pool www] child 38, script '/var/www/html/basic/upload.php' (request: "POST /basic/upload.php") executing too slow (30.917014 sec), logging
[15-Mar-2022 08:01:19] ERROR: failed to ptrace(ATTACH) child 39: Operation not permitted (1)
[15-Mar-2022 08:01:19] WARNING: [pool www] child 39, script '/var/www/html/basic/upload.php' (request: "POST /basic/upload.php") executing too slow (32.033336 sec), logging
[15-Mar-2022 08:01:52] ERROR: failed to ptrace(ATTACH) child 36: Operation not permitted (1)
[15-Mar-2022 08:01:52] WARNING: [pool www] child 36, script '/var/www/html/basic/upload.php' (request: "POST /basic/upload.php") executing too slow (32.070539 sec), logging
[15-Mar-2022 08:02:24] ERROR: failed to ptrace(ATTACH) child 37: Operation not permitted (1)
[15-Mar-2022 08:02:24] WARNING: [pool www] child 37, script '/var/www/html/basic/upload.php' (request: "POST /basic/upload.php") executing too slow (30.470423 sec), logging

tetrode avatar Mar 15 '22 08:03 tetrode

Just do not use chunked upload. That fixed the problem for me and upload goes maximum.

ponasromas avatar Mar 15 '22 08:03 ponasromas

Just do not use chunked upload. That fixed the problem for me and upload goes maximum.

in that case i am not able to resume my upload.

rajpt avatar Aug 31 '22 03:08 rajpt

What I found out is that fastcgi_request_buffering off; limits upload speed to ~2.5MB I tested that with XHR as well. Once that is removed upload is much much faster, but you lose resumable uploads so a workaround is to send files in chunks on FE, I ended up using 50MB chunk...

dokicro avatar Aug 10 '23 20:08 dokicro