Preloader
XUI Optimization

Tutorial: How To Fix High RAM and CPU Usage on XUI.ONE

Unlock the full potential of your server by eliminating Linux resource bottlenecks.


The Invisible BottleNeck

XUI.ONE is a highly efficient, compiled application. However, even the best software cannot perform well if the underlying Operating System (Ubuntu/Debian) is configured for "desktop" usage rather than "high-performance streaming." High CPU and RAM usage often indicates that the kernel is struggling to manage thousands of open connections (files) efficiently.

1Step 1: Raise File Descriptor Limits

Every stream a user watches opens a "file" on your Linux system. Default limits are often too low (1024), causing the CPU to work overtime managing queues or the RAM to fill up with stagnant processes.

Open the security limits file:

nano /etc/security/limits.conf

Add the following lines to the end of the file to allow XUI (and the root user) to handle massive concurrency:

root hard nofile 1000000 root soft nofile 1000000 * hard nofile 1000000 * soft nofile 1000000 root hard nproc 1000000 root soft nproc 1000000 * hard nproc 1000000 * soft nproc 1000000

Save and exit (Ctrl+O, Enter, Ctrl+X).

2Step 2: Optimize the Network Stack (Sysctl)

This is the most critical step for reducing RAM usage. We need to tweak how the kernel handles TCP buffers and connection tracking. Improper settings here cause memory leaks and high CPU wait times.

Open the sysctl configuration:

nano /etc/sysctl.conf

Paste these high-performance settings at the bottom:

# Network Core Improvements net.core.somaxconn = 65535 net.core.netdev_max_backlog = 262144 net.core.optmem_max = 25165824 net.core.rmem_default = 31457280 net.core.rmem_max = 67108864 net.core.wmem_default = 31457280 net.core.wmem_max = 67108864 # TCP Tuning for Streaming net.ipv4.tcp_rmem = 8192 87380 67108864 net.ipv4.tcp_wmem = 8192 65536 67108864 net.ipv4.tcp_congestion_control = htcp net.ipv4.tcp_mtu_probing = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_sack = 1 net.ipv4.tcp_timestamps = 0 # Connection Tracking (Prevents CPU spikes on new connections) net.netfilter.nf_conntrack_max = 1000000 net.ipv4.netfilter.ip_conntrack_max = 1000000 net.ipv4.tcp_max_syn_backlog = 65535 net.ipv4.tcp_max_tw_buckets = 7200000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 15

Apply the settings immediately:

sysctl -p

3Step 3: Database & Service Optimization

Unlike Xtream UI, XUI.ONE is self-contained. However, restarting the service after applying kernel updates ensures the application binds to the new limits.

Restart the XUI service:

systemctl restart xui # OR service xui restart

Pro Tip: If you are running a Main server and Load Balancers, apply Step 1 and Step 2 to all servers, not just the Main. Load Balancers handle the actual traffic and benefit most from the network stack tuning.

4Step 4: Verify Results

Check your new limits to ensure they are active:

ulimit -n

It should return 1000000. Monitor your CPU usage using htop. You should see a significant reduction in "System" (red) CPU usage, which indicates the kernel is handling networking packets much more efficiently.