Friday, January 15, 2021

Ultimate Plex Performance Setup Guide for NAS

I've finally pulled the trigger and purchased a Synology DS1520+ along with a pair of 10TB NAS hard drives. It was finally time to move away from an old laptop with a pair of 4tb external USB drives onto something a little more permanent. This was a bit complicated, because I was planning to use the pair of 4tb drives as well as the new 10tb drives with a total capacity of 18tb and single drive failure. Because I didn't have an extra 4tb lying around, it required the following:

  1. Initialize the pair of 10tb drives as a volume.
  2. Copy the contents of the 4tb USB drive onto the 10tb volume.
  3. Initialize the pair of 4tb drives as a volume (you cannot add smaller drives into a volume with existing larger drives)
  4. Copy the 4tb of content from the 10tb volume over to the 4tb volume.
  5. Remove the 10tb volume.
  6. Add the pair of 10tb drives to the 4tb volume. 

In the end, it took 5 days of copying (no joke), but I now have an 18tb storage volume that allows for a single drive failure without loosing any data, and without a single file of data loss.


Now onto the purpose of this post.... There are several things you can do to optimize your Plex media server to run at maximum capacity. I am making the assumption that you have at least a working knowledge of how to use DSM as well as Plex, so I'll be skipping some of the rudimentary steps and instead focus my time on the more complicated pieces. 

Please note, we'll be installing the entire Plex app on the SSD. If you already have Plex installed and configured, you can always just configure your transcoding and metadata library to run on the SSD instead.

Also note, we'll be running both the metadata AND transcoding on the SSD...  "But wait!!!", you might be shouting, "Won't transcoding destroy my SSD!?!". In the long run, yes, transcoding on an SSD will eventually kill the drive... But, it will take multiple years of constant transcoding for this to occur. Its a risk I'm willing to take. Also, we'll be backing up the contents of the SSD onto the primary RAID, so if/when it ever does die, we'll just purchase a new SSD and restore the drive like new.


Step 1 - Single drive SSD volume for Plex

Reading many a blog, everyone agrees, using an SSD for your Plex metadata is a key factor in getting the most from your Plex server. With this in mind, I added a 120GB SSD I had laying around into the fifth drive bay. This is one of several reasons I choose the DS1520+ instead of the DS920+... That plus the 8GB of ram and ability to expand to 15 disks instead of just 9.

Simply set up a single drive volume with the SSD. This can be done by opening your Storage Manager, followed by the Storage pool and click Create.


I chose "Basic" as the RAID time for maximum performance

Chose the correct drive and work through the rest of the prompts.


Next, Create the volume. On the Volume Tab, click create, choose custom, select an existing pool, which is your newly created SSD, the follow the prompts to finish.



Step 2 - Install Plex Media Server

If Plex is already installed & configured, skip to the end and I'll show you how to configure the transcoding & metadata settings to run on the SSD instead. If you don't mind recreating things, installing the entire plex app on the SSD is a much cleaner way to go.


Open the Package Center, but before we start, make sure you can choose which volume to install on. You can do this by clicking on the Settings button


Under General, Default Volume, Choose "Always ask me", and click the OK button. This way you can decide where to install Plex.


Next, click to install Plex Media Server. The first screen will be the option to Select a destination volume to install the package. Choose your SSD volume.



Finish the Plex install and that's it! Plex will automatically use the SSD for Metadata and Transcoding!

One last step, you may want to use the SSD for other rapid disk items, so go ahead and add a shared folder to the volume. In my case, I called it SSD. To do this, open the File Station, click Create -> Create New Shared Folder. Give it a name, select the SSD location, I unchecked Restrict access to administrators only and click next. I chose not to encrypt data, but I did choose the data integrity option. Finally, make set the appropriate read/write permissions.



This is now ready to go!


Step 2 - Set up auto-backups

Because this is a single disk volume, if/when it fails, you will loose everything on it. To accommodate for this single point of failure, simply setup an automated backup. This way if/when it fails, simply replace the drive and restore the backup, and you'll be back up and running!

For this task, I chose to use Snapshot Replication. To install, open your Package Center, find Snapshot Replication, and click install. Once finished, open it up.

Inside the Snapshot Replication app, Choose the Snapshops tab and use CTRL + Click to select both the Plex shared folder, as well as the SSD shared folder, then click the Settings button.


On the Schedule tab, uncheck "Keep the original" and Check "Enable snapshot schedule" instead. I set my snapshot to run daily at 3am.


Next under Retention, I choose to only retain the last 5 snapshots (5 days worth), and to delete old snapshots at 5am.


Finally, under Advanced, I chose to "Make snapshot visible".

Finally click OK to save the settings. You will now see the snapshots are scheduled! If your SSD ever fails, you'll be able to restore the backup!


Step 3 - Update Plex

While Synology does offer automatic updates, I can tell you from experience, They are quite a few versions behind! Thankfully Plex makes this incredibly easy! Start by visiting this page: https://www.plex.tv/media-server-downloads/#plex-media-server and choose Synology from the drop down menu, click Choose Package. I chose Intel 64-bit.



This will download a .spk file. Back to the Package Center, Click the "Manual Install" button, browse for the .spk file and click next. Follow the prompts and you will have the newest version of Plex installed!

In my case, the newest version of plex from the package center was 1.18.5... I was able to upgrade it to 1.21.1 with just a few clicks.


Bonus options:

Tanscoding driver fix

Thanks to NASCompares YouTube channel for this one. A full write-up can be found here. It turns out, the default driver is not able to take full advantage of the Intel Celeron J4125 processor! This is especially true with H265 video files. So, to improve transcoding, we will want to change the default driver to the i965 video driver.

Keep in mind, if you update to a newer version of the Plex Media Server, you may have to install the i965 video driver again.

First, install the Text Editor package from the Package Center.


Next, stop the Plex Media Center. You can do this via the Package Center, choose Plex and click the drop down next to open and click "Stop".


Open File Station. You will brows to Plex -> Library -> Application Support -> Plex Media Server. From there, you will click on the file Preferences.xml. This will open up in the Text Editor. Scroll right to the very end of the line, you will see the characters "/>"

You will want to add a space, followed by: VaapiDriver="i965"


Then click File -> Save


Now Return to the Package Center and click run on the Plex Media Center


That's it! Thanks Rob for doing the legwork on this one!

Pre-Transcoding

If you find that you are doing a lot of transcoding, and you have storage to spare, considering enabling offline transcoding. Essentially Plex with pre-transcode your videos so that when you want to stream, the plex will send the appropriate version without needing to engage your cpu.

To do this, simply click the ellipses for each video you would like to optimize and select "Optimize...". 


Move Plex Database to your SSD

If you already have plex setup and configured, but would still like to take advantage of the speed boost of an SSD, you can follow this guide. I could type that up, but honestly that guide has done a better job explaining it than I could have!


Move Temporary Transcoding to your SSD

If you already have plex setup and configured, but would still like to take advantage of the speed boost of an SSD, here is how it's done:

Open your File Station, Choose the SSD shared directory, and create a folder to store the temporary transcoding in. Then right click the folder and choose Properties. From there, you can copy the location which you will need for the next step.




Next, open your plex server, click settings, choose your server, click Transcoder under your server settings, then click the "Show Advanced" button. This will reveal the "Transcoder temporary directory" option. There you can paste in the directory of the newly created folder on your SSD. Click Save Changes, and you are all set!