core icon indicating copy to clipboard operation
core copied to clipboard

Multiple file uploading and deleting is very slow

Open jerrac opened this issue 13 years ago • 97 comments

Summary

This is kinda long. To summarize, OwnCloud appears to have issues when dealing with large numbers of files. Both on upload and delete. Via both the sync client and webdav. After some testing, and reading the issue queues, I'm sure it probably has something to do with how many sql queries that have to run when uploading or deleting a file.

The slowness of uploading and deleting effectively makes OwnCloud unbearble to use.

https://github.com/owncloud/mirall/issues/331 is the issue I would normally post this to, but this is core problem. Not a mirall problem. It's also focussed on the sync client.

In the core queue, I found https://github.com/owncloud/core/issues/769 and https://github.com/owncloud/core/issues/2010 but both are Mac specific.

So I don't think I'm posting a duplicate, but I'll leave that decision up to someone else. Especially if I missed a better issue to post on when I searched...

Server/Client config

My Owncloud server is running 5.0.5 on Ubuntu 12.04 with Apache 2.2.22 and PHP 5.3.10.

My desktop is running Nautilus 3.4.2 on Ubuntu 12.04.

The Problem

When uploading a 95MB folder to OwnCloud via Nautilus, the fastest speed I saw was 600ish kB/sec. Most of the time it was under 100-150ish kB/sec. The folder had hundreds of files in it. It took at least 20 minutes to upload. All according to the Nautilus file copy dialog.

Uploading a zip of the same folder was basically instant. As was any single file upload.

Can't really tell you what kind of speeds I got with the client, but it did take just as long as with webdav.

When uploading or deleting I see the server cpu fluctuate up to 60+%.

My hardware is pretty powerful, on both client and server. So, seeing that high of a load with just one person uploading is not good.

Diagnostics

When uploading, I tailed the owncloud.log and saw a lot of messages like this:

{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827798}
{"app":"core","message":"Adding user backend instance of OC_User_Database.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OC_User_Database.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OC_User_Database.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OC_User_Database.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OC_User_Database.","level":0,"time":1366827799}
{"app":"core","message":"Adding user backend instance of OCA\\user_ldap\\USER_LDAP.","level":0,"time":1366827799}

What exactly does that mean?

My user is an LDAP user. And all my potential users will be authenticating via LDAP.

I also tried moving the database to localhost instead of hosting on my normal mysql server. Now I see mysqld rise to the top of htop while uploading and deleting.

I increased the mysql query_cache_limit to 8M and query_cache_size to 64M. I think it sped up a bit, but I'm not sure it's not just my imagination.

I also turned on the slow query log. I get the following when uploading a single file, and when uploading lots of files, (and tailing the log) the log appears to do the same for every single file in the multi upload.

# Time: 130424 12:23:00
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.004940  Lock_time: 0.000032 Rows_sent: 0  Rows_examined: 11827
SET timestamp=1366831380;
SELECT `path`, `fileid` FROM `oc_filecache` WHERE `path` LIKE 'files/Testing/titan profile.png.part/%';
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000380  Lock_time: 0.000061 Rows_sent: 0  Rows_examined: 5
SET timestamp=1366831380;
SELECT `oc_share`.`id`, `item_type`, `oc_share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`, `token`, `storage` FROM `oc_share` INNER JOIN `oc_filecache` ON `file_source` = `oc_filecache`.`fileid` AND `uid_owner` = 'USERUID' AND `share_type` != '2' AND ( `file_source` = '52767' OR `item_type` IN ('folder'));
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000297  Lock_time: 0.000044 Rows_sent: 0  Rows_examined: 5
SET timestamp=1366831380;
SELECT `oc_share`.`id`, `item_type`, `oc_share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`, `token`, `storage` FROM `oc_share` INNER JOIN `oc_filecache` ON `file_source` = `oc_filecache`.`fileid` AND `uid_owner` = 'USERUID' AND `share_type` != '2' AND ( `file_source` = '39286' OR `item_type` IN ('folder'));
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000240  Lock_time: 0.000083 Rows_sent: 0  Rows_examined: 5
SET timestamp=1366831380;
SELECT `oc_share`.`id`, `item_type`, `item_source`, `item_target`,
                            `oc_share`.`parent`, `share_type`, `share_with`, `uid_owner`,
                            `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage` FROM `oc_share` INNER JOIN `oc_filecache` ON `file_source` = `oc_filecache`.`fileid` WHERE `file_target` IS NOT NULL AND `share_type` IN ('0','1','2') AND `share_with` IN ('USERUID') AND `uid_owner` != 'USERUID';

