core icon indicating copy to clipboard operation
core copied to clipboard

OC_FileChunking on external file systems

Open DeepDiver1975 opened this issue 13 years ago • 57 comments

The current implementation of OC_FileChunking is storing the chunks in the servers file cache (hidden/private folder on the server).

After all chunks have been received the file is reassembled and moved to the final target location.

While this approach seems valid for local filesystems this can case issues with respect to external filesystems and big files, because the final move of assembled file will consume some time.

From the overall system behavior it might be interesting to move the chunks already to the external filesystem.

My suggestion would be to store the chunks already in the target file but name it differently, append the .part and even make it hidden if possible.

This approach would speedup the process on the local filesystem as there is no reassembly step which as of today adds additional execution time.

@karlitschek @bartv2 @icewind1991 @danimo @dragotin Please add your comments - THX

DeepDiver1975 avatar Sep 26 '13 09:09 DeepDiver1975

:+1: as mentioned in bug #2947 already which was killed by a close-bugs-no-matter-what wave unfortunately ;-)

dragotin avatar Sep 26 '13 11:09 dragotin

This is a good idea, we only need to add an offset header to know where in the file to write the chunk. This way the order of chunks is not important

bartv2 avatar Oct 04 '13 10:10 bartv2

This is a good idea, we only need to add an offset header to know where in the file to write the chunk. This way the order of chunks is not important

we could use the http range header for this

DeepDiver1975 avatar Oct 16 '13 20:10 DeepDiver1975

@karlitschek oc7 I guess :wink:

DeepDiver1975 avatar Oct 16 '13 20:10 DeepDiver1975

Assembling the chunks on the external file system will be a problem though most backends don't support partial writes or appends, the only reliable way to append two uploaded chunks on an external file system would be to download both chunks and upload the result.

icewind1991 avatar Oct 16 '13 21:10 icewind1991

In such a scenario we need to stick with the approach we have today.

What about moving this to the storage api and let the storage implementation handle this? 

DeepDiver1975 avatar Oct 16 '13 23:10 DeepDiver1975

Yes. ownCloud 7

karlitschek avatar Oct 17 '13 06:10 karlitschek

Moving it to the storage API might help but I only know of one backend (ftp) that might be able to provide a better then default implementation. so I don't think it will help much in the end.

icewind1991 avatar Oct 17 '13 08:10 icewind1991

it will help with irods as well - not the most common storage but still ..... :wink:

DeepDiver1975 avatar Oct 17 '13 09:10 DeepDiver1975

Any more ideas on this ? After reading the thread that raises some relevant issues about the proposed approaches, I can't think of any other at the moment.

PVince81 avatar May 02 '14 16:05 PVince81

I heard that 1.6.0 has configurable chunk sizes. If we can increase the chunk size to reach the max upload size, it might help when uploading files to ext storage as a single chunk, at least for bigger files. This way the sysadmin, if they wish so, could manually increase the max upload size to bigger values to match the kind of file sizes expected in their environment.

PVince81 avatar May 02 '14 16:05 PVince81

@PVince81 remember that we also introduced the chunking to not get hit by the request timeout.

dragotin avatar May 05 '14 07:05 dragotin

I heard that 1.6.0 has configurable chunk sizes.

We might want to update the protocol in this case - I can think scenarios where the chunk size can become an necessary information on the server. As of today the chunk size is not communicated.

@dragotin another topic for Wednesday?

DeepDiver1975 avatar May 05 '14 07:05 DeepDiver1975

Yes, but I do not really see a big benefit in changing/configuring the chunk size.

dragotin avatar May 05 '14 08:05 dragotin

This is part of a larger conversation to be had around external storage. For example, if you upload a file once to the server in chunks and reassemble, and then put it to a backend server...you are uploading twice: once to the ownCloud server, once to the backend.

This is part of a larger oC 8 concept we need to look at that allows direct access where possible, streaming if the backend supports it, and then this as a last effort - as performance is slowest here.

MTRichards avatar Sep 02 '14 15:09 MTRichards

This is not an Enhancement, but a bug, the mirall issue tracker is full of bug reports about timed out uploads of big files (Example https://github.com/owncloud/mirall/issues/2074). Please re-tag to bug.

Solution proposal is https://github.com/owncloud/core/issues/12097

dragotin avatar Nov 11 '14 09:11 dragotin

@dragotin do you face these timeouts only on external storage or on local storage as well?

DeepDiver1975 avatar Nov 11 '14 10:11 DeepDiver1975

also on local storage. Its a matrix of computer speed and load and size of the file to process and timeout value, so it will always simply be possible to time out.

dragotin avatar Nov 11 '14 10:11 dragotin

okay - we can for now at least get rid of the reassembly step ... I'll take care of that - NOW

DeepDiver1975 avatar Nov 11 '14 10:11 DeepDiver1975

@DeepDiver1975 if I understand well, will you store the part file directly on the external storage, and use fseek() to fill in the chunk gaps ?

Note that fseek() doesn't work on most external storages.

The other approach, simply putting the chunks onto the external storage server will be even slower because the workflow would be as follows:

  1. Upload chunk1 to SMB
  2. Upload chunk2 to SMB
  3. ...
  4. Upload chunk N to SMB
  5. Read chunk 1 ... N from SMB and at the same time write the part file to SMB
  6. Rename part file on SMB to the final file name.

Putting the chunks directly with this methods adds an additional overhead for each chunk, and also the additional overhead of having the re-download the chunks from SMB for assembly.

PVince81 avatar Nov 11 '14 11:11 PVince81