Using S3FS as Primary Storage for ownCloud or NextCloud

The next generation of object storage with ownCloud and NextCloud

Using S3 as primary storage for ownCloud or NextCloud is a widely used option for organizations who cannot accurately predict their future storage capacity requirements, and don’t want the hassle of manually resizing their storage backend. Because S3 storage does not have to be pre-provisioned and it is “pay as you go”, it can be a cost-effective solution that eliminates the guesswork of creating a storage pool with block volumes.

ownCloud and NextCloud have a feature where S3 buckets can be used as the primary storage, i.e. to store user data. One of the downsides of this feature is that the appdata directory is also stored in S3, bottlenecking the performance of the frontend. Also, when this feature is enabled, user data is stored in urn:oid objects.

The urn:oid objects are associated with the uploaded file only by the metadata stored in the oc_filecache table of the ownCloud or NextCloud database. The file tree cannot be transparently browsed in a file explorer, precluding the use of backup tools.

It is particularly important to back up the database if you have enabled the S3 primary storage feature, as the data cannot be reconstituted without the metadata therein.

So, what if you want the scalability of S3 without its performance bottlenecks? What if you want to use classic backup tools such as rsync to easily backup your NextCloud data at any time?

New for 2020, we have a superior solution that is not currently offered by any ownCloud or NextCloud partner. By using S3FS instead of relying on NextCloud’s object storage support, you are able to use any S3 compatible bucket with NextCloud, while side skirting the downsides. For instance, you could use a different cloud provider’s object storage, or a third-party provider such as Wasabi, or even self-host a Minio cluster.

We are practically introducing the equivalent of the SSHD concept for cloud storage, where a high performance SSD is used for app data, and relatively slower S3, is used for inexpensive storage.

The s3fs-fuse driver allows you to mount an S3 bucket to your Linux system with many of the characteristics of a conventional filesystem. Although the performance of S3 is many times slower than that of an HDD or SSD block volume, it is sufficient for storing and retrieving NextCloud data. On the other hand, if NextCloud’s app data directory is persisted on the S3, the web interface of NextCloud will begin to load very slowly as your users accumulate hundreds of thousands or even millions of small objects in the S3 bucket.

With our solution based on S3FS, we can move the app data directory outside of S3 to a high performance SSD, while taking advantage of S3 for storing user data. The app data directory is relatively small compared to the rest of NextCloud’s data directory, as it is a cache for the NextCloud frontend (css, images, user avatars).

You only have to pay for a small amount of SSD, which averages 5X more expensive per gigabyte compared to storing data on S3. Our solution reduces data storage costs while taking advantage of blazing-fast SSDs for the frontend.

Normally, ownCloud or NextCloud do not allow you symlink directories outside of the data directory (it results in the error “following symlinks is not allowed”), but our solution does not require the use of symlinks.

If you are already using object storage as primary storage in NextCloud, we can handle the migration of your data to this high performance & cost-effective solution. Migrating data from the urn:oid objects cannot be accomplished by simply copying the data to a new server. It requires an adaptation of your database to retain your users, groups, and app settings – while reconstructing the metadata on the new instance.

The references to the urn:oid objects are no longer valid when you stop using the default object storage feature in ownCloud or NextCloud, making their solution a form of lock-in. With our solution, your data is never locked in to any particular storage format. It can be backed up, and migrated out to any other storage solution at any time.

One of the aspects of the object storage as primary storage feature in NextCloud that is not documented is the fact that you cannot disable object storage without rebuilding your NextCloud instance. Our solution is based on POSIX compliant mounts and filesystems, which can be migrated to a different storage medium at any time.

If you’re looking for a safer way to use object storage as primary storage in NextCloud, contact us about our unique implementation that is not offered by any NextCloud partner.

Migrating from NextCloud’s default to the S3FS implementation after installing NextCloud will require recreating file, folder shares, public links, and comments. If you are looking at deploying NextCloud for the first time, it’s worth considering to go with an S3FS-based deployment from the start.

If you have ever built a PC, you have probably seen SSHD (solid state hard disks) being advertised as faster than HDD, but less expensive per GB than SSD. We are practically introducing the equivalent of the SSHD concept for cloud storage, where a high performance SSD is used for app data, and relatively slower S3, is used for inexpensive storage.

As an independent NextCloud consultant, Autoize has the freedom to innovate in ways that diverge from the official project. We can deploy NextCloud and migrate your existing data to an accelerated instance that uses a hybrid of block storage for app data and S3FS for user data. This way, you can have the best of both worlds.