UnderHost
Knowledgebase Docs

Dedicated Server Optimization: Performance Tips

Optimize dedicated servers. CPU tuning, RAM management, disk I/O optimization, caching strategies, kernel parameters, monitoring, bottleneck identification.

On this page

Dedicated servers provide unlimited optimization opportunities. Unlike shared hosting, you control the entire stack: OS, kernel, services, resource allocation. Smart optimization can 2-5x your throughput, reduce costs through efficiency, and prevent bottlenecks before they impact users. This guide covers systematic dedicated server optimization.

Optimization Overview

Optimization principle:**

  • Measure first: Find bottlenecks before optimizing
  • Optimize one thing: Change one setting, measure impact
  • Monitor always: Track performance metrics continuously
  • Test staging first: Never change production without testing

Identify Bottlenecks

Common bottlenecks in order:**

BottleneckSymptomFix
Slow queriesMySQL 100% CPUOptimize SQL, add indexes
Memory exhaustionSwap usage > 20%Reduce workers, enable caching
Disk I/OHigh iowait, slow readsEnable caching, SSD upgrade
Network saturationBandwidth at limitCompress, CDN, scale out
CPU limitLoad constantly > coresOptimize code, scale out

Diagnostic commands:**

# What's using CPU?
top -b -n 1 | head -20

# What's using memory?
ps aux --sort=-%mem | head -5

# Disk I/O performance
iostat -x 1 5

# Network bandwidth
iftop -n

# MySQL slow queries
mysql -e "SHOW PROCESSLIST;"

CPU Optimization

CPU governor (frequency scaling):**

# Set CPU governor to performance (max speed)
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# Verify
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Process affinity (pin processes to cores):**

# Run Apache on specific cores
taskset -c 0-3 systemctl start apache2

# Nginx workers on specific cores (nginx.conf)
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000;

Disable unnecessary services:**

# List running services
systemctl list-units --type=service

# Disable unused services (reduce idle load)
systemctl disable bluetooth cups avahi-daemon

Memory Optimization

Reduce memory usage:**

# Reduce Apache workers (uses less RAM)
# In /etc/apache2/mods-enabled/mpm_prefork.conf
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 20

# Reduce MySQL buffer (free up RAM)
innodb_buffer_pool_size = 1G  # from 4G

Increase available memory:**

# Add swap (safety net, not as fast as RAM)
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

# Make permanent (in /etc/fstab)
/swapfile none swap sw 0 0

Disk I/O Optimization

Identify slow I/O:**

# Watch disk activity
iostat -xd 1 5

# Show which process is reading/writing
iotop -b -n 1

Enable write caching:**

# Check current setting
cat /sys/block/sda/queue/scheduler

# Change to noop or deadline (faster for SSD)
echo deadline | sudo tee /sys/block/sda/queue/scheduler

Mount options optimization:**

# In /etc/fstab (for EXT4)
/dev/sda1 / ext4 defaults,noatime,discard 0 1
#                        ^^^^^^^^ skip atime updates (faster)
#                                 ^^^^^^^^ TRIM support for SSD

Network Tuning

TCP buffer tuning (for high-throughput):**

# In /etc/sysctl.conf
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864

# Apply
sysctl -p

Increase connection queue:**

net.core.netdev_max_backlog = 5000
net.ipv4.tcp_max_syn_backlog = 5000

Caching Strategies

Redis caching (10-100x faster than queries):**

apt install redis-server
systemctl enable redis-server
systemctl start redis-server

# Configure in WordPress/Laravel/Django
REDIS_HOST=127.0.0.1
REDIS_PORT=6379

Page caching (WordPress W3 Total Cache):**

  • Install plugin
  • Enable page caching (disk or memory)
  • Cache static assets for 1 month
  • Purge on post updates

Continuous Monitoring

Real-time monitoring dashboard:**

# Install Htop (top replacement)
apt install htop
htop

# Install Iotop (disk I/O monitoring)
apt install iotop
sudo iotop

# Install nethogs (network per-process)
apt install nethogs
sudo nethogs

Setup automated monitoring:**

# Install Prometheus + Grafana
# Prometheus: metrics collection
# Grafana: visualization dashboards

# Or use simpler tools:
apt install collectd rrdtool
# Then graph with rrdtool

Alert on performance degration:**

  • CPU > 80% for 5 minutes → alert
  • Memory > 85% → alert
  • Disk I/O wait > 50% → alert
  • Network > 80% bandwidth → alert
Optimization is iterative—measure, change, measure, repeat

Don't over-optimize based on guesses. Measure bottlenecks first, optimize the biggest one, re-measure, repeat. Small optimizations compound into massive gains.

Related: Performance tuning | Resource monitoring | Bottleneck analysis | Kernel tuning

Was this article helpful?

Need a dedicated server?

Compare UnderHost dedicated servers for high-traffic sites, custom stacks, isolation, and hardware-level performance.

Back to Dedicated Servers