Skip to main content
  1. Posts/

Scaling to 400,000+ Files: The Ultimate OneDrive Alternative for Self-Hosted Storage

·4 mins

The Community Spark #

Recently, a thought-provoking thread exploded in the r/selfhosted community: “I have over 400,000 files, and OneDrive is choking. What are my self-hosted alternatives?”

When you cross the 400k file threshold, consumer-grade cloud sync tools like OneDrive, Google Drive, and Dropbox begin to fail. They suffocate under the I/O load of constant file indexing, burn through client-side RAM, and take hours to sync simple changes. For users with massive photo libraries, code repositories, or homelab backups, the sheer inode count demands a purpose-built self-hosted architecture.

Synthesized Community Perspectives #

The r/selfhosted community rapidly polarized around three primary solutions, each with distinct advantages and systemic trade-offs:

  1. The Seafile Camp: The overwhelming consensus favored Seafile for extreme file counts. Unlike traditional file systems, Seafile uses a Git-like block-level deduplication method. It doesn’t index individual files; it manages data as chunks. This makes syncing 400,000 files virtually effortless. The trade-off? Files are stored in proprietary chunks on the server, meaning you can’t just SSH in and browse them via standard Linux commands.
  2. The Nextcloud (with a catch) Camp: Nextcloud stores files natively on the Linux filesystem, making it easy to manage locally. However, users warned that Nextcloud’s filecount scanning will crush your CPU and database at this scale. The consensus mandated aggressive tuning, specifically moving away from default database backends.
  3. The Sync-Trick (Rclone): Power users pointed out that sometimes you don’t need a web GUI; you just need reliable multi-device sync. Rclone configured to mount S3/object storage serves as a lightweight, highly resilient alternative to commercial cloud apps.

Deep-Dive Actionable Guide: Tuning Nextcloud for 400k+ Files #

If you require native filesystem storage (like Nextcloud) but must handle massive file volumes, you cannot run a standard installation. Here is the exact community-tested tuning required to survive the 400,000 file index scan.

1. Switch to Redis and PostgreSQL #

SQLite and MySQL will crawl to a halt. You must offload memory caching to Redis and use PostgreSQL for the relational database.

sudo apt install redis-server postgresql php-redis php-pgsql

Configure your config.php to leverage Redis for file locking:

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

2. Bypass Background Job Overhead #

Processing 400,000 files via AJAX is a guaranteed server killer. Switch cron to run natively via the OS:

crontab -u www-data -e
# Add the following line to run cron every 5 minutes
*/5  *  *  *  * php -f /var/www/nextcloud/cron.php

Update Nextcloud settings:

occ background:cron

Solution Comparison Matrix #

FeatureSeafileNextcloud (Tuned)Rclone + Object Storage
Sync Efficiency (400k files)Excellent (Block-level)Moderate (Full file scan)Excellent (Chunked transfers)
Storage FormatProprietary ChunksNative Linux FilesNative (depends on mount)
Resource UsageLow / OptimizedHigh (Requires tuning)Very Low
Best Use CasePure backup & file syncCollaborative web GUIAdvanced homelabbers & devs

The Verdict / Expert Advice #

Choosing the right architecture depends entirely on your workflow:

  • For the Data Hoarder: Go with Seafile. If you just want your 400,000 files backed up, synced across devices, and protected from filesystem I/O bottlenecks, Seafile’s block-level architecture is the undisputed king.
  • For the Power User / Developer: Go with Rclone. If you don’t need a OneDrive-style web interface and just want machines talking to machines or direct desktop mounts, Rclone over object storage is beautifully efficient.
  • For the Web GUI power user: Stick with Nextcloud, but only if you implement the Redis and PostgreSQL tuning mentioned above. Expect occasional high CPU loads during routine index scans regardless of tuning.

Frequently Asked Questions (FAQ) #

Why does OneDrive struggle with 400,000 files? OneDrive relies on constant filesystem indexing to track changes. At 400,000 files, the overhead required to check metadata and file integrity consumes massive CPU and RAM, leading to frozen clients and sync failures.

Does Seafile store files normally on the server? No. Seafile splits files into logical blocks (similar to Git) to optimize deduplication and sync speeds. To view or access your files natively, you must mount Seafile locally using the Seafile client or a WebDAV mount.

Can Nextcloud handle 400,000 files smoothly? Yes, but not out-of-the-box. You must disable AJAX cron, switch to system cron, utilize Redis for memory caching and file locking, and run PostgreSQL instead of SQLite or MySQL to survive the massive database overhead.