Caching up - Adding disk caching to a Synology NAS to improve video streaming
A while ago I came across a great post on getting plex media server set up on a Synology NAS (Network Attached Storage). Since then installing and running Plex on a Synolgy NAS has become ridiculously simple thanks to a package that can be installed.
The problem is no longer getting a reliable media server up and running but getting past the network band and disk read and write problem so that the media stored on the instance would stream constantly. We often stream video to many different types of devices throughout the house and we have noticed recently as we encode these videos in native formats (4K) using the H.264 (AVC) codec.
So my options are to encode the videos at a lower resolution, have the codec on the server down convert the original format on the fly (this is really CPU intensive for my current NAS) or stream at the original format and deal with large files over WiFi.
Things used in this project
- Synology DiskStation 8-Bay Diskless Network Attached Storage (DS1813+)
- WD Red Pro 3TB NAS Hard Disk Drive - 7200 RPM SATA 6 Gb/s 64MB Cache 3.5 Inch - WD3001FFSX
- Toshiba OCZ Trion 150 960GB 2.5" 7mm SATA III Internal Solid State Drive TRN150-25SA3-960G
I decided to go with solving the large files over WiFi. My solution came in two parts:
- Add super fast disk caching to my NAS
- Come up with a way to get strong WiFi throughout our house using some soft of WiFi network mesh
This write up will detail #1 and I'll do another post on choosing and setting up wireless mesh.
Here's a breakdown of my setup prior to adding disks and configuring the NAS for caching:
- Synology DS1813+
- 6 x WD Red 3TB NAS Hard Disk Drive - SATA 6 Gb/s 64MB Cache
The configuration is a basic Synology Hybrid Raid (SHR) with one disk of fault tolerance.
Choosing the disks for caching
I ran the built in cache adviser on the Synology. This is yet another area where Synology makes it easy on the end user.
Navigate to: Main Menu > Storage manager > SSD Cache > SSD Cache adviser
So right out of the gate I need at least 700gb which tells me I am going to end up needing roughly 2 x 1TB SSDs because the cache will need to be configured as RAID 1. My guess is that I will not actually ever use that much read / write cache but the space will allow for some growth.
I ended up going with two of the following:
Toshiba OCZ Trion 150 960GB 2.5" 7mm SATA III Internal Solid State Drive TRN150-25SA3-960G
This type of storage tends to be pretty expensive but the price fluctuates. So setup a watch on CamelCamelCamel - a great deal on these would be about $200.
Installing the disks for caching
This, thanks to great design choices from Synology, was really easy. I had the last two bays (7 & 8) open in my NAS.
Setting up the disks for caching
Click "Create"
Choose "Read-write cache"
Choose the disks to be used for the cache
Allocate - I simply used the max allowed. There was no point in partitioning the SSDs that were being used for cache.
After clicking "Apply" the cache will be created
Streaming a video from our Xbox shows that the cache is getting hit
Measuring the performance of the cache
I ran several tests with the steaming client both connected to the network via WiFi and through a wired connection. I used file sizes from five mb to hundreds.
I ended up using a program called LAN speed test. There were so many variables (wireless radio, patch cable quality, client machine and connection hardware) going into trying to measure this that I simply wanted a consistent measurement.
LAN Speed test seem to at least give me repeatable results. Initially I was pretty disappointing with the measured results. I was constantly gathering data points then disabling the cache and gathering more data. There was a difference but it was fairly close to nominal.
I was concerned but I decided to do a real world test. I was blown away... I had it cranked all the way up to full HD and even tried some UHD stuff and streaming was flawless.
We have thousands of family videos and images that, pre-cache, were practically useless. Now content of all types stream incredibly fast and now that the cache has been optimized read and writing to the NAS wired or wireless is amazingly fast. The moral of the story here is that before breaking every thing down after getting results from black box tests try a real world test.
I'll end with this word of caution. If you are using your Synology to stream video and have something like Plex that gives you the ability to change bitrate/quality know that if you go with a setup described above and decide to set a different quality than the original - for instance going from 1080p to 720p, then you will most likely end up becoming CPU bound. You will get video stutters not because of IO but rather the NAS is having to work so hard to convert the video.
The good thing is if you stream out the original quality you will reduce the CPU pressure but increase the pressure on your network bandwidth (especially if it is a wireless connection) - this can be solved by implementing a network strategy such as creating a wireless mesh - but we'll leave that for another day.