Nextcloud server RAM issue

Hey I been encountering an issue and wonder if I am the only one.
I installed a working nextcloud multiple times now and always had the same issue.
As seen in the image my WSL 2 Ubuntu takes all RAM it wants and after that CPU usage goes crazy. Nextcloud / Ubuntu is not responding in this stage. If I clear the ram with the command “sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches***”
it seems not to happen.

Any ideas on this ?

  • Nextcloud Server version (e.g., 29.x.x):
    Nextcloud Hub 9

  • Operating system and version (e.g., Ubuntu 24.04):
    Windows 10 / WSL 2 / Ubuntu 24.04

  • Web server and version (e.g, Apache 2.4.25):

  • Apache 2.4

  • Reverse proxy and version _(e.g. nginx 1.27.2)

  • PHP version (e.g, 8.3):
    8.2

  • Is this the first time you’ve seen this error? (Yes / No):
    No

  • When did this problem seem to first start?
    When uploading the whole iPhone photo library

  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    first time manual install / second time snap install

  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    nothing that I know

Summary of the issue you are facing:

Steps to replicate it (hint: details matter!):

  1. install nextcloud server on Ubuntu 22.04 or 24.04 (NC or Ubuntu version does not matter as far I can tell)
  2. start upload whole photo library
  3. wait until Ubuntu freezes

I’m very familiar with this issue, as I struggled with it for over two years on my Nextcloud Snap and Nextcloud AIO servers (both running on Ubuntu Server).
Just like in your case, my server kept crashing, especially when uploading larger files. I tried to address the problem by clearing the memory every minute via cron, but this didn’t help much.

To minimize crashes, I started uploading larger files via SSH and then rescanned the files on the server.

Recently, however, I managed to resolve the issue. I use self-hosted VMs on Proxmox and configured them according to my own guide, which I’ve detailed in this post: https://help.nextcloud.com/t/nextcloud-with-dietpi-lxc-or-docker/210378/2?u=vawaver.

Since I don’t know what platform you’re running on, I can’t say whether my approach is directly applicable to your setup, but I recommend giving it a try if possible.
Feel free to reach out if you have any questions.

Mine is not directly crashing but as you said when uploading many files or big files. Big files are the bigger problem. I am still running a Windows 10 machine with WSL 2 for Ubuntu as my server but maybe I will use a dedicaded Linux in future. So thank you already for that guide. I think it will be useful in future

1 Like

What do your guest VM OS logs and measurements indicate?

I.e. what is going on in the Linux environment?

Hello,

WSL2 is basically a VM runs with Hyper-V as it’s hypervisors but much tightly integrated with Windows than a conventional Hyper-V VM. However, underneath, it is a VM layer with Hyper-V as it’s backend.

I have been a long term user of Nextcloud running via Hyper-V and dynamic memory management with Linux or anything apart from Windows VMs are a common problem of Hyper-V.

In theory, Hyper-V is supposed to increase or decrease the RAM allocation based on the RAM requirement of the Guest OS but due to Linux memory caching, it never works out as it is suppose to. Once some amount of RAM is allocated to the Linux Guest, Hyper-V can’t reclaim that back.

However, with Windows as Guest OS on Hyper-V, this feature works flawlessly.

This Dynamic RAM management works flawlessly with QEMU as hypervisor. Where Linux Guest runs on Linux Host.

Coming to the issue now, since WSL2 is just basically a Hyper-V VM, consider running Ubuntu as a standalone Hyper-V VM then deploy Nextcloud snap in that Ubuntu VM. WSL2 wont give you the ability to limit RAM usage but standalone Hyper-V will.

Limit the MAX RAM to something which you can allocate as per your available resources and need of the server.

Thanks.

2 Likes

My final solution / workaround was switching to docker / nextcloud aio

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.