Self-Hosted Open Source Infrastructure
Scaling Self-Hosted Nextcloud to 5,000 Users
Nextcloud works fine for a team and then falls over when the whole company arrives. The failure is rarely the web server. It is database lock contention, Redis cache stampedes, file locking overhead, and background job queues that cannot keep up. This guide scales a self-hosted Nextcloud instance to several thousand users with PostgreSQL, Redis, and a tuned PHP-FPM pool.
핵심 내용
- Move from SQLite to PostgreSQL before scaling. SQLite serializes writes and becomes the bottleneck long before user count does.
- Separate Redis roles. Use one instance for locking, one for caching, and one for session storage, or at least separate databases with distinct eviction policies.
- Tune PHP-FPM for steady state. Set pm to static with a worker count derived from available memory, not dynamic, which thrashes under bursty load.
- Enable file locking with Redis. The default database locking creates row contention on every upload and sync.
- Offload background jobs. Run occ background:ajax or a cron worker on a dedicated node so heavy maintenance does not block user requests.
- Index the database deliberately. Add indexes for oc_filecache and oc_share introduced by your actual query patterns, not the default set.
- Cache aggressively at the edge. Put a reverse proxy with long-lived cache headers in front of static assets and thumbnails.
- Measure before tuning. Use the built-in server info endpoint and database slow query logs to find the actual bottleneck.
Architecture
The request path runs from the edge proxy through PHP-FPM into PostgreSQL for metadata and Redis for locking and cache. Background jobs and previews run out of band. Scaling means keeping the database off the hot path for reads, which is why Redis carries cache and lock state while PostgreSQL holds the durable record.
Production configuration
Edge cases from production
- Large file uploads fail when client_max_body_size and PHP upload limits disagree; set both to the same value and test with a real large file.
- Redis eviction under memory pressure drops locks and corrupts uploads; set maxmemory-policy to noeviction for the locking instance.
- Federation shares across instances require matching protocol versions; mismatched versions silently fail.
- Previews for video and office documents consume CPU; disable preview generation for file types you do not need.
자주 묻는 질문
How many users can one Nextcloud node serve?
A well-tuned single node with PostgreSQL and Redis handles a few thousand active users; beyond that, split the database and add app servers behind a load balancer.
Should I use MariaDB or PostgreSQL?
PostgreSQL handles concurrent writes and large filecache tables better at scale; MariaDB is simpler for small deployments.
Why are file listings slow?
Usually a missing index on oc_filecache or an undersized Redis cache; check slow queries before adding hardware.
How do I handle a Redis failover?
Use Redis Sentinel or a managed service and configure Nextcloud to connect through the sentinel; test failover during a maintenance window.
Is object storage worth it?
Yes once file volume exceeds local disk comfort; S3-compatible storage offloads the primary disks and simplifies backups.
self-hosted open source infrastructure에 대한 Kinetikatech의 지원
저희가 매일 하는 일: Running sovereign collaboration, storage, and identity stacks on hardware you control. 당사의 서버 관리 및 웹사이트 유지보수 서비스는 평가, 구현, 24시간 연중무휴 모니터링, 30분 이내 긴급 대응을 엔드투엔드로 제공합니다.