I get the same behavior uploading from a Windows XP VirtualBox VM.

I haven't tried myself, but others in my department have reported the Mac OSX is slow. Like in the issues I linked to earlier.

Deleting the uploaded folder is just as slow as uploading.

Same with the sync client.

While deleting, the slow query log shows a lot of queries like these:

# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000172  Lock_time: 0.000059 Rows_sent: 0  Rows_examined: 5
SET timestamp=1366837346;
SELECT `oc_share`.`id`, `item_type`, `oc_share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`, `token`, `storage` FROM `oc_share` INNER JOIN `oc_filecache` ON `file_source` = `oc_filecache`.`fileid` AND `uid_owner` = 'USERUID' AND `share_type` != '2' AND ( `file_source` = '55519' OR `item_type` IN ('folder'));
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000091  Lock_time: 0.000035 Rows_sent: 1  Rows_examined: 3
SET timestamp=1366837346;
SELECT `size` FROM `oc_files_trashsize` WHERE `user`='USERUID';
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.002972  Lock_time: 0.000027 Rows_sent: 4906  Rows_examined: 4911
SET timestamp=1366837346;
SELECT `location`,`type`,`id`,`timestamp` FROM `oc_files_trash` WHERE `user`='USERUID';
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000158  Lock_time: 0.000057 Rows_sent: 0  Rows_examined: 3
SET timestamp=1366837346;
UPDATE `oc_files_trashsize` SET `size`='976451849' WHERE `user`='USERUID';
# User@Host: testfilehost[testfilehost] @ localhost []
# Query_time: 0.000204  Lock_time: 0.000069 Rows_sent: 0  Rows_examined: 5
SET timestamp=1366837346;
SELECT `oc_share`.`id`, `item_type`, `item_source`, `item_target`,
                            `oc_share`.`parent`, `share_type`, `share_with`, `uid_owner`,
                            `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage` FROM `oc_share` INNER JOIN `oc_filecache` ON `file_source` = `oc_filecache`.`fileid` WHERE `file_target` IS NOT NULL AND `share_type` IN ('0','1','2') AND `share_with` IN ('USERUID') AND `uid_owner` != 'USERUID';

I tried increasing my php memory to 256M and saw no difference.

My last test before posting this was to try connecting to my local install on my desktop. No network, on an SSD, 8 core cpu, 16GB of RAM, no https. Still slow. It might be faster than over the network, but not enough for me to notice... OwnCloud was running code from the master branch, as of yesterday sometime. Not 5.0.5.

Ending Thoughts

Am I right in blaming the sql queries for this? Are there some other server settings I could try?

From what I can tell, the issue is that there is a LOT of overhead to uploading or deleting a file. Thus, when you need to do that more than a couple times, it's slow. How can the overhead be reduced?

Are there some better ways I can test this than just uploading a random folder with a few thousand files in it? Ways that would provide more useful data?

jerrac avatar Apr 24 '13 22:04 jerrac

cc @icewind1991 @bartv2 dup of #2762?

MorrisJobke avatar Apr 25 '13 07:04 MorrisJobke

I wanted to post a note to say that I too am having this problem. My problem is with the client sync app. The performance is utterly TERRIBLE, I mean beyond describing. I feel like I've transported back to the days of a 14.4k modem.

I am running Owncloud Server 5.0.5. I was previously running 4.5 and I had no problems using the sync client. Also FYI when I tried to upgrade to 5.0 it stalled and never finished upgrading (I let it run for days!). I finally gave up on that and blew away 4.5 and installed 5.0.5 from scratch, so this problem would have nothing to do with a problematic upgrade.

My problem is specifically with the owncloud client on Mac. I also upgraded this morning to 1.2.5 which I see is recently out, that did not help. It transfers at speeds in the kilobytes. Just to prove how bad this is. I was testing Bittorrent Sync this morning and while Owncloud transfered < 1MB of data, the Bittorrent Sync client transfered > 500MB. This is on the same client and server. In fact Bittorrent Sync transfered 1GB in a few minutes which is pretty much on par for my network speed.

