Skip to content

Synchronizing small files = very slow #7072

Closed

Description

Expected behaviour

Files sync at about the speed of the broadband connection, independent of size unless limited by CPU or IO on client or server.

Actual behaviour

Synchronizing a folder with many small files is terribly slow. For instance a test folder with 10k 3-byte-files synchronizes with a speed of about 1 file per second over a broadband connection. The load on both client and server while doing this is negligible. Tested with server running Ubuntu 12.04 with current owncloud 6.0.1-1, client current Linux or Macos clients. The transfer rates on the broadband connection are very low as well, so this is not the bottleneck.

Steps to reproduce

  1. Download http://xn--grgen-jua.name/owncloudStressTest.tar.bz2
  2. unpack it into an owncloud folder that syncs with a remote owncloud machine.
  3. Observe upload speeds of one to a few 3-byte-files per second.

Server configuration

Operating system: Ubuntu 12.04

Web server: lighttpd

Database: mysql

PHP version: PHP 5.3.10-1ubuntu3.9

ownCloud version: 6.0.1-1

Updated from an older ownCloud or fresh install: Updated from ownCloud 5

The content of config/config.php:
$CONFIG = array ( 'instanceid' => 'removed', 'passwordsalt' => 'removed', 'datadirectory' => '/var/www/owncloud/data', 'dbtype' => 'mysql', 'version' => '6.0.0.16', 'dbname' => 'dropbox', 'dbhost' => 'localhost', 'dbtableprefix' => 'removed', 'dbuser' => 'removed', 'dbpassword' => 'removed', 'installed' => true, 'theme' => '', 'maintenance' => false, );

no external storage used.

Log files do not show error messages or warnings that seem related.

Client configuration

Both MacosX and Ubuntu 13.10 running current owncloud versions are affected. Browser was not used.

Why I think this is an issue

I regularly sync folders with several thousands of files. I think I am not the only one.

What I think is the reason

I am guessing that owncloud does at least one if not several http requests per file sent. It works sequentially, so the next file can only be sent when the last file is acknowledged. Therefore while preparing the request takes no time and effort, and storing the file does not either, the network delay comes into play: For each file to be sent you have to wait at least one if not several round-trip times.

Another indication is that syncing the folder on the local network or between two VMs on the same machine is much faster. This emphasizes the network delay being of importance in this scenario.

How I think it could be circumvented

Sync not file-by-file but instead several files per request, at least if the files are small.

