Skip to content

Upload performance OC 8.2.1 (50 mysql queries per file) #20967

Closed

Description

@tflidd

Upload of many small files is very slow. I tested on a raspbery pi 2 which is known to have a bad i/o-performance. During uploads, mysql-operation create an important io-wait on the system. It was worse with journaling of ext4, so I disabled it (it's a test system).

Uploading a folder with 1180 files (18 MB) via the oc-client takes about 20-30 minutes (pictures, a lot of text files, take any php code of a project), but the number of sql-queries is extremely high (>50 queries per uploaded file!):

command number
select 49,681
update 11,523
insert select 2,487
set option 1,526
delete 511
insert 423
begin 17
commit 17

For upload, a smaller number of queries can be obtained when files are uploaded in an external folder via ftp (takes a few seconds) then this folder is included into owncloud, the scanning process takes a few minutes (it's hard to tell, 5 minutes?) and the number of queries (some queries are due to handling the web-interface):

command number
select 11,054
update 3,040
insert select 3,004
set option 425
delete 138

I remember you worked on the deletion process for OC 8.0, this scales much better: 3000 files take 3500 update and 1400 select queries. Perhaps there is a similar improvement possible for upload operations ;-)

System: RPi2, Debian Jessie
Webserver: nginx/php-fpm
Database: mariadb
Owncloud 8.2.1
Apps enabled:

  • activity: 2.1.3
  • calendar: 0.8.1
  • contacts: 0.5.0.0
  • files: 1.2.0
  • files_external: 0.3.0
  • files_pdfviewer: 0.7
  • files_sharing: 0.7.0
  • files_texteditor: 2.0
  • files_trashbin: 0.7.0
  • files_versions: 1.1.0
  • files_videoviewer: 0.1.3
  • firstrunwizard: 1.1
  • galleryplus: 14.3.0
  • provisioning_api: 0.3.0
  • templateeditor: 0.1

I haven't tested with a pure webdav-client yet.

Activity

  1. melroy89 commented on Dec 7, 2015

    @melroy89

    We have indeed a big MySQL issue here... I can confirm this.

  2. DeepDiver1975 commented on Dec 7, 2015

    @DeepDiver1975
    Contributor

    @icewind1991 @LukasReschke some more profiling? 🙊

  3. added this to the milestone on Dec 7, 2015
  4. LukasReschke commented on Dec 7, 2015

    @LukasReschke
    Contributor

    Is Redis enabled as file locking provider? If no: Pretty sure it's file locking. 🙊

  5. tflidd commented on Dec 8, 2015

    @tflidd
    ContributorAuthor

    Indeed, I used only APCu. But I can't disable filelocking, I tried 'filelocking.enabled' => 'false', that didn't work.

    So, I tried to enable file-locking using a redis-server. I installed from debian (jessie) which comes in version 2.8.17. I run more or less the standard config, except that I use the socket to connect to redis. I disabled apcu (https://www.en0ch.se/how-to-configure-redis-cache-in-ubuntu-14-04-with-owncloud/) but the admin page now complains
    No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.

    Redis seems to be used as the warning the the database is used for file-locking disappeared. Before I could see many queries for a file-locking table, but such queries disappeared as well. Unfortunately the performance got worse:

    command number
    select 114 k
    update 27,946
    set option 4,465
    insert select 1,313
    commit 133
    begin 133

    I only used the standard redis-configuration, I perhaps I need to tune some parameters to use memory more efficiently. Is this normal in the logs?

    [7522] 08 Dec 00:07:05.004 * 10 changes in 300 seconds. Saving...
    [7522] 08 Dec 00:07:05.006 * Background saving started by pid 11366
    [11366] 08 Dec 00:07:05.484 * DB saved on disk
    [11366] 08 Dec 00:07:05.487 * RDB: 0 MB of memory used by copy-on-write
    [7522] 08 Dec 00:07:05.508 * Background saving terminated with success
    [7522] 08 Dec 00:12:06.090 * 10 changes in 300 seconds. Saving...
    [7522] 08 Dec 00:12:06.091 * Background saving started by pid 11883
    [11883] 08 Dec 00:12:06.135 * DB saved on disk
    [11883] 08 Dec 00:12:06.138 * RDB: 0 MB of memory used by copy-on-write
    
  6. LukasReschke commented on Dec 8, 2015

    @LukasReschke
    Contributor

    @tflidd Would it be possible for you to install the free blackfire.io tool on your server?

    Then just upload the file in your browser, open the developer tools, go to the network console, copy the request as cURL (to upload.php) and in the command line type "blackfire curl theRestOfTheCurlCommand"

    After this sharing the trace (there is an option for public sharing) would help us a lot. (ah. And technically there is also a 15day trial for the paid version. You might try to enable that one as well as it gives more infos ;))

  7. tflidd commented on Dec 8, 2015

    @tflidd
    ContributorAuthor

    Thanks for your ideas. I will have to verify my caching-setup with the docs, it's possible that I missed something. If it doesn't improve, I will try to install blackfire.io on my RPi2.

  8. melroy89 commented on Dec 8, 2015

    @melroy89

    Why are we talking about Redis, when the problem started with MySQL database. Even so, MySQL is default.

  9. melroy89 commented on Dec 8, 2015

    @melroy89

    Well, I was using APCu with the same drawback: large amount of small files takes forever. Ps. I was using Debian 8, which has release 8.1.4. And previously I ran Apache webserver.

    I now setup Redis with memcached and Transactional File Locking enabled. I also switched to Nginx server and php-fpm. Let me check if I see any improvements or not.

  10. tflidd commented on Dec 12, 2015

    @tflidd
    ContributorAuthor

    Ok, it took a bit longer. Problem was, that blackfire.io does not work on ARM. So I installed OC 8.2.1 on a virtual machine (Debian 8 system, it is apache+mod_php instead of nginx+php-fpm). There are still a lot of SQL queries.

    Now, I run blackfire.io like @LukasReschke described (hopefully I understood correctly):

  11. 22 remaining items

  12. ghost added this to the milestone on Apr 14, 2016
  13. ghost removed this from the milestone on Apr 14, 2016
  14. jospoortvliet commented on Apr 15, 2016

    @jospoortvliet

    The fastest local memcache would be APCU, on the Pi it's a bit more complicated as APCU eats more memory (two caches instead of one). But on the VM, APCU should speed things up a little more. Only for memecache.local!

  15. modified the milestones: , on Jun 24, 2016
  16. melroy89 commented on Aug 9, 2016

    @melroy89

    Still not fixed?

  17. PVince81 commented on Aug 10, 2016

    @PVince81
    Contributor

    @Danger89 is this happening for you in a recent OC version ?
    Some queries were optimized meanwhile.

  18. PVince81 commented on Dec 8, 2016

    @PVince81
    Contributor

    @mrow4a what do you think ?

  19. mrow4a commented on Dec 8, 2016

    @mrow4a
    Contributor

    @PVince81 You mean, trying to reduce the number of inserts or optimize the query? Probably this is yet another big project. I think I could have a look and analyse this as a next project.

    However, I am big fan of what guys at CERN have with EOS.

  20. PVince81 commented on Apr 6, 2017

    @PVince81
    Contributor

    @mrow4a is already working on optimizing SQL queries on upload and other file operations for 10.0, some fixes made it in already. Please retry there.

  21. lock commented on Aug 2, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  22. locked as resolved and limited conversation to collaborators on Aug 2, 2019
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