CLOUD
Guides

Server Resource Optimization: 8 Effective Techniques

CLOUD|January 14, 2026|3 min read|459 views
Server Resource Optimization: 8 Effective Techniques

PHP-FPM tuning, MySQL query cache, Nginx worker processes — 8 optimizations that boost server performance without upgrading.

Why Server Resource Optimization Matters

A high-spec server does not automatically mean high performance. Many servers operate at only 30-40% efficiency due to unoptimized default configurations. Resource optimization means better performance at the same cost — or the same performance at lower cost.

Analyzing Current Usage

Before any optimization, understand your current situation:

CPU Monitoring

# Current CPU usage
top -bn1 | head -20

# Load average
uptime

# Most CPU-intensive processes
ps aux --sort=-%cpu | head -10

Load Average Rule: If consistently higher than the number of CPU cores, you have a problem. A 4-core server with load average exceeding 4.0 means the server is overloaded.

Memory Monitoring (RAM)

# Memory usage
free -h

# Detailed memory info
cat /proc/meminfo | head -20

# Most memory-intensive processes
ps aux --sort=-%mem | head -10

Disk I/O Monitoring

# Disk space
df -h

# Read/write speeds
iostat -x 5 3

# Largest files and directories
du -sh /* | sort -rh | head -10

MySQL/MariaDB Optimization

Databases are usually the biggest resource consumer:

# Config file: /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
# InnoDB buffer — allocate 70% of available RAM
innodb_buffer_pool_size = 2G

# Log file size
innodb_log_file_size = 512M

# Concurrent connections
max_connections = 150

# Query cache (MySQL 5.7 only)
query_cache_size = 64M
query_cache_type = 1

# Temporary table optimization
tmp_table_size = 64M
max_heap_table_size = 64M

# Open table cache
table_open_cache = 4000
table_definition_cache = 2000

# Slow query logging
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2

After modifications:

sudo systemctl restart mysql
# Verify status
sudo mysqladmin status

Slow Query Optimization

# Analyze slow query log
mysqldumpslow -t 10 /var/log/mysql/slow.log

# Inside MySQL — analyze a specific query
EXPLAIN SELECT * FROM orders WHERE status = 'pending';

# Add an index
ALTER TABLE orders ADD INDEX idx_status (status);

PHP-FPM Optimization

# File: /etc/php/8.3/fpm/pool.d/www.conf

[www]
; Process management
pm = dynamic
pm.max_children = 30
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 10
pm.max_requests = 500

; Calculating pm.max_children:
; Available RAM for PHP / average memory per process
; Example: 2048MB / 64MB = 32 processes

OPcache Optimization

# File: /etc/php/8.3/fpm/conf.d/10-opcache.ini

opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

nginx Optimization

# File: /etc/nginx/nginx.conf

worker_processes auto;
worker_rlimit_nofile 65535;

events {
 worker_connections 4096;
 multi_accept on;
 use epoll;
}

http {
 # Compression
 gzip on;
 gzip_comp_level 5;
 gzip_min_length 256;
 gzip_types text/plain text/css application/json application/javascript text/xml;

 # Static file cache
 open_file_cache max=10000 inactive=30s;
 open_file_cache_valid 60s;
 open_file_cache_min_uses 2;

 # Buffers
 client_body_buffer_size 16k;
 client_header_buffer_size 1k;
 large_client_header_buffers 4 16k;

 # Timeouts
 client_body_timeout 12;
 client_header_timeout 12;
 keepalive_timeout 15;
 send_timeout 10;
}

Linux Kernel Tuning

# File: /etc/sysctl.conf

# Network
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1

# Memory
vm.swappiness = 10
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5

# Files
fs.file-max = 2097152

Apply changes:

sudo sysctl -p

Periodic Monitoring Schedule

Task Frequency Tool
Check Load Average Daily uptime, htop
Review RAM usage Weekly free -h
Analyze Slow Queries Weekly mysqldumpslow
Check disk space Weekly df -h, ncdu
Review logs Weekly journalctl, logrotate
System updates Monthly apt update && apt upgrade

CLOUD Servers and Optimization

CLOUD (cloud.net.sa) servers are built on fast SSD storage with 8ms network latency from Riyadh. But even the best hardware needs proper configuration. Apply the optimizations above and extract maximum performance from your server.

Need more resources? With CLOUD, you can upgrade CPU, RAM, or storage at any time without downtime — paying only the difference for the remaining period.


Get Started

Want to try it yourself? Choose the right hosting plan or build your custom server with the specs you need.

Share