Optimizing Plex Performance on Linux


Optimizing Plex Performance on Linux 🚀

Linux offers the most control over Plex optimization. Let’s unlock maximum performance!

Hardware Transcoding Setup

Hardware transcoding requires Plex Pass and proper driver configuration.

NVIDIA GPU Transcoding

Step 1: Install NVIDIA Drivers

# Ubuntu/Debian
sudo apt update
sudo apt install nvidia-driver-535  # Use latest version

# Fedora
sudo dnf install akmod-nvidia

Step 2: Add plex to video group

sudo usermod -aG video plex

Step 3: Install NVIDIA Container Toolkit (for Docker)

# Add repository
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

# Install
sudo apt update
sudo apt install nvidia-container-toolkit

Step 4: Remove NVENC Limit (GTX cards)

GTX cards limit to 2 simultaneous encodes. Remove this:

# Clone the patch
git clone https://github.com/keylase/nvidia-patch.git
cd nvidia-patch

# Apply patch
sudo bash patch.sh

Intel QuickSync (VAAPI)

Step 1: Install Intel Media Driver

# Ubuntu/Debian
sudo apt install intel-media-va-driver vainfo

# Fedora
sudo dnf install intel-media-driver libva-utils

Step 2: Verify Installation

vainfo

# Should show something like:
# vainfo: VA-API version: 1.14 (libva 2.12.0)
# vainfo: Driver version: Intel iHD driver

Step 3: Give plex access

# Add plex to render group
sudo usermod -aG render plex

# Set permissions on render devices
sudo chmod 666 /dev/dri/renderD128

Make permissions persistent:

sudo tee /etc/udev/rules.d/99-plex-hw-accel.rules << 'EOF'
KERNEL=="renderD128", MODE="0666"
EOF

AMD GPU (VAAPI)

# Install AMD drivers
sudo apt install mesa-va-drivers vainfo

# Add plex to video and render groups
sudo usermod -aG video,render plex

Transcoder Settings

In Plex Web → Settings → Transcoder:

SettingValueNotes
Use hardware acceleration✅Must enable!
Use hardware-accelerated encoding✅NVENC/QSV/VAAPI
Maximum simultaneous transcode4-8Based on hardware
Background transcoding threads2For sync features

Transcoder Temp Directory

Create a fast temp location:

# Create on SSD/tmpfs
sudo mkdir -p /dev/shm/plex-transcode
sudo chown plex:plex /dev/shm/plex-transcode

# Or create tmpfs mount
sudo mkdir /mnt/plex-transcode
sudo mount -t tmpfs -o size=8G tmpfs /mnt/plex-transcode
sudo chown plex:plex /mnt/plex-transcode

Add to /etc/fstab:

tmpfs /mnt/plex-transcode tmpfs size=8G,mode=0755,uid=plex,gid=plex 0 0

System Optimization

Kernel Parameters

Edit /etc/sysctl.conf:

# Network tuning
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

# File handle limits
fs.file-max = 2097152
fs.inotify.max_user_watches = 524288

Apply:

sudo sysctl -p

Process Limits

Create /etc/security/limits.d/plex.conf:

plex soft nofile 65536
plex hard nofile 65536
plex soft nproc 32768
plex hard nproc 32768

I/O Scheduler

For SSDs:

echo none > /sys/block/sda/queue/scheduler

Make persistent in /etc/udev/rules.d/60-scheduler.rules:

ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"

Monitoring Performance

GPU Monitoring

# NVIDIA
watch -n 1 nvidia-smi

# Intel/AMD
sudo intel_gpu_top  # Install: sudo apt install intel-gpu-tools

System Monitoring

# Overall system
htop

# I/O
iotop

# Network
iftop

Plex Logs

# Follow Plex logs
tail -f "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log"

Power Management

Prevent Sleep

# Disable suspend
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Wake on LAN

# Enable WoL
sudo ethtool -s eth0 wol g

Make persistent in /etc/network/interfaces:

auto eth0
iface eth0 inet dhcp
    ethernet-wol g

Database Optimization

Optimize Plex Database

# Stop Plex
sudo systemctl stop plexmediaserver

# Optimize database
PLEX_DB="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
sqlite3 "$PLEX_DB" "VACUUM; ANALYZE; REINDEX;"

# Start Plex
sudo systemctl start plexmediaserver

Schedule Maintenance

Create /etc/cron.weekly/plex-optimize:

#!/bin/bash
systemctl stop plexmediaserver
PLEX_DB="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
sqlite3 "$PLEX_DB" "VACUUM; ANALYZE;"
systemctl start plexmediaserver
sudo chmod +x /etc/cron.weekly/plex-optimize

What’s Next?

Your Linux Plex server is now fully optimized! Continue with:


Pro Tip: For dedicated Plex servers, consider running a minimal distribution like Ubuntu Server or Debian to minimize resource usage!