client icon indicating copy to clipboard operation
client copied to clipboard

PUT of large files via oc-client inefficient with standard chunksize in fast networks

Open kiu-ball opened this issue 10 years ago • 48 comments

Expected behaviour

ownCloud desktop client performs well while uploading large files in a fast network. (~100MB/s)

Actual behaviour

ownCloud desktop client performs bad while producing a high server load with standard parameters (~10-20MB/s) If you set the chunksize to a higher value the transfrerate raises while the server load drops. (~90-100MB/s)

Steps to reproduce

  1. Take a large File (>1GB) in a fast network environment (>1GBit)
  2. Upload it to your oC with oc-client using standard chunksize
  3. Watch transferrate and server load
  4. Set the chunksize to a higher value (export OWNCLOUD_CHUNK_SIZE=51248800 for example) and repeat step 2 and 3

Server configuration

Operating system: openSUSE 13.1 (Bottle) (x86_64)

Web server: Apache/2.4.16

Database: PostgreSQL 9.4.5

PHP version: 5.6.9

ownCloud version: 8.2.2

Storage backend: NFS

Client configuration

Client version: 2.1.0 (build 2944)

Operating system: OS X 10.10.5

OS language: German

Installation path of client: /Applications/owncloud.app

kiu-ball avatar Jan 13 '16 15:01 kiu-ball

cc @dragotin

MorrisJobke avatar Jan 13 '16 16:01 MorrisJobke

Comment by @DeepDiver1975:

from my pov the client could learn the chunk size depending on the network quality.

MorrisJobke avatar Jan 13 '16 16:01 MorrisJobke

Thank you for providing these performance test results. It would make sense to have the chunk size dynamic, or configurable from an admin side

felixboehm avatar Jan 13 '16 16:01 felixboehm

or configurable from an admin side

a config value will not help - in case of having the client running on a laptop living in different networks it will be a nightmare to change the setting over and over again.

this has to be an adaptive value depending on the network quality

DeepDiver1975 avatar Jan 13 '16 16:01 DeepDiver1975

Perhaps the best way to calculate what the chunk size should be involves starting at the default 5MB and measuring how long it takes to transfer chunks and how long it takes to start sending a new chunk. When that ratio gets close it indicates that the existing chunk size could probably be bigger, so increment a step, observe, [in|de]crement a step, observe, and so on. I'd guess the observation period would be based on number of chunks, not amount of time. Perhaps watch the first 6 chunks to get a starting avg then step up by XMB based on the ratio (closer indicates capacity to take a bigger step), watch the next 6, and so on.

How would the server handle chunks of variable size? Would it even have to worry?

scolebrook avatar Jan 13 '16 16:01 scolebrook

The server can handle dynamic chunk sizes.

DeepDiver1975 avatar Jan 13 '16 18:01 DeepDiver1975

I did this process manually for syncing from a VM to our servers with a 10gbit link between them. One thing to note is I found that after a certain point there was increased processing time server side so that increasing chunk size resulted in an ever increasing gap before the the process is complete and the client can start sending the next chunk. This is likely due to our storage being an SMB mount and the time it takes to do all the transfers. We ended up settling on 50MB chunks. It would probably be wise to have a ceiling on the variable chunk size to avoid a runaway condition in the calculation.

scolebrook avatar Jan 13 '16 18:01 scolebrook

@DeepDiver1975 does the NFS storage backend used here have any influence?

dragotin avatar Jan 13 '16 18:01 dragotin

I did suggest something similar to @DeepDiver1975, but probably in a wrong thread: https://github.com/owncloud/core/issues/9832#issuecomment-166577967 Here is what i suggested "could it be an idea for the sync client to somehow use an adaptive chunk size (based on different feedback such as network speed, delay, how fast the acks are coming back etc) if it could increase the throughput of syncing bigger files. "

fossxplorer avatar Jan 13 '16 19:01 fossxplorer

