TNCS-0028 – Why Your NAS is ‘Slow’
Created: July 15, 2015
Table of Contents
ToggleINTRODUCTION
Network Attached Storage (NAS) devices are extremely popular these days. They offer a very convenient method of sharing files between multiple users in a home or small office environment. NAS devices are essentially file servers that are packaged as appliances and thus are generally easy to configure and use.
As a Mac user, however, you have probably noticed that managing files on your NAS device is not quite as zippy as doing so on your local hard drive. If you also have Windows or Linux devices attached to the NAS, you may have noticed that those computers seem to manage files on the NAS better than your Mac. The internet is chock full of forums and threads where users have noticed this and questioned why their Macs were slow compared to PCs. These posts often degrade into flame wars with little attention being paid to the original question. This tech note seeks to address the ‘why your NAS is slow’ question in an objective and factual way.
UNDERSTANDING THE MAC FILESYSTEM
First the good news — your Mac is not sub-par compared to PCs. It is an extremely capable and sophisticated computing device running a very advanced yet user-friendly operating system. Many of the technologies packaged into your Mac are far more advanced than anything available on any other computing platform. There is no reason to feel like you’ve chosen a second rate platform — far from it! Unfortunately, however, there is a bit of bad news — your Mac is at a disadvantage when it comes to file sharing with others via an NAS. Why, you ask? Well, read on…
The basic reason that you might not achieve optimal performance is that your Mac and your NAS do not speak the same language when it comes to storing files. macOS historically has had “special needs” when it comes to storing and managing files. This dates all the way back to the original Macintosh in 1984.
While other filesystems would store little more than a filename and timestamp for each file, the Macintosh has always wanted to store much more. Information such as custom icon, color label, the character set used to name the file — even the location that the file appeared in a Finder window — were all stored with each file. This extra metadata was something other filesystems had no need to store and thus made no effort to accommodate. This always put Macintosh file storage at odds with the rest of the world.
HOW A NAS DEVICE WORKS WITH A MAC
Fast forward to today and macOS has evolved significantly to adapt and fit in with the rest of the computing world. However, the metadata storage requirements have not decreased over time. A lot of the old metadata is still stored for backwards compatibility. If you add to that the newer types of metadata such as Access Control Lists and Extended Attributes, it’s easy to see that the metadata storage requirements have actually increased.
Here’s where the problem comes in: no commercial NAS device (that we know of) uses a native Mac filesystem to store its data. They are all either Linux or Windows based and thus use a Linux or Windows native file system to store files. In order to accommodate all the extra metadata that macOS wants to store, such devices need to figure out a way to emulate a Mac native filesystem and store the metadata elsewhere on the drive.
How bad can that be? Well, take the example of trying to obtain some simple metadata from a file such as the Finder label color and the size of the file. If we’re dealing with a native Mac filesystem, we simply need to locate the catalog record for that file on disk, read it and extract this information from the record. Presto — done! An NAS device, however, needs to locate the catalog record of the file and determine what metadata can be extracted from it. Since not all the metadata is there, it then needs to locate the catalog record of another, invisible file that the NAS device is using to store the Mac-specific metadata. The NAS device then needs to open the file, parse its contents, extract the needed information, close the file and return the results. This is a LOT of work! Multiply this by the tens or hundreds of thousands of files that a typical ChronoSync backup session manipulates and you can see that an NAS device has to work a lot harder to store and maintain all those files.
Of course, not all NAS devices are created equal and some do a much better job than others at managing all the extra Mac metadata. When shopping for an NAS you should always compare the Mac-specific performance between models and brands. Don’t look at Windows or Linux benchmarks and expect them to be consistent with Mac file storage because they probably won’t be. The important point to take away from this is that you should expect NAS performance for Mac file storage to be slower than the same device offers for Windows and Linux clients — and often SIGNIFICANTLY slower than a locally attached drive.
POSSIBLE SOLUTIONS
So, what is one to do? Here’s a few pointers:
Experiment with File Sharing Protocols
Many NAS devices require you to use the SMB protocol, so you really have no option to experiment. However, some offer “Mac Native” file sharing and thus some form of “AppleShare.” AppleShare will use the AFP protocol, which is much more Mac friendly. However, don’t immediately assume that because you are connected via AppleShare/AFP that you are communicating the fastest way possible. Some NAS devices may not have a good AppleShare/AFP implementations and SMB may actually offer better performance.
You can control how you connect to an NAS or file server in Finder by choosing “Connect to Server” from the “Go” menu (or just COMMAND-K). You then specify the URL of the NAS device/server that you are trying to connect to.
For AFP connections, it will look something like this:
afp://ip.address.or.hostname.of.server
whereas SMB would look like:
smb://ip.address.or.hostname.of.server
There is also an older version of the SMB protocol that you can try by specifying:
cifs://ip.address.or.hostname.of.server
This may be beneficial with older NAS devices and file servers that may have difficulty with the newer SMB protocol (or Apple’s implementation of it). More details can be found in this article.
If at all Possible, Don't Use an NAS
Take an older Mac and set it up for file sharing. This will almost always be a better option for you because a) the hard drives will be formatted with a Mac native filesystem, thus there won’t be any trickery required to store metadata, and b) you’ll be using a file sharing protocol and software that is designed by Apple and optimized for Mac clients. If using ChronoSync for syncs and backups, you’ll also have the option of installing ChronoAgent on the Mac file server to achieve even better performance!
Note that even when using a Mac as a file server, you should pay attention to the protocol that is being used (as mentioned above). Apple has shifted away from AFP as the default protocol in favor of SMB. We have yet to witness Mac-to-Mac file sharing that performs better with SMB than AFP for real-world usage, so you will want to ensure you are connecting via AFP. Or you can disable SMB completely on your file server if you don’t need the ability to connect Windows or Linux clients.
Heres a good article that shows how to configure an old Mac to be a file server. The article discusses using the built-in file sharing features of macOS. You can also splurge and spend $20 to install macOS Server. This will offer the ability to host Time Machine backups and so much more.
Create a Sparse Disk Image
Whether you are connecting to a true NAS device or another Mac file server, you should give consideration to creating a sparse disk image on the device. You’d simply mount the disk image and store all your files on the disk image instead of directly on the device/server. This yields far better performance and truer file system fidelity. In fact, it is exactly what Time Machine does when using an NAS or file server for backup.
The reason this yields better performance is that only larger blocks of information are transferred over the network — the file system commands themselves and the transfer of small amounts of information all takes place locally without going over the network. The file system fidelity comes from the fact that you are, in essence, communicating with a native Mac filesystem when doing this.
The drawback to using a disk image is that only one user can mount it at a time, so if you need to share the information between users, it won’t be a convenient option. Plus if you have Windows or Linux users, they won’t be able to mount the disk image at all. If such is the case, disk images can still be used to store backups for your individual Mac computers.
We have a guide on using ChronoSync with disk images that discusses the process of creating and mounting disk images. It is informative, even if you are not using ChronoSync with your NAS/server.
Confused by any of this? Wonder exactly which approach you should take or how to fine-tune your setup? Just drop us a line at support@econtechnologies.com. We’ll be happy to help!
REVISION HISTORY
Jul-15-2015 – Created from Internal Support Notes.