The Usual Suspects
Most "mystery" RAM spikes in Xtream UI are caused by one of four things: bloated database log tables, an oversized MariaDB buffer pool, PHP-FPM workers not recycling, or uncapped Redis instances. This guide addresses each one.
1Step 1: Safety & Diagnosis
Before deleting anything, take a database backup. If you make a mistake, you can restore it.
Next, identify what is actually eating your RAM. Don't guess.
Look for mariadbd (Database), php-fpm (Web Workers), or ffmpeg.
2Step 2: Clean Bloated Log Tables
Xtream UI accumulates massive logs. Clearing these is often the fastest win for performance.
Option A: Aggressive Cleanup (Truncate)
Warning: This deletes all historical logs.
Option B: Gentle Cleanup (Delete old rows)
Keeps recent data (e.g., last 3 days).
3Step 3: Tune MariaDB Memory
By default, MariaDB might try to use too much RAM for caching (InnoDB Buffer Pool). On a server running everything (Main + Streams), this starves other processes.
Edit your MariaDB config:
Find [mysqld] and set a sane value. For example, on a 16GB server, limit it to 2GB:
Restart MariaDB: systemctl restart mariadb
4Step 4: Tune PHP-FPM
PHP workers can "leak" memory over time. We need to force them to recycle.
Edit your pool config (e.g., /etc/php/7.4/fpm/pool.d/www.conf):
This restarts every worker after 500 requests, freeing up any accumulated memory.
5Step 5: Cap Redis Memory
If you use Redis, it can grow indefinitely. Set a hard limit.
Add or uncomment:
Restart Redis: systemctl restart redis
6Step 6: Add Swap (Safety Net)
Swap acts as an overflow buffer. It prevents your server from crashing hard (OOM Kill) if RAM runs out momentarily.
7Step 7: Validation
After applying these fixes, monitor your server. Run free -h to check memory usage and ensure Swap is active but barely used. If RAM still climbs over days, consider lowering pm.max_children or the innodb_buffer_pool_size further.
