tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
2.95k stars 467 forks source link

Enabling Clients perform parallel uploads and to upload non-contiguous chunks. #1044

Closed ducpx closed 7 months ago

ducpx commented 7 months ago

I'm using tus lib with fileserver backend. I want to have the parallel upload feature to enable clients upload chunks in parallel.

Acconut commented 7 months ago

Clients like tus-js-client support uploading chunks of a single file in parallel. Have a look at its parallelUploads option: https://github.com/tus/tus-js-client/blob/main/docs/api.md#paralleluploads

ducpx commented 7 months ago

Clients like tus-js-client support uploading chunks of a single file in parallel. Have a look at its parallelUploads option: https://github.com/tus/tus-js-client/blob/main/docs/api.md#paralleluploads

Do you know how to config server to support uploading file in parallel? I knew that if the server does not support this feature, client can not upload a file in parallel.

Acconut commented 7 months ago

tusd supports this out-of-the-box for file-based storage and S3 storage without any additional configuration necessary. It is not supported on GCS or Azure Storage yet.

ducpx commented 7 months ago

Ok thanks. Let's me try to see how it works.

vunguyen1989 commented 6 months ago

@Acconut I have added some code for uprading our tus upload from v1.9 to v2.0. in backend, using this:

tusd "github.com/tus/tusd/v2/pkg/handler"

in client, adding this to js client: arallelUploads: 5

   var defaultOptions = {
      endpoint: "",
      fingerprint: _fingerprint2.default,
      resume: true,
      onProgress: null,
      onChunkComplete: null,
      onSuccess: null,
      onError: null,
      headers: {},
      chunkSize: Infinity,
      withCredentials: false,
      uploadUrl: null,
      uploadSize: null,
      overridePatchMethod: false,
      retryDelays: null,
      parallelUploads: 5
    };

Then, try to upload a file (about 3Gb), it shows about 10 seconds slower than non-parallel uploading.

It's slower. Should we keep working with parallel uploading?

Thanks

Acconut commented 6 months ago

Parallel uploads are not guaranteed to make uploads faster as multiple requests then have to share the connection. A single HTTP request is usually able to fully utilize the available network throughput and adding more requests won't increase the available throughput. Plus, the server must concatenate the uploads together, which also takes times. In production, we also don't use parallel uploads for those exact reasons.

I recommend you to benchmark the uploads with and without parallel uploads. If you don't get a benefit from it, you should disable it.

vunguyen1989 commented 6 months ago

I got your point. Thank you