Activity

  1. IngLP commented on Feb 4, 2014

    @IngLP

    Or, sync with multiple threads and split the work. Much more easy.
    Only one thread search for the files to sync, splits the list of files to be uploaded, and starts the threads.

  2. PVince81 commented on Feb 4, 2014

    @PVince81
    Contributor

    @dragotin did you guys have plans looking into uploading multiple files through the same connection ?

  3. PVince81 commented on Feb 4, 2014

    @PVince81
    Contributor

    Just had a try locally, using "localhost" and the sync client is able to upload many files within a second:
    stresstest

    I can imagine that each connection might take more time over the internet, also if it includes name resolution.

    Have you tried directly with the IP address to rule out the name resolution case ?

  4. PVince81 commented on Feb 4, 2014

    @PVince81
    Contributor

    It still feels a bit slow, this is about 41 M which I'd expect to be uploaded much faster.
    The problem also is that it might wait for the server to finish creating/saving/indexing the file before continuing, as the server won't give an answer until that happened.

  5. PVince81 commented on Feb 4, 2014

    @PVince81
    Contributor

    I tried with the tar file without compression (bunzip2) which is 11Mb big, it took less than a second to upload. I'd almost think that before uploading many files those could be tar'ed together, uploaded then untarred on the server...

  6. PVince81 commented on Feb 4, 2014

    @PVince81
    Contributor

    @gluap hmm right. I was actually looking at the progress bar and saw the file name changing 3-4 times within a second and thought the log would reflect that.

  7. enoch85 commented on Feb 4, 2014

    @enoch85

    Dont know if it helps you guys, but theese are my results.

    100/10 Mbit/s Server
    100/10 Mbit Client.

    oc

    oc2

  8. jcfischer commented on Feb 4, 2014

    @jcfischer
    Contributor

    We are in the same boat (and have filed #6937 ). I have traced the application with New Relic and I see hundreds of SELECTs for every file uploaded - that slows the processing down considerably.

  9. 135 remaining items

  10. mgscreativa commented on Mar 30, 2016

    @mgscreativa

    hi @divinity76!, Where should I add that exactly?

    By the way, I have tested in three scenarios, one VM installed with https://github.com/enoch85/ownCloud-VM/blob/master/production/owncloud_install_production.sh, a second VM using a fresh Ubuntu Server 14.04.4 installing ISPConfig and a third scenario using a owncloud docker image, in all of them, the file syncing goes just fine, the only slow thing is my real LAN server.

    I really don't know what can be causing the slowness, but I really don't care now, because I know that is my server, will waith till Ubuntu Server 16.04 releases so I can test in that new version...

  11. divinity76 commented on Mar 30, 2016

    @divinity76

    do i look like an ownCloud Client dev? :p or to say it another way, i don't know, but my best guess is
    client/src/libsync/abstractnetworkjob.cpp in void AbstractNetworkJob::setupConnections

  12. guruz commented on Mar 30, 2016

    @guruz
    Contributor
  13. mgscreativa commented on Mar 30, 2016

    @mgscreativa

    Nope...installed Revisión Git 173056 en Mar 30 2016 but the slowness persists. I really don't care now, because I was able to check that is an issue on my 2 years old server installation, maybe in that time, I setup something that causes the pauses for security. Anyway, will wait to Ubuntu Server 16.04 release an try again. Will let you know then.

  14. divinity76 commented on Mar 31, 2016

    @divinity76

    @ghiama why do you think this is an OS issue?

  15. mgscreativa commented on Mar 31, 2016

    @mgscreativa

    Hi @divinity76.

    I think of it because the test I've made, in three different VM scenarios, using my Laptop connected to my WiFi LAN the stress test files sync is really quick, but testing to my real LAN server, the stress test files sync take a very long time to sync compared to the other scenarios.

    As you can see on my previous posts here, you can check my server specs and realize that is solid rock, but still OC is slow, so, in my opinion, maybe there's something I installed on my server on this two years run that maybe, got this slowness with OC, maybe it's a security measure, because the files sync very fast, but by batches of three.

    Thanks in you interest.

  16. adrianvg commented on Apr 7, 2016

    @adrianvg

    @guruz;
    Are there any nightly builds for CentOS 7 available as well?
    I took the (maybe premature) step to move my local homefolder to Owncloud to get a sort of poor-mans-backup solution, and am now seeing very slow update checks.

  17. adrianvg commented on Apr 7, 2016

    @adrianvg

    I must be going blind...
    Thanks @dragotin !

  18. mSys-mislav commented on Jun 15, 2016

    @mSys-mislav

    Why is this closed if it's not fixed? There is still issue with small file uploading - even on 9.0.2. - as mentioned above, bigger file upload is not the problem, but small file upload.

    I've tried to upload through my linux network drive, mapping the same in windows machine, WinSCP - it's slow, very slow. There are no errors in logs, just slow speed - in bytes!!!

    I've created few hundred of files of size in range of 10-1000kB and always the same problem. I've also tried setting as suggested "innodb_flush_log_at_trx_commit = 2" but that didn't help. We also changed disks, also no luck.

    Any idea how to proceed? It's making a huge problem for us/clients.

  19. PVince81 commented on Jun 15, 2016

    @PVince81
    Contributor

    @mislav-eu it's likely closed because the slowness is on a case by case basis. For one person it can be environment issue A. For another it's environment issue B. For some people and environments it's not a problem at all.

    In your case need to find out what environment you are using so best would be to make a new report using the issue template: https://raw.githubusercontent.com/owncloud/core/master/issue_template.md

    I assume that you already checked https://owncloud.org/support/ or the forums for known environment issues that would cause upload slowness ?

  20. mSys-mislav commented on Jun 15, 2016

    @mSys-mislav
  21. PVince81 commented on Jun 15, 2016

    @PVince81
    Contributor

    During the upload of small files there is no chunking involved, so no chunk assembly.

    This means that in most cases the file is directly streaming by Apache to PHP and PHP passes it to the ownCloud code which stream-copies it into a part file. Then the part file gets renamed to the final file. So the part where the bytes are copied should be optimal.
    Now if there's encryption in the middle it can be a little slower because the stream copy also encrypts every block.

    So the slowness could be due to the stream copying from the web server to PHP being slow. Some web servers even create a temporary file before streaming the file to ownCloud (seen it happening with some nginx settings).

    Then the other part which could be slow is setting up the network connection and later on PHP setting up its internal filesystem, but this happens before the stream copy. So the question is whether the transfer speed values are based on the stream copy part or whether they look lower (averaged?) because the start of the transfer was slower.

    Also to check if whether the target folder is a received shared folder, and whether that one was reshared. If the target folder is on external storage, it will likely be much slower due to the extra upload to the external storage.

  22. mSys-mislav commented on Jun 15, 2016

    @mSys-mislav

    Dear @PVince81 - I will create separated report for this. #25115

  23. PVince81 commented on Jun 15, 2016

    @PVince81
    Contributor

    @mislav-eu thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions