How to Speed Up Nextcloud

If your Nextcloud feels sluggish, you’re not stuck with it. You can speed it up dramatically by tuning PHP and caching, putting Redis and OPcache to work, and making sure your storage and database aren’t dragging everything down.
You’ll also want to control previews, background jobs, and unused apps so they stop wasting CPU and I/O. Start with a few quick wins, then move to deeper tweaks that change how your instance actually behaves.
Quick Wins to Fix a Slow Nextcloud
Although more detailed tuning can be done later, you can improve Nextcloud performance with a few focused changes. First, install APCu, set shm_size to around 128M, and configure memcache.local = 'OCMemcacheAPCu' in config.php to reduce PHP request latency. Change background jobs from AJAX to a system cron running every five minutes so that page loads aren't delayed by maintenance tasks.
Next, enable Redis for transactional file locking and caching to lower database load and reduce contention.
In addition, enable and configure PHP OPcache (for example, setting opcache.revalidate_freq to about 60 seconds to limit frequent script recompilation).
Finally, use a supported and current PHP version (such as PHP 8.1 or newer where compatible) and an up-to-date Nextcloud release (for example, version 24 or later), as newer versions typically include performance and stability improvements.
Boost Nextcloud With Faster Storage and More RAM
Moving Nextcloud to faster storage and allocating sufficient RAM generally improves responsiveness. Because Nextcloud is often I/O-bound, replacing spinning SATA hard drives with SSDs or NVMe devices typically reduces page load times and lowers I/O wait, especially under concurrent access.
A practical baseline is around 16 GB of RAM for medium-sized deployments, with more memory beneficial for larger user bases or heavy usage. Additional RAM reduces swapping and allows components such as Redis and APCu to keep more data in memory, which can improve concurrency and interface responsiveness.
Where possible, place the database and Redis on local SSD or NVMe storage instead of slower hard drives or network-mounted storage, as database latency has a direct impact on perceived performance.
For organizations planning broader infrastructure or long-term data protection alongside performance tuning, managed Nextcloud hosting providers, such as Cloud Based Backup, offer solutions for storage optimization and backup strategies. More details are available here: https://cloudbasedbackup.com/
It's also advisable to keep disks used for torrent clients, Plex, or other heavy I/O workloads separate from the storage used by Nextcloud, to reduce contention.
Tools such as fio, ioping, and dd can be used to measure latency and IOPS before and after changes, providing an objective basis for evaluating performance improvements.
Tune PHP-FPM and OPcache for Nextcloud Performance
Once storage and memory are no longer the main bottlenecks on a Nextcloud server, PHP’s execution model becomes an important factor for responsiveness.
For PHP-FPM, a common starting point for pm.max_children is:
pm.max_children ≈ RAM_for_php / average_process_size
For example, with 4 GB of RAM allocated to PHP-FPM and an observed average worker size of about 40 MB, a value around 100 children is reasonable. Use pm = dynamic and adjust pm.start_servers, pm.min_spare_servers, and pm.max_spare_servers based on observed load so that the system avoids swapping and maintains stable response times.
Enable and configure OPcache in php.ini, for example:
- opcache.enable=1
- opcache.memory_consumption=128
- opcache.interned_strings_buffer=16
- opcache.max_accelerated_files=100000
- opcache.revalidate_freq=60
These values are typical starting points and should be refined using real workload measurements.
Enable APCu for PHP-FPM, for example with apc.shm_size=128M, and configure Nextcloud’s memcache.local to use APCu. This reduces repeated computation and database lookups for frequently accessed data.
Monitor PHP-FPM and OPcache under real traffic. Useful tools include:
- PHP-FPM status page (pm.status_path) for process counts, slow logs, and queue length
- opcache_get_status() for cache usage, memory consumption, and hit rate
- Application latency and server resource metrics (CPU, RAM, I/O)
Aim for an OPcache hit rate consistently above about 95%. If the hit rate is lower or memory is exhausted, adjust opcache.memory_consumption and opcache.max_accelerated_files. Reassess pm.max_children and related PHP-FPM settings if you observe high CPU utilization, frequent process spawning, or swapping.
Use Redis Caching and File Locking in Nextcloud
Using Redis in a Nextcloud deployment moves both caching and file locking away from the database, which can reduce lock contention and improve responsiveness when multiple users access files concurrently.
In config.php, set memcache.locking to OCMemcacheRedis, keep memcache.local as OCMemcacheAPCu, and define the redis configuration array with appropriate host, port, and db values.
Running Redis on a separate instance, preferably on fast storage rather than HDDs, can improve latency and stability under load.
The phpredis extension is typically recommended for lower overhead and faster lock operations compared with pure PHP clients.
Using system cron for background jobs instead of AJAX usually provides more predictable execution and reduces per-request overhead.
If Redis is used exclusively for locks and ephemeral cache data, disabling persistence can reduce disk I/O and simplify recovery scenarios.
Changes can be validated and monitored with commands such as occ status to inspect configuration and occ files:scan to assess behavior during file operations.
Optimize Your Database and Web Server for Nextcloud
Although Nextcloud’s interface and apps are the most visible components, the database and web server handle most of the workload, so their configuration has a significant effect on performance and stability. Use MariaDB or MySQL instead of SQLite for production deployments, and enable skip_name_resolve to avoid DNS-related connection delays. Place the database on fast SSD or NVMe storage, preferably on a volume separate from the operating system and user data, to reduce I/O contention.
Configure Redis for file locking and set memcache.locking = 'OCMemcacheRedis' to lower database load and reduce lock-related contention. Enable OPcache (for example, with opcache.revalidate_freq=60 and opcache.save_comments=1) and APCu to improve PHP execution performance. Adjust innodb_buffer_pool_size so that frequently accessed data and indexes fit in memory, align the maximum number of database connections with the number of PHP-FPM workers to avoid resource exhaustion, and regularly review slow query logs to identify and optimize problematic queries.
Configure Cron and Background Jobs for Nextcloud
A fast database and web server are only effective if Nextcloud’s background jobs run reliably and efficiently. To avoid tying heavy tasks to user requests, switch the background mode from AJAX to system cron.
Configure a cron job similar to:
*/5 * * * * /usr/bin/php8.0 -f /var/www/nextcloud/cron.php
Run this as the same system user and with the same PHP binary that the web server uses (for example, www-data on many Linux distributions). Avoid running it as root unless your setup requires it and you fully understand the implications.
Use the Nextcloud command-line tool to configure and verify cron operation:
- occ background:cron to set cron as the background mode
- occ background:job:list to review registered background jobs
For better performance and reliability, configure Redis in config.php for file locking and caching of background job data. This reduces database load and helps prevent file-locking issues.
Monitor the Nextcloud logs and use occ background:queue to inspect the state and size of the job queue. Based on observed load and queue behavior, adjust the cron interval—commonly between 1 and 5 minutes—to balance timeliness of job execution with system resource usage.
Reduce Preview, App, and Encryption Overhead in Nextcloud
Reducing preview, app, and encryption overhead can improve perceived performance in Nextcloud by lowering CPU, memory, and I/O usage.
Configure previews in config.php to limit or disable generation for large images, videos, and PDFs. To avoid on-demand preview generation during user requests, use occ preview:pre-generate on a schedule during off-peak hours. For additional offloading, you can use an Imaginary container on port 9000 via preview_imaginary_url (available from Nextcloud 1.2.4+; don't expose this endpoint publicly). Relevant options include preview_imaginary_key for access control, preview_format (for example, webp), and webp_quality to balance quality and size.
Review installed apps and disable ones that aren't required, especially resource-intensive components such as richdocumentscode and extra preview providers. This reduces background processing and memory consumption.
If server-side encryption is enabled, avoid using Imaginary for encrypted files, as this adds complexity and potential performance penalties. Instead, keep preview-related resources separate from encrypted data to minimize overhead and reduce the risk of misconfiguration.
Conclusion
You’ve seen how to speed up Nextcloud by tuning PHP-FPM and OPcache, adding Redis, and using fast SSD or NVMe storage. Now, apply these tweaks step by step: fix quick bottlenecks, optimize your database, and tighten cron and preview settings. Remove unused apps, keep PHP current, and watch your logs and metrics. With a bit of careful tuning, you’ll turn a sluggish Nextcloud into a fast, reliable daily workhorse.
