My local Nextcloud is too slow in any response

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, 12.0.2): 16.0.4
Operating system and version (eg, Ubuntu 17.04): Docker (with pgsql) under macOS (i5 16G)
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.15.2
PHP version (eg, 7.1): in Docker

The issue you are facing: Performance is too slow

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

Steps to replicate it:

  1. Install Nextcloud via docker-compose (most same as https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/insecure/postgres/fpm )
  2. Installation wizard timeout (504) even I set the nginx timeout setting to 600s (10mins). This means the installation can’t finish in 10mins.
  3. I tried use cli to finish the installation in docker container, it could be done well, but also was very slow.
  4. All operations such as listing files, doing any setting on web (via Chrome) are definitely slow. The average response time (PHP) in Chrome network console reach to 10s.

The output of your Nextcloud log in Admin > Logging:

All the logs seems just normal only with INFO/DEBUG something, no ERROR/WARNING etc.

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,
    ),
  ),
  'passwordsalt' => '',
  'secret' => ',
  'trusted_domains' => 
  array (
    0 => 'localhost',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '16.0.4.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'instanceid' => '',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

My docker-compose.yml:

version: '3'

services:
  db:
    image: postgres:alpine
    restart: always
    volumes:
      - ./db:/var/lib/postgresql/data

  app:
    image: nextcloud:fpm-alpine
    restart: always
    ports:
      - 9090:9000
    volumes:
      - ./app:/var/www/html
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB=nextcloud
    depends_on:
      - db

And my nginx is in the host server.

The output of your Apache/nginx/system log in /var/log/nginx:

Here may be the installation timeout 504 in nginx:

2019/09/15 12:07:10 [error] 6066#0: *5195 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 192.168.1.1, server: localhost, request: "POST /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9090"

When I am using like listing files, the app container CPU in docker stats will come up to 50%~80%, and come down after the operation is done.

All these test is on my local Mac which server and client just in one computer. I never met any local web server responding so slow before. Hope anyone could help!

Try using the nextcloud:latest image instead and accessing it directly without nginx to compare performance.

@KarlF12 Thank you for your solution! I have simply tried the nextcloud:latest by single docker run, and it is at least 10 times faster than my docker-compose even I just config it through SQLite.

I also tried change to nextcloud:latest than nextcloud:fpm-alpine in my docker-compose.yml, and directly visit without nginx, but still very slow.

So I think it is nothing to do with the nginx, maybe pgsql caused this which I am not so sure. I will get another try when I get some time these days.

Hmm, not sure. I run nextcloud:latest with mariadb behind an Apache reverse proxy and it seems to be fine.

Update:

I have done a few more tests and found that all slow is when I am using docker-compose.

I have tried on nextcloud:latest with SQLite only by docker run or by docker-compose, and found the performance are totally different, which same as I described before - docker run is at least 10 times faster than docker-compose.

Here is the docker-compose.yml file I am using:

version: '3'
services:
  app:
    image: nextcloud:latest
    restart: always
    ports:
      - 9090:80
    volumes:
      - ./app:/var/www/html

I am wondering why this is happening? And does it anything relate to the macOS or docker?

I have dig a little deeper and find the performance problem on macOS is from the volume config. No matter I am using docker run or docker-compose, if I map the volume from docker to host, then the container handles request very slowly.

I searched for the problem and found this unsolved issue (with docker on macOS): File system performance improvements.

And I have tried to add a flag :cached to the volume config, it will be much better, before the issue be solved by docker.

4 Likes

This is still a problem today with the latest Docker and Nextcloud version.

I have not tried :cached yet.

Does this still apply? or is there anything I can do to improve the performance?