Plex Media Server is an amazing piece of free software that allows you to basically run your own Netflix.
Plex will scan folders for media, detect what the movie or show is and present it to you in a very nice library. It also has the ability to transcode video which allows you to watch it on all sorts of devices, regardless of the format the video is in. While these features can be a good thing, they can also consume a lot of resources which is definitely not ideal when running in a shared environment such as a HostDoc VPS.
This guide will show you how to optimize your Plex Media Server so that you can still enjoy the benefits that Plex has to offer, while also being a “good neighbor” on the shared server, or VPS.
The first and foremost tweak we can make to Plex is to change some settings that makes Plex use less resources while transcoding.
It would be a shame for me to not point out the most obvious thing, which is that in most cases you may not even need to transcode in the first place! If you are watching your media through the Plex web interface, the most basic thing you can do is to set the playback quality in the player.
In the image above, you can see the Playback Settings menu (the 3 sliders, 3rd icon from the right) and the Quality selected is “Original”
Setting the quality to “original” means that the video is being directly streamed without any transcoding, which is the single most effective way to reduce resource use.
If you require transcoding, for example because of your internet connection or the file isn’t playable directly, then we can still make Plex transcode use less resources.
In the Plex settings, under Transcode, you will be able to set some options that will definitely help.
The image above is an example of some good settings to use. I’ll explain them.
“Prefer higher speed encoding” means that the CPU will spend less time, or resources, on the actual quality of the video which means that it can complete each block of video without stress. The opposite end of this spectrum, “Make my CPU hurt” means that the CPU will be pushed VERY hard to produce the highest quality output, which means that your resource usage would be unfair for a shared environment like a VPS. Don’t be a noisy neighbor, prefer higher speed encoding.
The other settings, such as the buffer can be left at the default of 60 seconds. This means that it will transcode 60 seconds of video, and then rest, transcode another 60 seconds and rest again and so on. Setting this higher will give you more bursts of CPU usage, less frequently, setting it lower will create more CPU usage as well as accessing the disk more frequently.
Max simultaneous transcodes is best left at 1, unless you have a good reason to allow more, such as you have more than one XBOX or set top box that cannot play directly, which is often the case. Change it off unlimited, just in case.
Library scanning is another important area that we can improve resource usage in. Plex will, by default, want to scan each file and really look into the contents of it, which is in most cases highly unnecessary and just uses more precious resources!
In the Plex settings, under Library, we can make the following changes:
If your settings look like the screenshot above, you’ve saved a lot of resources!
Automatically scanning the file system for changes can be buggy due to the use of inotify, especially if you’re mounting a network storage for your media. It consumes more resources than is needed, turn it off.
Periodic scanning is the best way to scan your files in. Daily is the best option of course, but you can lower this without too much of an impact due to the fact that we are going to make more tweaks with the generation of thumbnails, etc.
Emptying trash on every scan is usually not needed, so turn that off also.
Generating thumbnails and analyzing audio consume a ton of resources, and there’s no real benefit. Unless you explicitly need those things, for the sake of resource usage, set them to “never”
Plex will schedule some tasks that by default can be quite consuming of resources, mainly CPU and disk access (I/O)
First you can see the time that the tasks will be scheduled to run are usually when I’m asleep, adjust those to the times where there will likely be nobody watching anything. If these run while you are transcoding, for example, your resource usage will be higher than it should be and will make you a noisy neighbor and that’s a bad thing!
Backup database every three days
Optimize database every week
Remove old bundles every week
Remove old cache files every week
Refresh local metadata every three days
Perform refresh of program guide data.
Those things happen once every few days to a week, which isn’t really a huge problem. Backups and optimizing aren’t the end of the world, neither is a quick grab of guide data off the internet once a day
Update all libraries during maintenance
Upgrade media analysis during maintenance
Refresh metadata periodically
Perform extensive media analysis during maintenance
The above things do not need to be done daily, updating libraries is done already in the Library settings as often as you’ve chosen already. Media analysis and metadata refresh are 2 things that don’t need to be done daily. Extensive media analysis is an absolute waste of resources, we really don’t need to have it extensively look at every movie every single day, it’s not likely to ever change and it’s a complete waste.
Trimming the fat
By default, Plex comes with the DLNA server turned on - which is great if you are running Plex at home on a home network, but it’s horrible for security reasons and good neighborly behaviour to not scream all the time to your neighbors.
Turn it off, it’s not going to do you any good when it’s running on a VPS. DLNA doesn’t work remotely anyway, and it’s just going to create a lot of noise advertising itself to not only other VPS on your node, but everything on that subnet, in that datacenter. It’s horrible. Just turn it off unless you really know what you’re doing and have a crazy reason for needing it enabled (which, by the way, I’d love to hear about!)
If you’ve made it this far, awesome! You’ve just saved yourself from getting suspended for using too much resources on your VPS, and you’re being a good neighbor. You also get the benefit of your VPS being much faster, and your Plex experience will be better. You will sleep better at night knowing that you’re doing the right thing.
Please comment below if you have anything you’d like to add to this, all feedback is appreciated!
For some fun, can you guess which movie I was playing in the first screenshot?