Very Slow UI After Clean Install on Docker (fpm-alpine/nginx/redis/mariadb)

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 24.0.5
Operating system and version (eg, Ubuntu 20.04): Docker on Ubuntu 21.04
Apache or nginx version (eg, Apache 2.4.25): nginx:alpine
PHP version (eg, 7.4): nextcloud:fpm-alpine

The issue you are facing:

Nextcloud UI is extremely slow (takes almost 10 seconds to fully load a new screen, e.g. just navigating from one settings page to another). I have just created a new install so this is on a clean setup. I have other Docker services running on the server where I do not experience a slow UI. The server is very powerful compared to what is running on it so HW resources should not be an issue.

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

Steps to replicate it:

Run this docker-compose:

  cloud-application:

    image: nextcloud:fpm-alpine
    hostname: nextcloud
    container_name: cloud-application

    security_opt:
      - no-new-privileges:true

    secrets:
      - source: app_default_password
      - source: smtp_password

    depends_on:
      - cloud-database
      - cloud-cache

    networks:

      cloud-net:
        ipv4_address: ${IP_CLOUD_BASE}.${ID_CLOUD_APPLICATION}

    volumes:

      - type: bind
        source: ${DIR_DOCKER}/shared
        target: /shared

      - type: bind
        source: ${DIR_DOCKER}/nextcloud/config
        target: /var/www/html/config

      - type: bind
        source: ${DIR_DOCKER}/nextcloud
        target: /var/www/html

      - type: bind
        source: ${DIR_APP_DATA}/nextcloud/apps
        target: /var/www/html/custom_apps

      - type: bind
        source: ${DIR_APP_DATA}/nextcloud/themes
        target: /var/www/html/themes

      - type: bind
        source: ${DIR_FILES}
        target: /var/www/html/data

    environment:

      - NEXTCLOUD_ADMIN_USER=${USER_DEFAULT}
      - NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/app_default_password
      - NEXTCLOUD_TRUSTED_DOMAINS=cloud.${DOMAIN_LOCAL} cloud.${DOMAIN_EXTERNAL}
      - TRUSTED_PROXIES=${IP_REVERSE_PROXY}
      - MYSQL_HOST=cloud-database
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=${USER_DEFAULT}
      - MYSQL_PASSWORD_FILE=/run/secrets/app_default_password
      - REDIS_HOST=cloud-cache
      - REDIS_HOST_PASSWORD=${REDIS_PASSWORD}
      - SMTP_HOST=${SMTP_HOST}
      - SMTP_SECURE=${SMTP_SECURE}
      - SMTP_PORT=${SMTP_PORT}
      - SMTP_AUTHTYPE=${SMTP_AUTHTYPE}
      - SMTP_NAME=${MAIL_DEFAULT}
      - SMTP_PASSWORD_FILE=/run/secrets/smtp_password
      - MAIL_FROM_ADDRESS=${MAIL_DEFAULT}
      - MAIL_DOMAIN=${SMTP_DOMAIN}

    restart: unless-stopped

  cloud-database:

    image: mariadb:10.5
    hostname: mariadb
    container_name: cloud-database

    security_opt:
      - no-new-privileges:true

    secrets:
      - source: mysql_root_password
      - source: app_default_password

    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW

    networks:

      cloud-net:
        ipv4_address: ${IP_CLOUD_BASE}.${ID_CLOUD_DATABASE}

    volumes:

      - type: bind
        source: ${DIR_DOCKER}/shared
        target: /shared

      - type: bind
        source: ${DIR_DOCKER}/mariadb/config/conf.d
        target: /etc/mysql/conf.d

      - type: volume
        source: cloud-database-data
        target: /var/lib/mysql

      - type: volume
        source: cloud-database-logs
        target: /var/lib/mysql/logs

    environment:

      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=${USER_DEFAULT}
      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
      - MYSQL_PASSWORD_FILE=/run/secrets/app_default_password

    restart: unless-stopped


  cloud-cache:

    image: redis:alpine
    hostname: redis
    container_name: cloud-cache

    security_opt:
      - no-new-privileges:true

    command: redis-server --requirepass ${REDIS_PASSWORD}

    networks:

      cloud-net:
        ipv4_address: ${IP_CLOUD_BASE}.${ID_CLOUD_CACHE}

    volumes:

      - type: bind
        source: ${DIR_DOCKER}/shared
        target: /shared

      - type: volume
        source: cloud-cache
        target: /data

    restart: unless-stopped

  cloud-proxy:

    image: nginx:alpine
    hostname: nginx
    container_name: cloud-proxy

    security_opt:
      - no-new-privileges:true

    depends_on:
      - cloud-application

    networks:
      cloud-net:
        ipv4_address: ${IP_CLOUD_BASE}.${ID_CLOUD_PROXY}

    ports:
      - target: 80
        published: ${PORT_EXTERNAL_BASE}${ID_CLOUD_PROXY}

    volumes:

      - type: bind
        source: ${DIR_DOCKER}/shared
        target: /shared

      - type: bind
        source: ${DIR_DOCKER}/nginx/config/nginx.conf
        target: /etc/nginx/nginx.conf
        read_only: true

      - type: bind
        source: ${DIR_DOCKER}/nextcloud/config
        target: /var/www/html/config
        read_only: true

      - type: bind
        source: ${DIR_DOCKER}/nextcloud
        target: /var/www/html
        read_only: true

      - type: bind
        source: ${DIR_APP_DATA}/nextcloud/apps
        target: /var/www/html/custom_apps
        read_only: true

      - type: bind
        source: ${DIR_APP_DATA}/nextcloud/themes
        target: /var/www/html/themes
        read_only: true

      - type: bind
        source: ${DIR_FILES}
        target: /var/www/html/data
        read_only: true

    restart: unless-stopped

