Preloader
Performance Tuning

Fixing High CPU & RAM Usage on Xtream UI

Optimize your server's kernel parameters to handle heavy VOD and live stream loads efficiently.


Why Is My Server Overloaded?

Default Linux installations often have resource limits (ulimits) and kernel parameters configured for general use, not for high-throughput media streaming. When these limits are reached, your server may struggle with open files, network connections, and processes, leading to high CPU/RAM usage and buffering.

1Step 1: Increase System Limits (ulimit)

First, check your current user limits. Run ulimit -u. If it returns a low number like 1024, you need to increase it.

Edit the security limits configuration file:

nano /etc/security/limits.conf

Scroll to the end of the file and paste the following lines to drastically increase the limit on open files and processes:

* hard nofile 500000 * soft nofile 500000 root hard nofile 500000 root soft nofile 500000 * soft nproc 500000 * hard nproc 500000 root soft nproc 500000 root hard nproc 500000

Save and close the file (Ctrl+X, then Y).

2Step 2: Optimize Kernel Parameters (sysctl)

Next, we need to tune the kernel's networking stack to handle more connections and data throughput.

Edit the sysctl configuration file:

nano /etc/sysctl.conf

Add the following optimized settings to the end of the file:

net.core.somaxconn = 6815744 net.ipv4.route.flush=1 net.ipv4.tcp_no_metrics_save=1 net.ipv4.tcp_moderate_rcvbuf = 1 fs.file-max = 6815744 fs.aio-max-nr = 6815744 fs.nr_open = 6815744 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_rmem = 10000000 10000000 10000000 net.ipv4.tcp_wmem = 10000000 10000000 10000000 net.ipv4.tcp_mem = 10000000 10000000 10000000 net.core.rmem_max = 524287 net.core.wmem_max = 524287 net.core.rmem_default = 524287 net.core.wmem_default = 524287 net.core.optmem_max = 524287 net.core.netdev_max_backlog = 300000 net.ipv4.tcp_max_syn_backlog = 300000 net.netfilter.nf_conntrack_max=1215196608 net.ipv4.tcp_window_scaling = 1 vm.max_map_count = 655300 net.ipv4.tcp_max_tw_buckets = 1440000

Apply these changes immediately by running:

sudo sysctl -p

3Step 3: Verification & Reboot

To ensure all settings are applied correctly, it is highly recommended to reboot your server.

reboot

After the server comes back online, verify the changes:

  • Run ulimit -u. It should now show 500000.
  • Run sudo sysctl -p again to confirm the network settings are loaded without errors.

Troubleshooting

If you encounter an error regarding nf_conntrack while applying sysctl settings, it means the module isn't loaded. Fix it by running:

modprobe nf_conntrack

Then run sudo sysctl -p again.