I really want to be of a positive mind-set but this is a MAJOR problem and one I see many others are reporting. Whatever it is this should be priority one as it renders owncloud useless. I think this product has great potential, but right now it's basically of no value to me and I'm forced to find alternatives. I cannot say how dissapointed I was when I saw 1.2.5 was released and a fix for this was not part of it. anything else you guys work on should take a back seat to this until it's resolved.

dlangh avatar Apr 25 '13 11:04 dlangh

i second that opinion, i would like to stress that owncloud is excellent work-- but my 70000 files needed more than a week to upload in my internal network. as i only need dropbox-like syncing, i switched to seafile, which, thanks to git, shows much more performance (about 30 minutes).

again, THANK YOU for all your work!

but this bug is a show-stopper and should be handled with upmost priority.

munialabs avatar Apr 25 '13 11:04 munialabs

What database did you use?

MorrisJobke avatar Apr 25 '13 11:04 MorrisJobke

i used sqlite. and if i remember correctly i also used mysql on the raspberry pi. but no postgresql.

munialabs avatar Apr 25 '13 11:04 munialabs

In my case sqlite was the show-stopper. Using mysql, uploads are pretty fast.

MorrisJobke avatar Apr 25 '13 11:04 MorrisJobke

I don't remember choosing a database, so I have to assume that means sqlite. Having said that since someone else mentioned raspberry pi, where the hardware could possibly be the bottleneck (I have 4 pi's and I love them but when I tested owncloud 4.5 on one of them it was just too slow for me. In that case it was web access. My owncloud server is running on a 2.2 Ghz Mac Mini with 4GB ram, so performance should not be an issue.

Having said this I will give mysql a try and report back here my findings.

Thanks!

Don

dlangh avatar Apr 25 '13 13:04 dlangh

as a sidenote: i also had owncloud running on some quad-core amd, x4 631 i think, under linux mint, and the client was just the laptop next to it, connected via a 100mbit switch. the performance was not different to my pogoplug and also not different to my raspberry pi. on both the amd and the pogoplug i'm quite confident that i have chosen sqlite.

munialabs avatar Apr 25 '13 13:04 munialabs

If just one php module is installed(sqlite, mysql, psql), owncloud automatically chooses this and no choices are listed;)

MorrisJobke avatar Apr 25 '13 15:04 MorrisJobke

I haven't tried anything but mysql.

jerrac avatar Apr 25 '13 16:04 jerrac

Ok, I performed the following:

  1. Installed owncloud server on ubuntu server, setup apache with SSL the works. This was a completely NEW installation, no legacy files, no upgrade, no migration. Brand new Owncloud server 5.0.5. This time I used Mysql for the database backend, NOT sqlite as before. This box really isn't doing much at the moment, no other activity and it's an internal box of mine.
  2. I confirmed owncloud web interface loads and works via https://
  3. Opened my client app on Mac version 1.2.5. I deleted all sync folders in the client so I had none anymore. The old ones were pointing to my original owncloud server on my mac mini, so I figured best to wipe them and start clean with client as well.
  4. I created a new sync client definition. it connected without issue and let me create new sync folder.
  5. Sync started running.
  6. In ssh terminal on ubuntu server, cd into the owncloud data folder. This folder is btw not located in the owncloud webroot, I have an external drive I am using, I don't expect that is the cause but trying to provide as much info as I can. After going into the files folder for my user I can see the new folder I synced, if I go into that I can see it's folders/files being populated.
  7. Running du -c from the files folder tells me that in fact files are continuing to be populated, but again the speed is horrific. If I wait a few seconds and rerun the command, I might get 10-25K increase. It is still painfully slow. After about 10 mins and maybe 2 MB transfered, I finally aborted and gave up.

That is my experience, for me mysql was no help.

dlangh avatar Apr 25 '13 20:04 dlangh

@dlangh Thanks for your detailed report. Here at my (virtual) machine with ubuntu 12.04 and oc 5.0.5 (upgraded from fresh 5.0.0) my 2GB documents folder (< 20k files) was uploaded in 20-30 minutes. And for me sqlite was the bottleneck.

