-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big file download from SMB via fast networks eats up memory #29328
Comments
Is libsmbclient-php installed and used? |
yes, as written above
|
More RAM solves the issue, or? |
More memory just delays the time to crash and is not the solution. |
#29328 (comment) https://packages.ubuntu.com/xenial/php-smbclient not https://doc.owncloud.org/server/latest/admin_manual/configuration/files/external_storage/smb.html |
|
Installed doesn't mean its loaded correctly so another check you could do is to verify this via a phpinfo(). |
|
@kdslkdsaldsal refering #29328 (comment) |
@mmattel Ok, that looks good and shows that the module is correctly loaded. If you think anything needs to be adopted feel free to create a new issue at the issue tracker of the documentation. 😃 |
@mmattel could you check running the following script from you nginx server? Adjust the parameters (workgroup, username, password and smbfile) in order to download your file.
I haven't seen any possible memory leak in our code, so it might be in the libsmbclient-php or lower libraries (libsmbclient), or maybe nginx could be buferring the whole response. The above script is quite simple and should help to determine where the problem might be:
You can also check with apache. Last time I checked (with apache) in a VM with 2-3 GB of memory fetching a file of around 5 GB I didn't experience any issue. PHP memory limitations were the default (512 MB). This was between 2 different VM on the same host, although I didn't remember if I put some network constraint to test another issue. |
(Edited)
My phi.ini has |
It seems that I found a fix (or better a workaround)... Documenting the nginx parameter
and with a quick search I found:
Testing this parameter in on/off situations I can tell that having it set to off solves the problem 😄 I am not happy with the solution because I still think that the root cause is in the oC code. I cannot imagine that nginx would have an memory issue for such an long time and nobody identifies it... I will file a documentation PR asap. |
Wow, thanks! So we can close this one? |
No.
causes this issue |
I'm checking with apache and I don't see any problem downloading a 4.4GB file between local VMs (between 13-15MB/s). VM memory limited to 2GB, and docker container (with ownCloud) inside that VM limited to 512MB. Memory consumption stays stable during the whole transfer, also checked with output buffering on and off (according to the .htaccess file). You might want to retry with apache to check if the problem is with nginx. Note that, as far as I know, nginx isn't officially supported, so I don't think there will be more progress other than verifying that apache works under similar conditions. |
Just to make sure: Nginx is supported. Our recommendation and default however continues to be Apache as we don't see a huge advantage and there are way more improvements for performance which we can make inside ownCloud rather then using a different web server. |
You are right. As you have seen, I already filed a fix/workaround for nginx in the documentation repro. |
Made some more tests. I created a subpage and added the two scripts from below. Results
Personal opinion
I come back to the question if we on the one hand side use fwrite in the while loop until it is finished and on the other side use readfile - where does fwrite write to so that readfile can use it. And from my understanding these are two processes. I do not know if they mandatory run sequential or can run in parallel...
|
@mmattel you might want to check how the
Hopefully that's close enough to what ownCloud should be doing. |
Just keep in mind that running PHP scripts via php-cli vs. mod_php (in apache) vs. php-fpm (in nginx) might be completely different things where not even the webserver but the SAPI plays a role. |
@kdslkdsaldsal @jvillafanez |
Yes, all the tests should be done through nginx because the problem is there.
I don't think that's the case since all the file access should be done through the webdav interface, so downloads should be controlled by the webdav module, which is using You might want to check what happens if you add the following line in the apps/dav/lib/Connector/Sabre/FilesPlugin.php file (with the nginx buffering active):
That should disable the buffering for the file downloads |
Just ran the test by commenting out Memory consumption raises again. Personal opinion Thinking about the following situation: |
I can confirm the problem with a similar configuration as the one proposed by ownCloud before removing the nginx buffering (data from "top")
nginx memory consumption keeps increasing (php-fpm7.0 is stable) Adding the line said in #29328 (comment) seems to do the trick for me, keeping the nginx's memory usage low (0.2 comparing with the data above - php-fpm7.0 keeps a similar value of 2.2) I'm using the following configuration (based on what it is in the documentation):
nginx configuration is the default provided by ubuntu (mail section is commented, so it's ignored here):
|
I have created an nginx ticket: https://trac.nginx.org/nginx/ticket/1408 |
Update from nginx ticket:
And
Because we have in our documentation @jvillafanez we can add in the doc also the nginx conf parameter |
Makes sense 👍 |
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. |
Steps to reproduce
Expected behaviour
Download should pass without problems
Actual behaviour
Download stops after a while (3-4GB downloaded), system becomes unresponsive, after some minutes, system is accessible again.
This does not occur when
Testing
Monitoring the system via htop under different scenarious
On fast/SMB, memory and swap gets eaten up, not from the beginning but after a while until system becomes unresponsive, download gets broken and recovers after a while beeing responsive againg and memory is recovered. Memory recovery also takes place if the file downloaded finishes earlier than memory becomes eaten up. This is monitorable.
libsmbclient
installed in the latest public version (sudo pecl upgrade smbclient
)Network performance = browser (client) side, the SMB backend delivering the data is fast (55-60MB/s)
Slow Network, SMB: 3.2mbit/s (manually stopped after 510 MB = ~26min, no issues)

Fast Network, SMB 114mbit/s (memory starts raising from 345 to +603MB)

Memory raising appears between 1.2 and 3.7GB downloaded, mostly on higher numbers
Fast Network, SMB 114mbit/s (memory continues raising from 603 to +980MB)

Memory consumption continues
Pause or stop download at 980MB, waiting a minute

Memory gets freed up
Fast Network, Local (which is on an NFS mountpoint 200mbit/s (memory stays at ~380)

Server configuration
Operating system: ubuntu 16.04
Web server: nginx 1.13.6 (currently latest)
Database: mysql
PHP version: 7.0
ownCloud version: 10.0.3 production
Updated from an older ownCloud or fresh install: updated
Where did you install ownCloud from: tar
Signing status (ownCloud 9.0 and above):
The content of config/config.php:
config_report_20171023.txt
List of activated apps:
Are you using external storage, if yes which one: local / smb / sftp /
Are you using encryption: no
Are you using an external user-backend, if yes which one: no
Client configuration
Browser: Opera, Chrome, same behaviour
Operating system: W10x64
Logs
Web server error log
ownCloud log (data/owncloud.log)
Browser log
@PVince81 @DeepDiver1975
The text was updated successfully, but these errors were encountered: