Nextcloud performance tuning: settings for Linux, Docker and AIO
Practical guides · Digital sovereignty
Examples for Nextcloud 35 · PHP 8.5 · Ubuntu, Docker and AIO
Nextcloud is installed and the first files have synced. Yet folders take too long to open or photos load slowly. Time the action that feels slow and check PHP load and storage latency while it runs. If you run Nextcloud directly on Linux or use the official Docker image, start with OPcache, Redis for file locking and reliable cron runs. With AIO, check the managed settings and container resources first.
Running your own cloud is a useful step towards digital sovereignty. You decide where data lives, who can access it and which infrastructure processes it. Nextcloud gives you an open platform that you can operate yourself and adapt to your team.
That freedom needs reliable operation behind it. Nobody wants to wait for a file list just before a meeting. Whether you install Nextcloud directly on Linux, use the official Docker image or choose All-in-One, the services need to work well together.
Start with the action that feels slow
Before changing values, pin down what is taking time. Does opening any folder feel slow? Is it only the first view of a photo collection? Does the problem appear when several clients sync at once? Those distinctions often get you to the cause faster than a long list of supposed secret tweaks.
Record the installed versions, enabled apps, storage locations and resource limits. Then open a file list, load an existing thumbnail and generate a new one. Watch whether PHP, the database or image processing is doing the work. A quick login and a slow photo view can easily coexist on the same server.
Our conventional installation uses Ubuntu with Nginx and PHP-FPM. For Nextcloud 35, the official system requirements include Ubuntu 24.04/26.04 LTS, PHP 8.3–8.5 and PostgreSQL 14–18, alongside supported MySQL and MariaDB versions. These examples use Ubuntu 26.04 LTS and PHP 8.5 on a 64-bit platform. Follow the official installation instructions for packages and permissions; here we concentrate on tuning a working installation.
Docker takes care of some package management, but the performance questions remain: how much CPU and RAM are available, how quickly does storage respond, and what is Nextcloud doing? The database, PHP code and frequently accessed application data benefit from low-latency SSD storage. Large file archives can still live on HDDs. Office, antivirus and full-text search need room in the resource budget too.
PHP and OPcache: make sure you edit the right file
Separate PHP configurations are easy to overlook. On Ubuntu, the web service might use /etc/php/8.5/fpm/php.ini and its conf.d files. Command-line PHP and cron read /etc/php/8.5/cli/ instead. Apache with mod_php has another branch.
Run php --ini to see the command-line configuration. For web requests, also check Nextcloud’s administrative system information and the running FPM service. This is particularly useful after a PHP upgrade: you may have edited the new configuration while the web server still talks to the old version.
For our example server, add a dedicated PHP-FPM configuration file:
; /etc/php/8.5/fpm/conf.d/99-nextcloud.ini
memory_limit = 512M
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.save_comments = 1
opcache.validate_timestamps = 1
opcache.revalidate_freq = 2
OPcache stores compiled PHP code in memory. Here, 256 MiB gives it space for Nextcloud and its apps. After a typical working day, look at occupancy, free keys, interned strings and cache restarts to see whether it needs more. Adding memory to an already adequate cache rarely makes the application faster.
memory_limit = 512M limits the memory a single script can allocate through PHP. Total web-service memory also depends on how many processes run. We will come to that next.
Check the configuration and reload the matching service:
sudo php-fpm8.5 -t
sudo systemctl reload php8.5-fpm
sudo -u www-data /usr/bin/php8.5 --ini
The last line helps you compare CLI and cron with the web configuration. Read web values through the administrative view; a public phpinfo() file would expose unnecessary server details. The PHP reference explains each OPcache option.
What an 8 GiB server can handle
Take a small team server with four CPU cores, 8 GiB RAM and SSD storage. The web server, PHP, database and Redis all share it. Before starting more PHP processes, divide the available memory:
| Component | Budget |
|---|---|
| Operating system, web server, file cache and reserve | 2,048 MiB |
| Database, including its processes | 1,536 MiB |
| Redis, including overhead | 256 MiB |
| PHP web service/container | 4,096 MiB |
| Additional free reserve | 256 MiB |
| Total | 8,192 MiB |
For this calculation, assume 180 MiB RSS per busy PHP worker. Replace that assumption with a measurement during representative requests on your server. From PHP’s 4,096 MiB budget, first leave 1,024 MiB for shared memory and load spikes. The remaining 3,072 MiB gives a calculated ceiling of about 17 workers: floor((4096 − 1024) / 180) = 17.
We start with eight workers. That leaves headroom for larger requests and avoids making four CPU cores compete among too many processes immediately. If a worker uses closer to 300 MiB under load, the calculated ceiling falls to ten; at 512 MiB, it falls to six. Measuring the workload changes the answer substantially.
For PHP-FPM, put these values in /etc/php/8.5/fpm/pool.d/www.conf:
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
Then watch the FPM queue, CPU and memory peaks during concurrent requests. If FPM reports max_children while resources are still available, more workers may help. If CPU is already saturated, extra processes mainly compete with each other. pm.max_requests recycles workers after a given number of requests.
ps -eo pid,rss,args reports RSS in KiB. Look at busy pool workers; RSS counts shared pages more than once. Keep the FPM status endpoint local or restricted to administrators. Include cron, preview generation and extensions in the budget. A separate cron container therefore needs its own allowance. Docker’s container limit also caps usable memory. See the FPM reference and Docker resource documentation.
Build a dependable base with APCu, Redis and cron
APCu and Redis have different jobs. APCu caches local application data. Redis can handle transactional file locks, taking that work off the database. Those locks stop file operations from interfering with one another.
Once Redis and the required PHP extensions are installed, extend the existing config/config.php. For one server with local Redis:
// Merge into the existing config/config.php:
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
],
Keep Redis on the internal network and supply any existing credentials from your secure configuration. In Docker, use the Redis service name as the host. There, 127.0.0.1 points back to the Nextcloud container itself.
Use occ config:system:get memcache.locking to check Nextcloud’s setting, then check connectivity to Redis. That covers both ends of the connection. The caching guide and file-locking documentation describe other arrangements.
Regular cron execution matters just as much. AJAX background jobs depend on visits to the website. Cron gives Nextcloud a dependable schedule:
sudo -u www-data /usr/bin/php8.5 -d apc.enable_cli=1 /var/www/nextcloud/occ background:cron
Add this entry to www-data’s crontab, replacing any existing equivalent entry:
*/5 * * * * /usr/bin/php8.5 -d apc.enable_cli=1 -f /var/www/nextcloud/cron.php
apc.enable_cli=1 enables the installed APCu extension for this CLI invocation. The administration area shows when cron last completed successfully. Check the logs for recurring errors at the same time.
maintenance_window_start = 1 moves certain non-urgent daily jobs into quieter hours. The window is 01:00–05:00 UTC: in Germany, 02:00–06:00 in winter and 03:00–07:00 in summer. Ordinary background jobs continue on their regular schedule. See Nextcloud’s background-job documentation.
Let’s make Nextcloud work well for your team.
Setup, performance or day-to-day operation: we help with Nextcloud, Linux, cloud services and the infrastructure behind them.
Web server, database and storage work together
The official Nginx configuration is a good starting point. Choose the variant for your web root or subdirectory, and retain the protected-path and PHP routing rules. HTTP/2 at the TLS endpoint and compression for CSS, JavaScript and SVG shorten transfers. Browser developer tools show the negotiated protocol and Content-Encoding.
Versioned static files can use appropriate cache headers. Authenticated pages depend on the user, session and shares; an indiscriminate FastCGI cache can serve the wrong content. After changes, run sudo nginx -t and reload the valid configuration.
If large uploads fail, follow the whole path: reverse proxy, web server, PHP, temporary storage and time limits. upload_max_filesize is only one boundary. Nextcloud clients often upload chunks, so a file’s size differs from the size of one HTTP request. Test a complete upload after changing a limit. The upload documentation helps align the settings.
A team installation needs a supported PostgreSQL, MariaDB or MySQL database. Slow queries, lock waits and missing indexes are useful starting points. If Nextcloud reports missing indexes, schedule occ db:add-missing-indices with a backup and maintenance window.
On our shared 8 GiB server, database settings need to respect the allocated budget. Percentage rules for shared_buffers often assume a dedicated PostgreSQL server. Also watch work_mem: it can be allocated per query operation and concurrent session. The PostgreSQL reference explains the relationship.
While the cloud is slow, iostat -xz 1 and vmstat 1 can reveal I/O waits and memory pressure. A disk may copy large files quickly yet struggle with many small metadata requests. Repeating the same action with preview generation paused helps expose that competition.
Make Docker settings survive a container replacement
The official community image comes in Apache and PHP-FPM variants. Apache includes the HTTP server; FPM needs a web server for static files and FastCGI routing. The pool settings above apply to FPM. With Apache/mod_php, Apache processes and MaxRequestWorkers control concurrency.
The image supports options including PHP_MEMORY_LIMIT, PHP_UPLOAD_LIMIT, PHP_OPCACHE_MEMORY_CONSUMPTION and, for Apache, APACHE_BODY_LIMIT. Store them in Compose, mounted configuration files or a derived image so they survive the next container replacement.
For an existing stack with services named app and cron, use an additional Compose fragment. It supplements your existing volumes and database/Redis settings. The cron service still uses /cron.sh and shares the application’s Nextcloud volumes:
# compose.tuning.yaml — adapt service names to your stack
services:
app:
environment:
PHP_MEMORY_LIMIT: 512M
PHP_OPCACHE_MEMORY_CONSUMPTION: "256"
mem_limit: 4g
cpus: 4.0
cron:
environment:
PHP_MEMORY_LIMIT: 512M
The 4 GiB belongs to the web service. Budget separately for the cron container. Mount custom FPM pool files under /usr/local/etc/php-fpm.d/ and PHP configuration fragments under /usr/local/etc/php/conf.d/. Run php-fpm -tt to inspect the merged pool configuration, especially when a later file overrides your value.
docker compose -f compose.yaml -f compose.tuning.yaml config --quiet
# After review, recreate during a suitable change window:
docker compose -f compose.yaml -f compose.tuning.yaml up -d app cron
docker compose exec --user www-data app php occ config:system:get memcache.local
docker compose stats --no-stream
Recreating containers briefly interrupts the affected services. Afterwards, check the actual limits, OOM events and CPU throttling as well as docker stats. Free host memory does little good if the container has reached its limit. Run cron through one mechanism only. The image documentation lists the options for your tag.
What Nextcloud AIO already provides
Nextcloud All-in-One bundles the application with PostgreSQL, Redis, APCu, Files Push and other components. Much of the groundwork above is already configured. Start by checking those services and the load from optional apps.
AIO uses its own master-container options, such as NEXTCLOUD_MEMORY_LIMIT=512M, NEXTCLOUD_UPLOAD_LIMIT and NEXTCLOUD_MAX_TIME. Follow the documented creation and update procedure, retaining your volumes and existing options. Consider resource limits per managed container: limiting the master container only limits the master itself.
Check application status and the Files Push self-test inside the Nextcloud container:
docker exec --user www-data nextcloud-aio-nextcloud php occ status
docker exec --user www-data nextcloud-aio-nextcloud php occ notify_push:self-test
If large photo archives keep the disks busy, AIO’s documented procedure for moving appdata to SSD is worth considering. Follow it with a backup, suitable mounts and permissions. Include extra services such as Office and antivirus in memory planning.
Which community tips are worth investigating?
The Nextcloud forums contain useful ideas beyond basic settings. Reports that describe exactly which action was slow are particularly helpful. The following approaches have a clear technical basis; a short comparison can show whether they address your bottleneck.
| Approach | When it may help | What to watch |
|---|---|---|
| Generate previews in advance | The first photo view waits for new thumbnails. | Pre-generation shifts CPU work into the background and uses storage. Compare first and repeat views separately. |
| Put appdata and previews on SSD | Many small requests overwhelm slower storage. | Compare the same collection with existing previews. Adapt mounts and recovery procedures. |
| Use Files Push | Many compatible clients frequently poll for changes. | Check active connections, messages and PROPFIND rates. Clients and the proxy must support the path too. |
| JIT or longer OPcache intervals | A CPU profile shows substantial time in relevant PHP computation. | Allow for extra RAM and code-change detection. We retain timestamp validation as the starting point. |
Generating every thumbnail ahead of time sounds attractive for photo collections. A 2025 forum report shows how much load that work can create itself. Use the Preview Generator app selectively: suitable file types, limited concurrency and a small initial collection.
An older SSD experience report describes faster loading of existing previews. The useful idea is separating a large file archive from frequently read thumbnails. Its timings belong to that particular system; test with your own collection.
For Files Push, look beyond the self-test. In a 2024 forum case, the test passed but load remained high. occ notify_push:metrics and client connections help investigate. As the project explains, push reduces regular polling while some polling remains. Files Push and the Talk backend serve different purposes.
Keeping OPcache timestamp validation enabled gives us a maintainable starting point. A 2024 upgrade discussion illustrates how stale code can cause problems after changes. Treat JIT just as pragmatically: it can accelerate PHP computation, while database and disk waits remain. Those waits are often the more useful place to investigate.
Measure the difference
Use this table to turn a vague feeling of slowness into a focused next step:
| Symptom | Check first | Next experiment |
|---|---|---|
| Dynamic pages wait while CPU has headroom | FPM queue, busy workers, database waits | With spare RAM, test more workers or investigate a blocking query |
| CPU saturated, photo view slow | Preview generation, additional apps, CPU limit | Limit preview concurrency; test new and existing thumbnails separately |
| Many clients, heavy PROPFIND traffic | Push metrics and active client connections | Check push and proxy routing, then compare polling rates |
| Container exits under load | OOM events, memory limit, worker and cron peaks | Reduce concurrency or redistribute memory |
| Only large uploads fail | 413/504 errors, proxy limits, time and temporary storage | Adjust the relevant boundary and upload a complete file |
| Irregular load spikes | Cron, previews, search, backups and disks | Spread background work over time and compare response times |
A before-and-after comparison needs a fixed workload. Use the same user, client, files, network and concurrency. Repeat an action, for example, 30 times. Record first requests with a cold cache separately from repeated requests with a warm cache.
Record median latency, p95, error count and CPU, RAM and I/O peaks. p95 describes slower responses; with so few samples, it is a rough guide. Browser network tools capture the actual file-view experience. status.php tells you little about how smoothly that view behaves.
Change one value per run and record its previous setting. That makes improvements attributable and unsuccessful attempts reversible. Leave production caches and file locks intact during these comparisons. A tested recovery procedure belongs to a cloud your team can rely on too.
A short checklist before you finish
- Versions, enabled apps and resource limits fit together.
- Web PHP and CLI/cron load the intended settings.
- OPcache has enough space; APCu and Redis file locking are active.
- One cron mechanism runs regularly and successfully.
- Worker count fits measured memory use and available CPU.
- HTTP/2, static compression and upload limits work.
- The budget includes the database, storage and additional services.
- The same workload shows whether a change helped.
For more detail, use Nextcloud’s server tuning guide and the project sources linked above. For another major version, select its documentation and check app compatibility before upgrading.
A cloud your team enjoys using
Digital sovereignty also means understanding your cloud’s operation and being able to shape it yourself. Dexor helps with diagnosis, suitable Linux infrastructure and handover to your team. Explore Linux & cloud infrastructure or talk to us about your Nextcloud.