Maybe @icewind1991 has a glue.

MorrisJobke avatar Apr 25 '13 20:04 MorrisJobke

Having the same problem here. My system: Windows 7 x64 SP1 using current downloadable version of xamp I used mysql as database

Content was about 2 GB mainly pdf-documents in several sub directories. Some files were bigger. Upload to server was something around 5 files in one minute and approximately 10MB in total. Server was within local network, 100MBit connection, running also with windows 7 x64 SP1 Any more info I'll be happy to submit

dermase avatar Apr 26 '13 06:04 dermase

My experience is similar, and I'm using PostgreSQL with ownCloud 5.0.5. Uploads of a single file seem pretty normal, but whenever there are large amounts of files, it's so slow as to be unusable. I started to sync Windows server (using client 1.2.5) that had maybe 200,000 files totaling about 180 GB, to an ownCloud server to which the client machine had a gigabit Ethernet path. Even across gigabit Ethernet, the progress was so slow that it would have taken ten days to complete had I not interrupted it after two days.

The server is Ubuntu 12.04 64-bit, running PHP 5.3.10-1ubuntu3.6 and PostgreSQL 9.1+129ubuntu1.

We're interesting in providing a private backup to our customers and are interested in using ownCloud as a service provider, but obviously we won't go any further in this direction until we see our test install work well.

tfelice avatar Apr 26 '13 15:04 tfelice

On my system with owncloud 5.0.5 on opensuse 12.3 with sqlite as db I notice the same issue. I use nginx with php-fpm

Since I can hear the disk activity, I have focussed in that venue to trace the issue.

I have noticed that on every PROPFIND the owncloud.db and owncloud.db-journal is openen multiple times with NOEXIST as a result given. Surprising since owncloud.db exists.

owncloud.db-journal is being created and deleted repeatedly.

opened the owncloud.db with sqlite3 and issued a PRAGMA journal_mode = WAL

This has mitigated the issue greatly, but I still notice a lot of file open commands on the owncloud data dir.

This leads me to believe that the connection to the database is opened and closed repetitively. in de lib/db.php I do notice some code which tests access to the database. I have not tersely researched the code. Well I can read it, but only with half a clue... ;-) But I think that connections to the database are not persistent and are opened and closed about 3 times for each query (on PROPFIND).

Expensive in sqlite and perhaps also on other (remote) db backends.

I hope this can help in resolving the issue.

BB, Arjen

ArjenR avatar Apr 26 '13 23:04 ArjenR

@ArjenR Thanks to your great research!

MorrisJobke avatar Apr 27 '13 07:04 MorrisJobke

@kabum

You are welcome :-)

But looking again, I am unsure on the fact that it is related to PROPFIND. (I did not look into the code) I look at log files and the strace and correlate them. So I think it is at PUT that all the repetitive database open seem to happen. As is mentioned elsewhere.

ArjenR avatar Apr 27 '13 10:04 ArjenR

I don't know if this helps at all, but I did a tcpdump on the server, which uses a local copy of PostgreSQL, to see the traffic on localhost:5432, and I see the following curious output (incorrect checksums). This is while a couple of clients are actively syncing, and I see the file count incrementing on the server, so the slow file transfers are still in progress. Doesn't seem to be any filesystem problems on the server; when I use scp I get transfer speed close to 300x what I'm getting with the ownCloud client.

