Tuning NextCloud for Optimal Performance


Depending on the number of users, NextCloud can be installed on hardware as lightweight as a Raspberry Pi, or scaled out to a cluster of web servers, MySQL and Redis database servers and NFS storage nodes. Most organizations’ needs will fall somewhere in between. For an installation up between 150 to 1,000 users, NextCloud’s recommended requirements suggest that a cluster of two to four application servers should be adequate to run all of the services required.

Regardless of the hardware you are using, here is a list of best practices to follow that can noticeably improve the performance of your NextCloud instance, especially the web interface which is usually the first to show signs of slowdowns.

Also check out How to Fix Common NextCloud Performance Issues for some updated recommendations based on deploying NextCloud with Nginx and PHP-FPM, which has become increasingly popular with newer versions of NextCloud.

Use the latest version of Apache with PHP 7

OwnCloud, the predecessor of NextCloud has primarily been developed for Apache, so to this day, the NextCloud team prescribes using Apache 2.4+ for the best compatibility. Many users have also had much success with setting up NextCloud using Nginx, which provides high performance particularly when used in conjunction with a PHP-FPM worker pool to scale out.

The oldest version of PHP that the recent versions of NextCloud will run on is version 5.6. However, PHP 7.1 or greater is strongly recommended because the 7.x branch of PHP is actively maintained with security updates, and sports many performance enhancements that will make NextCloud more responsive.

You have the option of running PHP as an Apache module (mod_php), or PHP as a separate process (PHP-FPM, also known as FastCGI). The most compatible option with the best performance on a single machine will be mod_php, but PHP-FPM has the advantage of being capable of networked mode once you begin scaling out to multiple application servers.

Enable PHP Opcache

One of the memory caches that NextCloud supports is PHP OPcache. For best results, any NextCloud server should have this enabled by adding the following parameters to your 10-opcache.ini file (found under your /etc/php directory such as /etc/php/7.0/fpm/conf.d/10-opcache.ini)


Enable Redis and/or APCu memory cache

NextCloud also allows you to specify a local and/or file locking cache in its config.php file. PHP APCu and Redis are both key value stores that can be used to accelerate the performance of a PHP application such as NextCloud.

If you are running on a small cloud instance (say, less than 2GB RAM), or a resource-constrained device such as Raspberry Pi, Redis can be used for both local caching and file locking.

To install Redis on Ubuntu:

apt-get install redis-server php-redis -y

Then, add the following lines to config.php if you are using a local Redis server.

'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,

If you have the memory overhead to run both PHP APCu and Redis, you would enjoy better performance by running APCu as the local cache, and Redis as the file locking cache based on a user benchmark on GitHub.

To install PHP APCu also:

apt-get install php-apcu -y

After restarting your web server, make the following changes to config.php

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,

Any NextCloud installation can benefit from these simple performance tweaks. In fact, NextCloud will show a warning on the admin page if you’ve set up your instance without a memory cache. It’s in your best interest to resolve the issue before creating logins for your users, lest they run into timeouts and slow thumbnails in the UI.

Read more about NextCloud
, ,
Previous Post
Should You Switch to a Dedicated Invoicing App
Next Post
Backup NextCloud to Amazon S3 or BackBlaze B2

1 Comment.

  • Netto Hikari
    May 8, 2019 5:35 am

    I’m running NGINX on all my servers, including a Nextcloud server on a low-end machine and while NGINX is not as easy to set up as Apache, the overhead produced by NGINX is a lot smaller, therefore does Nextcloud on NGINX a lot snappier. Especially with many users in mind.

    I also didn’t have a single compatibility issue regarding Nextcloud extensions on NGINX. They all work fine.

Comments are closed.