Unresponsive Web UI with postgres using docker-compose on vm

Nextcloud version (eg, 20.0.5): 22-fpm; 22-fpm-alpine; 22-apache; 21-fpm official nextcloud docker images
Operating system and version (eg, Ubuntu 20.04): debian 10 buster vm on unraid 6.9.2
Apache or nginx version (eg, Apache 2.4.25): whatever is provided by the official docker images
PHP version (eg, 7.4): whatever is provided by the official docker image

The issue you are facing:
It takes web ui 20-60 seconds to load any page

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Get the example config from docker/.examples/docker-compose/insecure/postgres/fpm at master · nextcloud/docker · GitHub
  2. Change credentials settings
  3. docker-compose up

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

same as default

Hi!

I am trying to install Nextcloud using docker-compose from this example on debian VM on unraid server. The main problem is that it takes web ui 20-60 seconds to load any page, which is just unusable.

I tried a lot of different configs: apache and fpm, with and without redis, and every other performance tweak from the guide, but it only works reasonably well, when I use sqlite database. I also tried to run this docker-compose on my local machine and it works fine, so it seems that the problem is somewhere in the combination of postgres, vm and nextcloud.

I checked the network speeds using iperf3 and checked postgres performance using pgbench and they seem relatively close on my local machine and on my vm, and every other app that uses postgres works fine.

Also it is strange, that nextcloud on vm shows 1.4+ cpu load, while htop shows less than 10% overall load(on 2 cores/4 threads passed to vm)

What else should I check to solve the performance issues?