Deployment issues with Nextcloud on Unraid

Original link: https://www.codewoody.com/posts/4155/

I wrote an article before to complain about the performance of Nextcloud. At that time, I was trying to try out Nextcloud on Synology. Considering that the CPU performance of the Synology server I used was poor compared to the price, I tried to deploy Nextcloud on Unraid. But the problem of poor performance still hasn’t changed. However, this problem has been greatly improved after Unraid released version 6.12.0 recently.

1 Problem Analysis

The problem lies in the shfs process. In Unraid, this process is responsible for aggregating the contents of folders scattered on various Disks into a unified directory library, which means that if we want to access any files, we need to find files through shfs, which also makes shfs write high throughput A performance bottleneck in the scene. I’ve often seen shfs CPU usage soar to 100% or even 200% before. The exclusive access feature is provided in the new version of Unraid. Exclusive means exclusive and exclusive. Exclusive Access refers to fixedly placing a directory in a Disk, so that when we access files in this directory, we do not need to retrieve the directory through shfs, but can directly access the directory system on the disk, thereby reducing overhead.

On the other hand, Exclusive also means that this directory cannot effectively use the storage pool provided by the disk array, but can only use the space of a single disk. Therefore, the Nextcloud data folder cannot use Exclusive Access. Fortunately, the access to data files is not the main bottleneck. The main reason for Nextcloud’s lag is the high-frequency reading and writing of many small files in the configuration file (that is, appdata) mounted on the container.

Another thing to point out is that in Unraid, although there are multiple SSDs in the cache, these SSDs will be aggregated into a unified cache disk through the Raid mechanism in advance. For Shfs, the cache pool is a single disk, so the cache Pool access can enable Exclusive Access

2 how to use

If you use Exclusive Access, you first need to open it under Settings –> Global Share Settings (as shown in the figure below, set Permit exclusive shares to yes).

8a6f60cac02092da06ff326e3375954f.png

However, when used in shared directories, the meaning of Exclusive Access is rather vague. Because the Share management interface does not provide an option that can be directly controlled by the user to enable Exclusive Access for a specific Share. In fact, whether Exclusive Access will work is determined automatically by the system based on the status of the directory. As mentioned earlier, the premise of Exclusive Access is that the data is only located on one disk. Therefore, on the premise that Permit exclusive shares is enabled, if a Share’s files can only be located in one disk, then Exclusive Access will be automatically enabled.

To realize that the shared file only belongs to one disk, the following conditions need to be met:

  1. Share only has one Storage enabled, no Secondary Storage
  2. If Share is stored in Array, only one disk can be selected when setting Include disks;
  3. If it is a pre-existing directory, then if the above two conditions are met, the data needs to be migrated to a single disk through appropriate Mover actions. (Note that if the Share exists in multiple disks before, the first two modifications will not automatically migrate the data to the target disk)

In the scenario of this article, we need to enable Exclusive Access on the appdata shared directory, and we may need to perform necessary Mover operations. If you see the following Exclusive access: no text displayed on the Share settings page of appdata, do the following:

  1. This state appears, indicating that your appdata is not completely in the cache, but part of it is in the array. At this time, we need to let Mover move the data from the array to the cache. Notice:
    1. If in the current state, your appdata is Cache only, but you still see Exclusive access: no, it is because at some point you set the option of array storage for appdata (in the old version of terminology, That is, use cache is not only, but an option of yes and prefer), then during that time period, shfs may schedule data files to the array. At this point, even if you set appdata to cache only, Mover will not automatically migrate files from the array to the cache. Modifying these related settings of the shared directory will only affect new files, not existing files directly.
    2. In the above case, you need to restore the cache-array two-level cache architecture first, and then set the Mover behavior to prefer cache (under 6.12,0, set the Mover action to Array -> Cache. Then run Mover Finished. At this time, Mover will move the files still on the array to the cache (of course, the premise is that the cache has enough space).
    3. After completing the above operations, we set appdata to cache only (Primary Storage is cache, no Secondary Storage), then we should be able to see that Exclusive access has changed to yes.

3 Epilogue

The above set of operations can greatly improve the performance of Nextcloud on Unraid. Other apps will see big improvements too (e.g. Jellyfin’s opening and searching speed will be qualitatively improved).

This article is transferred from: https://www.codewoody.com/posts/4155/
This site is only for collection, and the copyright belongs to the original author.