The output of your Nextcloud log in Admin > Logging:

N/A only Info messages.

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'cloud-cache',
    'password' => '****************',
    'port' => 6379,
  ),
  'trusted_proxies' =>
  array (
    0 => '*************',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '*************',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => false,
  'mail_smtpauthtype' => 'login',
  'mail_smtpname' => '*************',
  'mail_from_address' => '*************',
  'mail_domain' => '*************',
  'mail_smtppassword' => '*************',
  'passwordsalt' => '*************',
  'secret' => '*************',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '*************',
    2 => '*************',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '24.0.5.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'cloud-database',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '*************',
  'dbpassword' => '*************',
  'installed' => true,
  'instanceid' => 'oc2op3n12fto',
  'loglevel' => 2,
  'maintenance' => false,

somebody reported shortly fpm variant to be much slower as Apache - did you test this as well?

Thanks for the input. No, I have not tried it because the FPM-PHP was recommended exactly because of faster performance of serving Nextcloud pages. In any case, I have tried clean installs of both 22.x and 23.x versions of Nextcloud with the same issue.

I wiped everything and did clean install today replacing the nextcloud:fpm-alpine and nginx:alpine images with the regular nextcloud image using apache. The docker-compose file for Nextcloud is the same except I have added a port as well as the APACHE_DISABLE_REWRITE_IP=1 env variable.

This is the log from container startup.

Conf remoteip disabled.
To activate the new configuration, you need to run:
  service apache2 reload
Configuring Redis as session handler
Initializing nextcloud 24.0.5.1 ...
New nextcloud instance
Installing with MySQL database
Starting nextcloud installation
Nextcloud was successfully installed
Setting trusted domains…
System config value trusted_domains => 1 set to string ***************
System config value trusted_domains => 2 set to string ***************
Initializing finished
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.*****. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.*****. Set the 'ServerName' directive globally to suppress this message
[Sun Sep 25 06:05:12.430395 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/8.0.23 configured -- resuming normal operations
[Sun Sep 25 06:05:12.430419 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

I did see some improvement in the UI response. First time I navigated to a new page it was just as slow as with the FPM/Nginx setup, however, it now seemed to cache the pages and the next time I navigated to a page I already visited it was faster. The response was still quite slow though and pages took at least 3-4 seconds to load even when previously visited.

I should mention here that even though I access my server services on my local network I do so through a reverse proxy (Nginx Proxy Manager) on a local domain. When I tried accessing Nextcloud directly on the server IP the response was quite different. Much faster. I did not think to try this before as I do not have this issue with any other services. So there seems to be a problem with the Nextcloud - reverse proxy combo that causes the issue.

Below is the configuration for Nextcloud on NPM:

image

Are there any configuration changes I need to do in either the Nextcloud or the NPM setup in order to fix the response issue when accessing through the reverse proxy?