Would a general usage of bigger chunks have any disadvantages?

@scolebrook That's interesting. 50MB was also my best performing chunk size.

kiu-ball avatar Jan 13 '16 21:01 kiu-ball

@DeepDiver1975 does the NFS storage backend used here have any influence?

Chunks are stored within the data folder - in a clustered setup the data folder has to be a shared resource among the web servers. So - yes - the shared file system has an influence on chunked upload but should not be of any greater value.

One thing to remark about the current chunked implementation on the server side: Chunks are fully read into memory before they are written to disk - same on assembly. As a result a bigger chunk size leads to latencies due to more data being loaded to RAM and causes higher RAM consumption on the server as well.

These issue have been addressed with the new chunking implementation.

DeepDiver1975 avatar Jan 14 '16 07:01 DeepDiver1975

@DeepDiver1975 Chunks are fully read into memory before they are written to disk

Really? Not in my case as it seems. I can live watch the chunks growing in my php upload temp directory until they reach the full chunk size. Then they are moved away to the users cache folder I think.

Every 0,1s: ls -l Thu Jan 14 10:05:53 2016

total 70877 -rw------- 1 wwwrun www 51248800 Jan 14 10:05 phpMbPkz6 -rw------- 1 wwwrun www 14434304 Jan 14 10:05 phpSV5YuC -rw------- 1 wwwrun www 40624128 Jan 14 10:05 phptR8XOA

kiu-ball avatar Jan 14 '16 09:01 kiu-ball

Then they are moved away to the users cache folder I think.

yes - and this is the operation which reads them fully into RAM

DeepDiver1975 avatar Jan 14 '16 09:01 DeepDiver1975

I don't know the internals but in my setup I can verify this behavior:

5MB chunks -> throughput ~13MB/s -> server CPU load ~50% -> server RAM consumption ~470MB 50MB chunks -> throughput ~80MB/s -> server CPU load ~25% -> server RAM consumption ~470MB

kiu-ball avatar Jan 14 '16 10:01 kiu-ball

You are right - it's only on assembly where the full chunk is loaded to ram :see_no_evil:

DeepDiver1975 avatar Jan 14 '16 10:01 DeepDiver1975

while producing a high server load

The high server load is possibly a server bug. Not sure why it would occur like that, maybe too much per-chunk overhead? Or: I've seen in other issues the theory that the latency and load increases based on the number of chunks (maybe even O(n*n)) so that could be something for the server guys to look into..

this has to be an adaptive value depending on the network quality

Yep. Similar: https://github.com/owncloud/client/issues/3382

guruz avatar Jan 14 '16 12:01 guruz

Maybe https://github.com/owncloud/core/blob/c5a200c4198de951dabdd3f783ade655b8ea6434/lib/private/filechunking.php#L80 is expensive?

guruz avatar Jan 14 '16 12:01 guruz

We do not want to increase the default chunk size because that is very bad for slow networks. Not that many people have such high bandwith.

A good solution would be to adopt the chunk size according to the current network speed. As the chunk size has to be constant during the chunked upload of one file, we can only change it for the next file.

So what we suggest: During the upload of the chunks of a certain file we measure the time that takes. If a good percentage of the chunks for the file upload faster than in a certain time span, we increase the base value for the chunk size. For the upload of the next file, we use that adopted chunk size.

In addition to that, we make the chunk size a value that can be set in the config file. That way, deployments can adopt the base value depending on their site network.

@felixboehm fyi

dragotin avatar Jan 14 '16 12:01 dragotin

I'll temporarily change this to 2.1.1: We want the config setting in 2.1.1, the dynamic scaling in 2.2

guruz avatar Jan 14 '16 12:01 guruz

@DeepDiver1975 its unfortunate that the new chunking can also not handle changing chunk sizes during the upload. We should rethink that for the new chunking.

dragotin avatar Jan 14 '16 12:01 dragotin