Nextcloud extremely slow when multiple users access at the same time (docker container behind reverse proxy)

Host Infos

CPU: Ryzen 5 3600 12-core
Memory: 64 Gb
Storage: 500 Gb NVMe
OS: Ubuntu Server 20.04

Docker Container Structure

  • Nextcloud [localhost:*]
  • SWAG Reverse Proxy (nginx) [*:443, *:80]
  • Redis [localhost:*]
  • MariaDB [localhost:*]

Nextcloud Container Infos

Nextcloud version: 20.0.5
Operating system and version: Ubuntu Minimal 20.04
Apache or nginx version: nginx 1.18.0
PHP version: 7.3.25

Problem Description

Our Nextcloud frontend loads for up to a minute when more than one user accesses any functionality (Login, Logout, Talk, Files, Dashboard, …). However, with a single user actively interacting with the installation, everything is extremely fast.

There are no errors generated and the system usage is also low (checked using htop). We tried switching to MySQL (MariaDB container) and Redis caching to improve multi-user performance. While further improving load times for single users, the installation is still extremely slow when two or more users interact with the frontend at the same time.

Steps to replicate it:

  1. run official Docker image of Nextcloud
  2. trigger any functionality from two different users at the same time
    optional steps:
  3. configure usage of MariaDB container
  4. configure usage of Redis container

I verified that both the MariaDB and Redis containers are utilized by the Nextcloud installation. Sadly, there are no relevant logging informations present. Most error logs are empty altogether.

We want to use the Talk application to chat privately, so we often access the installation at the same time, resulting in a coffee break for everyone involved. I would be very grateful for any hints on fixing this weird behaviour.

I will also try to enable opcache now and report the results here as soon as I am done.

Hi am just curious to know like how are you maintaining the privacy of each user’s upload…
In my case am trying to create folder for each users in external folder, but its the mannual process i want automatic creation

Can u help me out!!!

I do not really understand your question - maybe you should open your own topic for it.

Each user automatically has a private directory on the server, which is in my case a mounted volume on the docker host machine. Whoever has access to the host server via ssh/ftp will be able to view the individual files of each and every user. However, the nextcloud frontend only grants users access to the files they are allowed to view/edit (they either own them, then they’re stored in the user’s directory on the server or it is a shared file in which case the file will be stored in the owner’s server directory).

Feel free to correct me, though - I am still very new to the Nextcloud ecosystem.

I totally get it, What i am trying to achieve here is

    • as you said users will have their own files and folders created in the host in which NC is hosted ---- this is totally fine, am good here
    • i want to provide external storage access with folders created on the name of users, so that they wont disturb the host’s data space — so here i can create folders manually in the name of users since am the admin, but i expect NC to create folder under user’s name.

Now user will have their own extra space in External Storage also…

As I already mentioned, I am not familiar with Nextcloud in-depth, yet. However, you could look into “flows” and run a script on the server, every time a new user is created. This script should link a folder inside of the user’s directory to the external drive (e.g. ln -s /mnt/EXTERNALDRIVE/nextcloud-data-or-something/USERNAME/ /data). For already existing users, you could also let the script loop over the directory - just check if there already exists a directory “external” in the user’s data directory beforehand.

I just noticed you may want to keep your host clear of all user data. If that is the case you could just copy the existing user data to the external space and link the whole user data directory from the external memory to the nextcloud (ln -s TARGET NAME). Alternatively, I am shure there is a setting for the user data directory location somewhere in the configuration file.

Okay i will try that thanks for your time Byomeer

Possible Solution

Alright. The opcache was already enabled. However, after changing the max_accelerated_files gradually to the maximum value of 999,999 in my PHP7 configuration (Nextcloud container access through docker exec -it nextcloud_container_name bash) the waiting times went down to some seconds.

I then chose to also enable MySQL caching in the MariaDB database container by editing the configuration in /etc/mysql/conf.d/docker.cnf and add the following under [mysqld]:


which equals to 1 GiB in bytes.

You can check if the MySQL cache works after interacting with the Nextcloud frontend for a while by accessing your MariaDB container through docker exec -it mariadb_container_name bash. Enter mysql -u root -p and enter your root user password when asked to. Follow up with the MySQL request SHOW STATUS LIKE 'Qcache%'. If, for example, the value for Qcache_hits is bigger than zero, the cache is working.

There are almost no “hickups” left now. However, sometimes messages in the Talk app take a while to be delivered. There are almost no waiting times of more than 10 seconds, though, which is totally acceptable.