Improving the speed of my Nextcloud instance

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.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu Server 22.04
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.18.0 (Ubuntu)
PHP version (eg, 7.4): 8.0.19

The issue you are facing: My Nextcloud instance is slow as hell, way slower than other instances. I’d like to get advice on ways to speed up the access to my Nextcloud, it would really make my life easier. Thanks a lot !

Is this the first time you’ve seen this error? (Y/N): No, has been going on for a few weeks now, even after reinstalling.

Steps to replicate it:

Either adding a new event in Thunderbird, trying to mark a task as complete, accessing the web interface of my server… it’s really slow.

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

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

  GNU nano 6.2                                                                                     config.php                                                                                              
<?php
$CONFIG = array (
  'instanceid' => 'XXX',
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' => 
  array (
    0 => 'XXX',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.1.1',
  'overwrite.cli.url' => 'https://XXX',
  'dbname' => 'XXX',
  'dbhost' => 'XXX',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXX',
  'dbpassword' => 'XXX',
  'installed' => true,
  'memcache.local' => '\OC\Memcache\APCu',
  'mail_from_address' => 'XXX',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'XXX',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'XXX',
  'mail_smtpport' => 'XXX',
  'mail_smtpname' => 'XXX',
  'mail_smtppassword' => 'XXX',
);

What are your actual server specs? What kind of hardware?

  • CPU type
    • arm64 or x86-64
    • are you using a Raspberry Pi? If so, it supplies only the bare minimum specs as of Model 4.
  • How much RAM
    • If less than 4gb ram by itself, that is horrible.
  • How fast is your network speed?
    • If only xx mb/s of speed, you are hurting.
    • Please do not run your server over wifi. Very very slow.
    • Upgrade your network to wired gigabit if you can. Will greatly increase speeds.
    • External networking speeds will be hampered by your actual ISP speeds.
  • What kind of disks?
    • Spinning sata is fair
    • USB 2.0 external spinning drive garbage
    • Micro-SD card garbage
    • eMMC is not good
    • USB 3.0 external drive is fair for light usage
    • nvme Good!
    • SSD Good!
  • How many users?
  • Are you using one of the office suites?
    • Collabora CODE, OnlyOffice, etc?
    • If so, less than an additional two cores and additional 4gb ram is horrible.
  • Are you running other services on the same machine?
    • Matrix, Jellyfin, Jitsi, ?
    • If yes, you’ll need even more ram, etc.

Hopefully this will give you some ideas!

3 Likes

Hi, I’m renting a KS-10 server at OVH with an Intel I5-2300, 16Gb RAM, 2To SATA, 100Mbps broadband speed.

I’ve only got 1 user, no office suite, I’m only running a seedbox with a Plex Media Server instance.

Not exactly positive about how to make sure I allow Nextcloud to fully use all the server’s resources, and not have some random line of code restraining the use to 1% of its capacities, though.

Well an i5-2300 with spinning drives? and 100MBbs networking isn’t exatcley the fastest thing in the world, especially if you also using it for torrents and media streaming at the same time. I think the milion dollar question here is: What exactly is your definition of “slow.” ?

How fast is the throughput (MB/s) when you upload or download files. Please test with multiple smaller files and with one large file >2GB. And how long does it take when you log in to see the files or when navigate through the folders to see the content? More like 2-5 seconds (to be expected) or more like 10 to 20 seconds (could probably be optimized).

1 Like

Can’t say for sure about the CPU, as I have no real control over the data.
Yeah, 100Mbps is garbage, but unfortunately that’s what they are offering. I’m thinking about hosting a server at home (1Gbps) but that would be a cost and a lot of things to consider.

When I download/upload, it’s 11.1 Mo/s max. And accessing my instance/files via web takes about 20-25 seconds when the page isn’t cached (then it’s 4-5 seconds)

Thanks a lot for your answers

Thats’ pretty much what you get with a 100Mbs connection.

This is definitly too slow and cannot be explained by the 100Mbs networking or the relatively old CPU alone. I use Nextcloud on a home server in a VM on a E3-1240v5 (6th gen Core) with 8GB RAM and SSD storage and when I access it from outside my network, also with a 100Mbs connection, it is significantly faster than yours. The spinning drives certainly play a large part in this. I think SSDs would definitely help a lot here, especially if there are other things running in parallel that generate a lot of I/O (such as torrents). But I also think that there is probably room for improvement in terms of software tuning. A few keywords:

  • use / optimize PHP-FPM (FastCGI Process Manager)
  • use / optimize meomry cache like Redis, APCu
  • Upgrade to Nextcloud 24 and PHP 8.1. Performs noticable better, especially in combination with PHP 8.1.
1 Like

Okay, I did all this before without any luck.

Now I’ve found something that, I believe, really helped me out : enabling skip_name_resolve in my database settings : https://docs.nextcloud.com/server/23/admin_manual/configuration_database/linux_database_configuration.html#configuring-a-mysql-or-mariadb-database

Not sure if this was something I was supposed to do long ago, but anyway, seems to work correctly now.

1 Like

Also : configuring correctly APCu seems to have definitely sealed the deal. I only had “apc.enabled 1” in my APCu config file, so I found all the other stuff to add here : https://www.php.net/manual/fr/apcu.configuration.php

Now my 20-apcu.ini looks like this :

extension=apcu.so
apc.enable_cli=1
apc.shm_segments=1 # default = 1
apc.shm_size=128 # default = 30
apc.ttl=7200 # default = 0
apc.user_ttl=7200 # default = 0
apc.num_files_hint=1024 # default = 1000
#apc.mmap_file_mask=/tmp/apc.XXXXXX # default = no value
apc.enable_cli=1 # default = 0

F*ck me, configuring this correctly is tough. Hopefully it will hold. Thanks a lot again !!

Edit : this also helped greatly with my CalDAV tasks’ speed, it was horrendous aswell Several issues after upgrading to Nextcloud 21 - #2 by newhinton

3 Likes

I used the above 20-apcu.ini configuration and i get an error:

PHP: syntax error, unexpected ‘=’ in /etc/php/7.4/cli/conf.d/20-apcu.ini on line 3

Any idea how to solve this?

PHP: syntax error, unexpected ‘=’ in /etc/php/7.4/cli/conf.d/20-apcu.ini on line 3

Post your /etc/php/7.4/cli/conf.d/20-apcu.ini . What about line 3?
I think this config (because of cli) is not so relevant for Nextcloud performance.
Search Nextcloud tuning. Read this becaus of APCu for your Nextlcoud.

I think you only need for ACPu in config/config.php:
'memcache.local' => '\OC\Memcache\APCu',

Read also Server tuning.

Here is my config:

extension=apcu.so
apc.enable_cli=1
apc.shm_segments=1 # default = 1
apc.shm_size=128M # default = 30
apc.ttl=7200 # default = 0
apc.user_ttl=7200 # default = 0
apc.num_files_hint=1024 # default = 1000
#apc.mmap_file_mask=/tmp/apc.XXXXXX # default = no value
apc.enable_cli=1 # default = 0

Solved here: APCu syntax error - #3 by Irdi

1 Like