Self-host Nextcloud – Part 3 – Performance

Background:

After about two days’ troubleshooting and and testing, Nextcloud is successfully running in my homelab. This article documents a few performance tweaking.

Issues:

  • 504 Gateway Timeout when uploading larger files.
  • Disable file locking.

Solutions:

1. Modify PHP max_input_time and max_execution_time to get rid of the 504 Gateway Timeout error when uploading large files.

# Modify php.ini under /etc/php/8.0/fpm/ and /etc/php/8.0/apache2/
max_input_time 86400
max_execution_time 86400

upload_max_filesize 50G
post_max_size 50G

# Restart PHP and Apache
service apache2 restart
service php8.0-fpm restart

2. Disable file locking.

This might cause potential problems when you have multiple users collaborating on file editing/syncing, but in my single-user setup this was not a concern. I needed to do this when I was syncing some large files and the client froze, and after a force restart/resync, the Nextcloud client reported 423 Locked errors to PUT https://..... .

# Add
'filelocking.enabled' => false,
# to nextcloud's config.php, and clear the locked files.

# Add
'maintenance' => true,
# to config.php

# Get into MariaDB and run the following
DELETE FROM oc_file_locks WHERE 1;

# Revert maintenance mode
'maintenance' => false,

# Restart PHP and Apache
service apache2 restart
service php8.0-fpm restart

Overall performance.

Nextcloud’s overall syncing speed has a lot to do with your Nextcloud server’s performance, the more smooth your server runs the better syncing performance you’ll get (more RAM, use SSD instead of HDD, etc.). I was able to get roughly 25MB upload speed and 65MB download speed with a Hyper-V VM running Ubuntu Desktop.