IP (tos 0x0, ttl 64, id 778, offset 0, flags [DF], proto TCP (6), length 126) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe72 (incorrect -> 0x3830), seq 721585049:721585123, ack 4005059246, win 768, options [nop,nop,TS val 17694106 ecr 17694104], length 74 IP (tos 0x0, ttl 64, id 14240, offset 0, flags [DF], proto TCP (6), length 126) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfe72 (incorrect -> 0x52d3), seq 1:75, ack 74, win 613, options [nop,nop,TS val 17694106 ecr 17694106], length 74 IP (tos 0x0, ttl 64, id 779, offset 0, flags [DF], proto TCP (6), length 158) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe92 (incorrect -> 0xc084), seq 74:180, ack 75, win 768, options [nop,nop,TS val 17694106 ecr 17694106], length 106 IP (tos 0x0, ttl 64, id 14241, offset 0, flags [DF], proto TCP (6), length 174) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfea2 (incorrect -> 0x9ee1), seq 75:197, ack 180, win 613, options [nop,nop,TS val 17694106 ecr 17694106], length 122 IP (tos 0x0, ttl 64, id 780, offset 0, flags [DF], proto TCP (6), length 142) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe82 (incorrect -> 0x4d4b), seq 180:270, ack 197, win 768, options [nop,nop,TS val 17694106 ecr 17694106], length 90 IP (tos 0x0, ttl 64, id 14242, offset 0, flags [DF], proto TCP (6), length 142) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfe82 (incorrect -> 0xc627), seq 197:287, ack 270, win 613, options [nop,nop,TS val 17694106 ecr 17694106], length 90 IP (tos 0x0, ttl 64, id 781, offset 0, flags [DF], proto TCP (6), length 158) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe92 (incorrect -> 0xdaba), seq 270:376, ack 287, win 768, options [nop,nop,TS val 17694106 ecr 17694106], length 106 IP (tos 0x0, ttl 64, id 14243, offset 0, flags [DF], proto TCP (6), length 126) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfe72 (incorrect -> 0x1d7f), seq 287:361, ack 376, win 613, options [nop,nop,TS val 17694106 ecr 17694106], length 74 IP (tos 0x0, ttl 64, id 782, offset 0, flags [DF], proto TCP (6), length 126) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe72 (incorrect -> 0xbfb2), seq 376:450, ack 361, win 768, options [nop,nop,TS val 17694108 ecr 17694106], length 74 IP (tos 0x0, ttl 64, id 14244, offset 0, flags [DF], proto TCP (6), length 126) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfe72 (incorrect -> 0x815a), seq 361:435, ack 450, win 613, options [nop,nop,TS val 17694108 ecr 17694108], length 74 IP (tos 0x0, ttl 64, id 783, offset 0, flags [DF], proto TCP (6), length 158) 127.0.0.1.41236 > 127.0.0.1.5432: Flags [P.], cksum 0xfe92 (incorrect -> 0x1dfc), seq 450:556, ack 435, win 768, options [nop,nop,TS val 17694108 ecr 17694108], length 106 IP (tos 0x0, ttl 64, id 14245, offset 0, flags [DF], proto TCP (6), length 174) 127.0.0.1.5432 > 127.0.0.1.41236: Flags [P.], cksum 0xfea2 (incorrect -> 0x79d8), seq 435:557, ack 556, win 613, options [nop,nop,TS val 17694108 ecr 17694108], length 122

tfelice avatar Apr 27 '13 12:04 tfelice

On further investigating, my change to WAL journal for sqlite3 made little change.

the strace is still running on php-fpm. It now points me to stufft happeninging in updater.php and mimetypes.lst.php should warrant further investigation. Each time these are opened an open on owncloud datadir happens and the process stocks for a second or two.

updater.php has a function correctFolder which recursively updates some metadata on all parenfolders. This is good in code, but I guess it results in multiple selects and updates on the database. And, perhaps is also the cause for the frequent database connects/opens I observed. Since there is also an array mentioned in the code this perhaps points to code iterating over a recordset where an SQL command resolving all this in one go, is faster.

mimetypes.lst.php just defines an array of mimetypes. So I think whatever calls/includes it is another culprit.

Oh well, lot's of other stuff to do..

@tfelice imho this should not be related to the issue at hand, since this Oh well, shows osi layer 3 / kernel stuff and not on the application level?

ArjenR avatar Apr 27 '13 15:04 ArjenR

I wanted to follow up to say how I am addressing this issue for the time being in the hopes it might help others. My problem with owncloud at this point is limited to the client only. If I manually place files in my owncloud folder on my server it's working fine. I can also upload files via my phone ( I use camscanner to scan receipts and then drop them into owncloud).

So my hangup was the owncloud client and how slow it is communicating with my owncloud server. I decided to use BitTorrent Sync to sync the few folders I needed synced. I run btsync on my laptop as well as in linux where my owncloud server is. So far this has worked for me. I can now access owncloud on any device and it gets updated automatically for those folders I need to have that feature. I may even just keep it this way, since I don't need yet another cloud client running on my laptop...

dlangh avatar Apr 29 '13 13:04 dlangh