+
terraform
+
+
<=
mxnet
+
+
torch
tls
+
py
d
+
cosmos
+
+
+
+
+
+
+
css
dynamo
node
backbone
swc
android
istio
@
+
cypress
sqlite
circle
mongo
+
jwt
+
npm
+
go
+
groovy
+
erlang
%
laravel
+
cypress
stimulus
neo4j
+
@
+
+
+
java
dart
influxdb
+
+
eclipse
+
helm
+
+
gradle
matplotlib
yaml
phpstorm
+
quarkus
+
+
+
+
&
+
+
[]
+
+
nim
saml
graphdb
+
+
Back to Blog
⚡ AlmaLinux Performance Tuning: Complete Optimization Guide
almalinux performance tuning

⚡ AlmaLinux Performance Tuning: Complete Optimization Guide

Published Sep 17, 2025

Master AlmaLinux performance optimization! Complete guide to system tuning, memory management, CPU optimization, and disk I/O improvements. Perfect for maximizing your Linux system performance.

32 min read
0 views
Table of Contents

⚡ AlmaLinux Performance Tuning: Complete Optimization Guide

Ready to unleash your AlmaLinux system’s full potential? 🚀 Performance tuning transforms sluggish systems into blazing-fast powerhouses! Whether you’re running a web server, database, or workstation, proper optimization can double or triple your performance. This comprehensive guide covers everything from kernel parameters to application-specific tuning. Let’s make your system fly! ⚡

🤔 Why Performance Tuning is Crucial?

Performance optimization is the difference between good and great! 🌟 Here’s why it matters:

  • Speed Increase: 2-5x performance improvements possible
  • 💰 Cost Savings: Get more from existing hardware
  • 🎯 User Experience: Faster response times delight users
  • 📈 Scalability: Handle more load with same resources
  • 🔋 Energy Efficiency: Reduce power consumption
  • 🛡️ Stability: Well-tuned systems are more reliable
  • 💼 Competitive Edge: Outperform competitors
  • 🎓 Learning: Deep understanding of system internals

Properly tuned systems can handle 300% more load! 🏆

🎯 What You Need

Let’s prepare for performance mastery! ✅

  • ✅ AlmaLinux system with root or sudo access
  • ✅ Baseline performance measurements
  • ✅ Understanding of your workload requirements
  • ✅ Monitoring tools for before/after comparisons
  • ✅ 60 minutes to implement comprehensive optimizations
  • ✅ Patience for testing and measurement
  • ✅ Backup plan to revert changes if needed
  • ✅ Excitement to see dramatic improvements! 🎉

Let’s optimize everything for maximum performance! 🌍

📝 Step 1: System Performance Assessment

Establish baseline performance metrics! 🎯

Performance Benchmarking:

# Install benchmarking tools:
sudo dnf install -y sysstat iotop htop stress sysbench

# CPU Performance Baseline:
# 1. CPU information and capabilities
lscpu
cat /proc/cpuinfo | grep -E "processor|model name|cpu MHz|cache size" | head -20

# 2. CPU stress test
stress --cpu $(nproc) --timeout 60s &
# Monitor during test:
top -d 1

# 3. CPU benchmark
sysbench cpu --cpu-max-prime=20000 --threads=$(nproc) run

# 4. Context switching performance
vmstat 1 10   # Monitor context switches (cs column)

# Memory Performance Baseline:
# 1. Memory information
free -h
cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable|Cached|Buffers"

# 2. Memory bandwidth test
sysbench memory --memory-total-size=10G --memory-oper=read run
sysbench memory --memory-total-size=10G --memory-oper=write run

# 3. Memory latency test
lat_mem_rd -P 1 -W 1 1024 64   # If lmbench installed

# Disk I/O Performance Baseline:
# 1. Disk information
lsblk
df -h
cat /proc/mounts | grep -v tmpfs

# 2. Sequential read/write test
dd if=/dev/zero of=/tmp/testfile bs=1G count=1 oflag=dsync
dd if=/tmp/testfile of=/dev/null bs=1G count=1

# 3. Random I/O test
sysbench fileio --file-total-size=5G prepare
sysbench fileio --file-total-size=5G --file-test-mode=rndrw --time=60 run
sysbench fileio cleanup

# Network Performance Baseline:
# 1. Network interface information
ip link show
ethtool eth0   # Interface capabilities

# 2. Network throughput test (requires iperf3 on both ends)
# Server: iperf3 -s
# Client: iperf3 -c server_ip -t 60

# 3. Network latency test
ping -c 100 8.8.8.8 | tail -1

Performance Monitoring Setup:

# Create performance monitoring script:
cat > ~/performance-baseline.sh << 'EOF'
#!/bin/bash

REPORT_FILE="/tmp/performance-baseline-$(date +%Y%m%d-%H%M%S).txt"

echo "=== AlmaLinux Performance Baseline Report ===" > "$REPORT_FILE"
echo "Generated: $(date)" >> "$REPORT_FILE"
echo "Hostname: $(hostname)" >> "$REPORT_FILE"
echo "Kernel: $(uname -r)" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# System Information
echo "=== SYSTEM INFORMATION ===" >> "$REPORT_FILE"
lscpu | grep -E "Architecture|CPU|Thread|Core|Socket|Model name|CPU MHz|BogoMIPS|Cache" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# Memory Information
echo "=== MEMORY INFORMATION ===" >> "$REPORT_FILE"
free -h >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
dmidecode -t memory | grep -E "Size|Speed|Type|Manufacturer" >> "$REPORT_FILE" 2>/dev/null
echo "" >> "$REPORT_FILE"

# Storage Information
echo "=== STORAGE INFORMATION ===" >> "$REPORT_FILE"
lsblk >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
df -h >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# Current Performance
echo "=== CURRENT PERFORMANCE ===" >> "$REPORT_FILE"
uptime >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
iostat -x 1 3 >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
vmstat 1 5 >> "$REPORT_FILE"

echo "Baseline report saved to: $REPORT_FILE"
EOF

chmod +x ~/performance-baseline.sh
~/performance-baseline.sh

Perfect! 🎉 Performance baseline established!

🔧 Step 2: Kernel and System Optimization

Optimize core system parameters! 📦

Kernel Parameter Tuning (sysctl):

# Create optimized sysctl configuration:
cat | sudo tee /etc/sysctl.d/99-performance-tuning.conf << 'EOF'
# AlmaLinux Performance Tuning Configuration

# === VIRTUAL MEMORY SUBSYSTEM ===
# Reduce swappiness (prefer RAM over swap)
vm.swappiness = 10

# Increase dirty page cache size for better I/O performance
vm.dirty_ratio = 20
vm.dirty_background_ratio = 5

# Increase memory map areas for applications
vm.max_map_count = 262144

# Optimize memory overcommit
vm.overcommit_memory = 1
vm.overcommit_ratio = 50

# === NETWORK PERFORMANCE ===
# Increase network buffer sizes
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.core.rmem_default = 65536
net.core.wmem_default = 65536

# TCP buffer sizes (min, default, max)
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728

# TCP congestion control algorithm
net.ipv4.tcp_congestion_control = bbr

# Enable TCP window scaling
net.ipv4.tcp_window_scaling = 1

# TCP Fast Open
net.ipv4.tcp_fastopen = 3

# Increase connection backlog
net.core.netdev_max_backlog = 5000
net.core.somaxconn = 65535

# TCP keepalive settings
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 90

# === FILE SYSTEM PERFORMANCE ===
# Increase file handles
fs.file-max = 2097152

# Inotify limits
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 512

# === KERNEL PERFORMANCE ===
# Scheduler performance
kernel.sched_migration_cost_ns = 5000000
kernel.sched_autogroup_enabled = 0

# Process limits
kernel.pid_max = 4194304
kernel.threads-max = 4194304

# === SECURITY VS PERFORMANCE ===
# Disable address space randomization for performance (less secure)
# kernel.randomize_va_space = 0

# Reduce dmesg noise
kernel.printk = 3 4 1 3
EOF

# Apply immediately:
sudo sysctl -p /etc/sysctl.d/99-performance-tuning.conf

# Verify settings:
sysctl vm.swappiness
sysctl net.ipv4.tcp_congestion_control
sysctl net.core.rmem_max

CPU Performance Optimization:

# 1. CPU Governor Configuration
# Check current governor:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Set performance governor:
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# Make permanent:
sudo dnf install kernel-tools
cat | sudo tee /etc/default/cpupower << 'EOF'
# CPU governor settings
CPUPOWER_START_OPTS="frequency-set -g performance"
CPUPOWER_STOP_OPTS="frequency-set -g ondemand"
EOF

sudo systemctl enable cpupower

# 2. CPU Affinity and NUMA Optimization
# Check NUMA topology:
numactl --hardware
lscpu | grep NUMA

# Example: Bind process to specific CPU
taskset -c 0-3 command    # Use CPUs 0-3
numactl --cpubind=0 --membind=0 command  # Use NUMA node 0

# 3. IRQ Balancing
# Install irqbalance:
sudo dnf install irqbalance
sudo systemctl enable --now irqbalance

# Check IRQ distribution:
cat /proc/interrupts

# Manual IRQ affinity (if needed):
echo 1 | sudo tee /proc/irq/24/smp_affinity  # Bind IRQ 24 to CPU 0

# 4. Transparent Huge Pages
# Check current setting:
cat /sys/kernel/mm/transparent_hugepage/enabled

# Disable for database workloads:
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/defrag

# Make permanent:
cat | sudo tee /etc/tmpfiles.d/hugepages.conf << 'EOF'
w /sys/kernel/mm/transparent_hugepage/enabled - - - - never
w /sys/kernel/mm/transparent_hugepage/defrag - - - - never
EOF

Memory Optimization:

# 1. Memory Allocation Tuning
# Configure memory zones:
echo 1 | sudo tee /proc/sys/vm/zone_reclaim_mode

# 2. Huge Pages Configuration (for databases)
# Calculate huge pages needed (example for 8GB):
HUGEPAGE_SIZE=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
PAGES_NEEDED=$((8*1024*1024/$HUGEPAGE_SIZE))

# Set huge pages:
echo $PAGES_NEEDED | sudo tee /proc/sys/vm/nr_hugepages

# Make permanent:
echo "vm.nr_hugepages = $PAGES_NEEDED" | sudo tee -a /etc/sysctl.d/99-hugepages.conf

# 3. NUMA Memory Policy
# Check NUMA memory usage:
numastat

# Set NUMA policy for applications:
numactl --preferred=0 command   # Prefer NUMA node 0

# 4. Memory Compaction
# Enable automatic memory compaction:
echo 1 | sudo tee /proc/sys/vm/compact_memory

# 5. Memory Cgroup Optimization
# Create memory cgroup for critical applications:
sudo mkdir /sys/fs/cgroup/memory/critical
echo $((16*1024*1024*1024)) | sudo tee /sys/fs/cgroup/memory/critical/memory.limit_in_bytes

Amazing! 🌟 Kernel and system optimization complete!

🌟 Step 3: Storage and I/O Optimization

Maximize disk performance! ⚡

Disk I/O Scheduler Optimization:

# 1. Check current I/O scheduler:
cat /sys/block/sda/queue/scheduler

# 2. Optimize schedulers by disk type:
# For SSDs (use noop or none):
echo none | sudo tee /sys/block/nvme0n1/queue/scheduler
# For traditional HDDs (use deadline or mq-deadline):
echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler

# 3. Make permanent:
cat | sudo tee /etc/udev/rules.d/60-ioschedulers.conf << 'EOF'
# Set I/O scheduler based on drive type
# SSDs use none, HDDs use mq-deadline
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="mq-deadline"
ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"
EOF

# 4. Optimize I/O queue depth:
echo 32 | sudo tee /sys/block/sda/queue/nr_requests

# 5. Disable disk read-ahead for random I/O workloads:
blockdev --setra 256 /dev/sda  # Reduce read-ahead

File System Optimization:

# 1. Mount Options for Performance
# Create optimized fstab entries:
cat | sudo tee -a /etc/fstab << 'EOF'
# Performance-optimized mount options
# For ext4 filesystems:
/dev/sda1 /data ext4 defaults,noatime,nodiratime,data=writeback,barrier=0,nobh 0 2

# For XFS filesystems:
/dev/sdb1 /logs xfs defaults,noatime,nodiratime,logbufs=8,logbsize=256k,largeio,inode64 0 2
EOF

# 2. Ext4 Optimization
# Optimize existing ext4 filesystem:
sudo tune2fs -o journal_data_writeback /dev/sda1
sudo tune2fs -O ^has_journal /dev/sda1    # Remove journal for read-heavy workloads
sudo e2fsck -f /dev/sda1                  # Check filesystem after journal removal

# 3. XFS Optimization
# Format XFS with performance options:
sudo mkfs.xfs -f -d agcount=4 -l logdev=/dev/sdc1,size=256m /dev/sdb1

# 4. Disable access time updates globally:
cat | sudo tee /etc/tmpfiles.d/noatime.conf << 'EOF'
# Mount all filesystems with noatime
f /etc/fstab - - - - defaults,noatime
EOF

# 5. File System Caching
# Increase buffer cache:
echo 'vm.vfs_cache_pressure = 50' | sudo tee -a /etc/sysctl.d/99-performance-tuning.conf

# 6. Tmpfs for Temporary Files
# Mount /tmp in RAM:
echo 'tmpfs /tmp tmpfs defaults,nodev,nosuid,size=2G 0 0' | sudo tee -a /etc/fstab

RAID and LVM Optimization:

# 1. RAID Performance Tuning
# Check RAID status:
cat /proc/mdstat

# Optimize RAID read-ahead:
sudo blockdev --setra 65536 /dev/md0

# Set optimal stripe cache size:
echo 8192 | sudo tee /sys/block/md0/md/stripe_cache_size

# 2. LVM Performance Optimization
# Create performance-optimized LV:
sudo lvcreate -L 100G -n data_lv volume_group \
    --stripes 4 --stripesize 256k

# Optimize LVM metadata:
cat | sudo tee -a /etc/lvm/lvm.conf << 'EOF'
devices {
    # Optimize device scanning
    scan = [ "/dev/disk/by-id", "/dev/mapper", "/dev" ]
    write_cache_state = 0
}
allocation {
    # Optimize allocation
    cling_tag_list = [ "@*" ]
}
EOF

# 3. SSD Optimization
# Enable TRIM for SSDs:
sudo systemctl enable fstrim.timer

# Manual TRIM:
sudo fstrim -av

# Check SSD health:
sudo smartctl -a /dev/nvme0n1 | grep -E "Temperature|Wear_Leveling|Reallocated"

Excellent! ⚡ Storage optimization implemented!

✅ Step 4: Application-Specific Tuning

Optimize common applications! 🔧

Web Server Optimization (Nginx):

# 1. Nginx Performance Configuration
cat | sudo tee /etc/nginx/conf.d/performance.conf << 'EOF'
# Nginx Performance Optimization

# Worker processes (usually = CPU cores)
worker_processes auto;
worker_cpu_affinity auto;

# Worker connections
events {
    worker_connections 8192;
    use epoll;
    multi_accept on;
}

# Main configuration
http {
    # Enable sendfile
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    # Keepalive settings
    keepalive_timeout 30;
    keepalive_requests 1000;

    # Buffer sizes
    client_body_buffer_size 128k;
    client_max_body_size 10m;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;
    output_buffers 1 32k;
    postpone_output 1460;

    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_types
        text/plain
        text/css
        text/xml
        text/javascript
        application/json
        application/javascript
        application/xml+rss
        application/atom+xml
        image/svg+xml;

    # Caching
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    # Rate limiting
    limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
}
EOF

# 2. System limits for web server:
cat | sudo tee /etc/security/limits.d/nginx.conf << 'EOF'
nginx soft nofile 65535
nginx hard nofile 65535
nginx soft nproc 65535
nginx hard nproc 65535
EOF

# 3. Nginx worker optimization:
sudo systemctl edit nginx
# Add:
[Service]
LimitNOFILE=65535
LimitNPROC=65535

Database Optimization (MySQL/MariaDB):

# 1. MySQL Performance Configuration
cat | sudo tee /etc/my.cnf.d/performance.cnf << 'EOF'
[mysqld]
# === GENERAL PERFORMANCE ===
# Buffer pool (70-80% of available RAM for dedicated DB server)
innodb_buffer_pool_size = 12G
innodb_buffer_pool_instances = 12

# Query cache (disable in MySQL 5.7+)
query_cache_size = 0
query_cache_type = 0

# === CONNECTION OPTIMIZATION ===
max_connections = 500
max_connect_errors = 1000000
max_user_connections = 450
thread_cache_size = 50

# === INNODB OPTIMIZATION ===
innodb_log_file_size = 1G
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_open_files = 65535

# I/O optimization
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_read_io_threads = 8
innodb_write_io_threads = 8

# === BINARY LOGGING ===
log_bin = mysql-bin
sync_binlog = 0
expire_logs_days = 7

# === QUERY OPTIMIZATION ===
tmp_table_size = 256M
max_heap_table_size = 256M
sort_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
join_buffer_size = 8M

# === MYISAM OPTIMIZATION ===
key_buffer_size = 256M
table_open_cache = 4000
table_definition_cache = 2000
EOF

# 2. Operating system limits for MySQL:
cat | sudo tee /etc/security/limits.d/mysql.conf << 'EOF'
mysql soft nofile 65535
mysql hard nofile 65535
mysql soft nproc 65535
mysql hard nproc 65535
mysql soft memlock unlimited
mysql hard memlock unlimited
EOF

# 3. MySQL systemd optimization:
sudo systemctl edit mysql
# Add:
[Service]
LimitNOFILE=65535
LimitNPROC=65535
LimitMEMLOCK=infinity

Redis Optimization:

# 1. Redis Performance Configuration
cat | sudo tee /etc/redis/redis-performance.conf << 'EOF'
# Redis Performance Configuration

# Memory optimization
maxmemory 8gb
maxmemory-policy allkeys-lru

# Persistence optimization
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error no
rdbcompression yes
rdbchecksum yes

# Network optimization
tcp-keepalive 60
tcp-backlog 511
timeout 0

# Client optimization
maxclients 10000

# Background operations
hz 10

# Disable expensive operations in production
rename-command FLUSHDB ""
rename-command FLUSHALL ""
rename-command DEBUG ""
rename-command CONFIG ""
EOF

# 2. Redis system optimization:
# Disable THP for Redis:
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled

# Set overcommit memory:
echo 1 | sudo tee /proc/sys/vm/overcommit_memory

# Increase somaxconn:
echo 65535 | sudo tee /proc/sys/net/core/somaxconn

Java Application Optimization:

# 1. JVM Performance Tuning
cat | sudo tee /opt/app/jvm-performance.conf << 'EOF'
# JVM Performance Options

# Heap size (adjust based on available memory)
-Xms4g
-Xmx8g

# Garbage collection optimization
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:G1HeapRegionSize=16m
-XX:+UseStringDeduplication

# Performance optimizations
-XX:+UseFastAccessorMethods
-XX:+AggressiveOpts
-XX:+UseBiasedLocking

# Memory optimization
-XX:+UseCompressedOops
-XX:+UseCompressedClassPointers

# Monitoring and debugging
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:/var/log/app/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=10M

# Network stack optimization
-Djava.net.preferIPv4Stack=true
-Dsun.net.inetaddr.ttl=60

# JIT compilation
-XX:+TieredCompilation
-XX:TieredStopAtLevel=4
EOF

Perfect! 🏆 Application-specific optimization complete!

🎮 Quick Examples

Real-world performance tuning scenarios! 🎯

Example 1: High-Performance Web Server Setup

#!/bin/bash
# Complete web server performance optimization

echo "Optimizing web server performance..."

# 1. System-level optimizations
cat | sudo tee /etc/sysctl.d/99-webserver.conf << 'EOF'
# Web server specific optimizations
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

# File descriptor limits
fs.file-max = 2097152

# Virtual memory
vm.swappiness = 1
vm.dirty_ratio = 80
vm.dirty_background_ratio = 5
EOF

sudo sysctl -p /etc/sysctl.d/99-webserver.conf

# 2. Nginx high-performance configuration
cat | sudo tee /etc/nginx/nginx.conf << 'EOF'
user nginx;
worker_processes auto;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

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

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Logging
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

    # Basic settings
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 30;
    keepalive_requests 1000;
    reset_timedout_connection on;
    client_body_timeout 10;
    send_timeout 2;

    # Buffer settings
    client_header_buffer_size 1k;
    client_body_buffer_size 128k;
    large_client_header_buffers 4 4k;

    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types
        text/plain
        text/css
        text/xml
        text/javascript
        application/json
        application/javascript
        application/xml+rss
        application/atom+xml;

    # File caching
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    # Rate limiting
    limit_req_zone $binary_remote_addr zone=login:10m rate=10r/m;
    limit_req_zone $binary_remote_addr zone=api:10m rate=100r/s;

    include /etc/nginx/conf.d/*.conf;
}
EOF

# 3. SSL/TLS optimization
cat | sudo tee /etc/nginx/conf.d/ssl-performance.conf << 'EOF'
# SSL performance optimization
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;

# Modern ciphers only
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;

# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;
EOF

# 4. Static content optimization
cat | sudo tee /etc/nginx/conf.d/static-content.conf << 'EOF'
# Static content serving optimization
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
    add_header Vary Accept-Encoding;
    access_log off;

    # Enable compression for static files
    gzip_static on;
}

# Enable Brotli compression if available
location ~* \.(js|css|html|xml)$ {
    brotli on;
    brotli_comp_level 6;
    brotli_types text/plain text/css application/json application/javascript;
}
EOF

# 5. System limits
cat | sudo tee /etc/security/limits.d/nginx.conf << 'EOF'
nginx soft nofile 65535
nginx hard nofile 65535
nginx soft nproc 65535
nginx hard nproc 65535
EOF

# 6. Systemd service optimization
sudo mkdir -p /etc/systemd/system/nginx.service.d
cat | sudo tee /etc/systemd/system/nginx.service.d/limits.conf << 'EOF'
[Service]
LimitNOFILE=65535
LimitNPROC=65535
LimitCORE=infinity
EOF

sudo systemctl daemon-reload
sudo systemctl restart nginx

echo "Web server optimization complete!"
echo "Test with: ab -n 10000 -c 100 http://localhost/"

Example 2: Database Server Performance Tuning

#!/bin/bash
# High-performance database server optimization

echo "Optimizing database server..."

# 1. Calculate optimal settings based on system memory
TOTAL_RAM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
TOTAL_RAM_GB=$((TOTAL_RAM / 1024 / 1024))
BUFFER_POOL_SIZE=$((TOTAL_RAM_GB * 70 / 100))  # 70% of RAM
INSTANCES=$((BUFFER_POOL_SIZE / 1))  # 1 instance per GB

echo "Detected ${TOTAL_RAM_GB}GB RAM, configuring buffer pool: ${BUFFER_POOL_SIZE}GB"

# 2. MySQL/MariaDB optimization
cat | sudo tee /etc/my.cnf.d/performance-tuning.cnf << EOF
[mysqld]
# === MEMORY CONFIGURATION ===
innodb_buffer_pool_size = ${BUFFER_POOL_SIZE}G
innodb_buffer_pool_instances = $INSTANCES
innodb_log_buffer_size = 64M

# === CONNECTION OPTIMIZATION ===
max_connections = 1000
max_user_connections = 950
thread_cache_size = 100
table_open_cache = 10000
table_definition_cache = 4000

# === INNODB PERFORMANCE ===
innodb_log_file_size = 2G
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_lru_scan_depth = 2048

# === QUERY OPTIMIZATION ===
tmp_table_size = 512M
max_heap_table_size = 512M
sort_buffer_size = 8M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
join_buffer_size = 16M

# === BINARY LOGGING ===
log_bin = mysql-bin
sync_binlog = 0
binlog_cache_size = 32M
max_binlog_cache_size = 512M
expire_logs_days = 3

# === QUERY CACHE (disable for MySQL 5.7+) ===
query_cache_type = 0
query_cache_size = 0

# === MISCELLANEOUS ===
skip_name_resolve = 1
default_storage_engine = InnoDB
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO

# === PERFORMANCE SCHEMA ===
performance_schema = ON
performance_schema_max_table_instances = 12500
performance_schema_max_table_handles = 4000
EOF

# 3. System optimizations for database
cat | sudo tee /etc/sysctl.d/99-database.conf << 'EOF'
# Database server optimizations
vm.swappiness = 1
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5

# Memory overcommit
vm.overcommit_memory = 0

# File descriptor limits
fs.file-max = 2097152

# Network optimization for database replication
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728
EOF

sudo sysctl -p /etc/sysctl.d/99-database.conf

# 4. Huge pages for large buffer pools
if [ $BUFFER_POOL_SIZE -gt 4 ]; then
    HUGEPAGE_SIZE=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
    PAGES_NEEDED=$(($BUFFER_POOL_SIZE * 1024 * 1024 / $HUGEPAGE_SIZE))

    echo "Configuring $PAGES_NEEDED huge pages"
    echo $PAGES_NEEDED | sudo tee /proc/sys/vm/nr_hugepages
    echo "vm.nr_hugepages = $PAGES_NEEDED" | sudo tee /etc/sysctl.d/99-hugepages.conf
fi

# 5. I/O scheduler optimization
cat | sudo tee /etc/udev/rules.d/60-database-ioschedulers.conf << 'EOF'
# Optimize I/O scheduler for database workloads
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="deadline"
ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"
EOF

# 6. Security limits
cat | sudo tee /etc/security/limits.d/mysql.conf << 'EOF'
mysql soft nofile 65535
mysql hard nofile 65535
mysql soft nproc 65535
mysql hard nproc 65535
mysql soft memlock unlimited
mysql hard memlock unlimited
EOF

# 7. Database monitoring script
cat > ~/database-performance-monitor.sh << 'EOF'
#!/bin/bash
# Database performance monitoring

mysql << SQL
SELECT
    'Buffer Pool Hit Ratio' as Metric,
    ROUND((1 - (Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests)) * 100, 2) as 'Value (%)'
FROM information_schema.global_status
WHERE variable_name IN ('Innodb_buffer_pool_reads', 'Innodb_buffer_pool_read_requests');

SELECT
    'Query Cache Hit Ratio' as Metric,
    ROUND((Qcache_hits / (Qcache_hits + Qcache_inserts)) * 100, 2) as 'Value (%)'
FROM information_schema.global_status
WHERE variable_name IN ('Qcache_hits', 'Qcache_inserts');

SELECT
    'Slow Queries' as Metric,
    Variable_value as 'Count'
FROM information_schema.global_status
WHERE Variable_name = 'Slow_queries';

SHOW ENGINE INNODB STATUS\G
SQL
EOF

chmod +x ~/database-performance-monitor.sh

echo "Database optimization complete!"
echo "Monitor with: ~/database-performance-monitor.sh"

Example 3: Application Server Optimization

#!/bin/bash
# Java application server performance tuning

echo "Optimizing Java application server..."

# 1. JVM performance configuration
TOTAL_RAM_MB=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024)}')
HEAP_SIZE_MB=$((TOTAL_RAM_MB * 60 / 100))  # 60% of system RAM
MAX_HEAP_MB=$((TOTAL_RAM_MB * 70 / 100))   # 70% maximum

cat | sudo tee /opt/app/conf/jvm-performance.conf << EOF
# JVM Performance Configuration
# Generated for system with ${TOTAL_RAM_MB}MB RAM

# === MEMORY SETTINGS ===
-Xms${HEAP_SIZE_MB}m
-Xmx${MAX_HEAP_MB}m
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=512m
-XX:CompressedClassSpaceSize=128m

# === GARBAGE COLLECTION ===
# Use G1GC for low latency
-XX:+UseG1GC
-XX:MaxGCPauseMillis=100
-XX:G1HeapRegionSize=16m
-XX:G1NewSizePercent=30
-XX:G1MaxNewSizePercent=40
-XX:G1MixedGCLiveThresholdPercent=85
-XX:+G1UseAdaptiveIHOP

# === PERFORMANCE OPTIMIZATIONS ===
-XX:+UseFastAccessorMethods
-XX:+UseStringDeduplication
-XX:+OptimizeStringConcat
-XX:+UseCompressedOops
-XX:+UseCompressedClassPointers
-XX:+TieredCompilation
-XX:TieredStopAtLevel=4

# === JIT COMPILATION ===
-XX:+AggressiveOpts
-XX:+UseBiasedLocking
-XX:BiasedLockingStartupDelay=0
-XX:+EliminateLocks
-XX:+DoEscapeAnalysis

# === MEMORY ALLOCATION ===
-XX:+UseTLAB
-XX:+ResizeTLAB
-XX:TLABSize=1m

# === MONITORING AND DEBUGGING ===
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/var/log/app/gc-%t.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=100M

# === CRASH DUMPS ===
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/var/log/app/heapdumps/

# === NETWORK OPTIMIZATION ===
-Djava.net.preferIPv4Stack=true
-Dsun.net.inetaddr.ttl=60
-Dsun.net.inetaddr.negative.ttl=10

# === RANDOM NUMBER GENERATION ===
-Djava.security.egd=file:/dev/./urandom

# === APPLICATION SPECIFIC ===
-server
-Dfile.encoding=UTF-8
-Duser.timezone=UTC
EOF

# 2. System optimizations for Java applications
cat | sudo tee /etc/sysctl.d/99-java-app.conf << 'EOF'
# Java application optimizations
vm.swappiness = 1
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
vm.overcommit_memory = 0

# Network optimizations
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 90

# File descriptor limits
fs.file-max = 2097152
EOF

sudo sysctl -p /etc/sysctl.d/99-java-app.conf

# 3. Security limits for application user
cat | sudo tee /etc/security/limits.d/app-user.conf << 'EOF'
appuser soft nofile 65535
appuser hard nofile 65535
appuser soft nproc 65535
appuser hard nproc 65535
appuser soft memlock unlimited
appuser hard memlock unlimited
EOF

# 4. Application performance monitoring script
cat > ~/app-performance-monitor.sh << 'EOF'
#!/bin/bash
# Java application performance monitoring

APP_PID=$(pgrep -f "java.*your-app")

if [ -n "$APP_PID" ]; then
    echo "=== Java Application Performance Monitor ==="
    echo "PID: $APP_PID"
    echo "Start Time: $(ps -o lstart= -p $APP_PID)"
    echo ""

    # Memory usage
    echo "=== Memory Usage ==="
    jstat -gc $APP_PID
    echo ""

    # GC performance
    echo "=== GC Performance ==="
    jstat -gcutil $APP_PID
    echo ""

    # Heap usage
    echo "=== Heap Usage ==="
    jmap -heap $APP_PID | grep -A 5 "Heap Configuration"
    echo ""

    # Thread dump (top 10 threads by CPU)
    echo "=== Top Threads ==="
    jstack $APP_PID | grep -A 2 "tid=" | head -30

else
    echo "Application not running"
fi
EOF

chmod +x ~/app-performance-monitor.sh

# 5. Systemd service optimization
cat | sudo tee /etc/systemd/system/app.service.d/performance.conf << 'EOF'
[Service]
# Resource limits
LimitNOFILE=65535
LimitNPROC=65535
LimitMEMLOCK=infinity

# CPU affinity (adjust based on your system)
CPUAffinity=0-7

# Priority
Nice=-10
IOSchedulingClass=1
IOSchedulingPriority=4

# Security
NoNewPrivileges=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectControlGroups=true
EOF

sudo systemctl daemon-reload

echo "Java application optimization complete!"
echo "Monitor with: ~/app-performance-monitor.sh"

Example 4: Complete System Performance Audit

#!/bin/bash
# Comprehensive system performance audit and optimization

echo "Performing complete system performance audit..."

# Create audit report
AUDIT_REPORT="/tmp/performance-audit-$(date +%Y%m%d-%H%M%S).txt"

cat > ~/performance-audit.sh << 'EOF'
#!/bin/bash

REPORT_FILE="/tmp/performance-audit-$(date +%Y%m%d-%H%M%S).txt"

echo "# AlmaLinux Performance Audit Report" > "$REPORT_FILE"
echo "Generated: $(date)" >> "$REPORT_FILE"
echo "System: $(hostname) ($(uname -r))" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# System Information
echo "## SYSTEM INFORMATION" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
lscpu >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
free -h >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
df -h >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# Performance Metrics
echo "## CURRENT PERFORMANCE" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
uptime >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
iostat -x 1 3 2>/dev/null >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
vmstat 1 5 >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"

# Configuration Audit
echo "## CONFIGURATION AUDIT" >> "$REPORT_FILE"

# Check CPU governor
echo "### CPU Governor" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"

# Check I/O schedulers
echo "### I/O Schedulers" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
for disk in $(lsblk -d -o NAME | tail -n +2); do
    echo "$disk: $(cat /sys/block/$disk/queue/scheduler 2>/dev/null)"
done >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"

# Check swap usage
echo "### Swap Configuration" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
swapon --show >> "$REPORT_FILE"
echo "Swappiness: $(cat /proc/sys/vm/swappiness)" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"

# Network configuration
echo "### Network Configuration" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
echo "TCP Congestion Control: $(sysctl net.ipv4.tcp_congestion_control | cut -d= -f2)" >> "$REPORT_FILE"
echo "TCP Window Scaling: $(sysctl net.ipv4.tcp_window_scaling | cut -d= -f2)" >> "$REPORT_FILE"
echo "Socket Buffer Max: $(sysctl net.core.rmem_max | cut -d= -f2)" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"

# Performance Issues Detection
echo "## PERFORMANCE ISSUES" >> "$REPORT_FILE"

# Check for high load
LOAD=$(uptime | awk -F'load average:' '{print $2}' | cut -d, -f1 | xargs)
CORES=$(nproc)
if (( $(echo "$LOAD > $CORES" | bc -l) )); then
    echo "⚠️ High system load: $LOAD (cores: $CORES)" >> "$REPORT_FILE"
fi

# Check for low memory
MEM_AVAIL=$(free | grep Mem | awk '{print $7/$2 * 100.0}')
if (( $(echo "$MEM_AVAIL < 20" | bc -l) )); then
    echo "⚠️ Low available memory: ${MEM_AVAIL}%" >> "$REPORT_FILE"
fi

# Check for high swap usage
SWAP_USED=$(free | grep Swap | awk '{if($2>0) print $3/$2 * 100.0; else print 0}')
if (( $(echo "$SWAP_USED > 50" | bc -l) )); then
    echo "⚠️ High swap usage: ${SWAP_USED}%" >> "$REPORT_FILE"
fi

# Optimization Recommendations
echo "## OPTIMIZATION RECOMMENDATIONS" >> "$REPORT_FILE"

# CPU Governor recommendation
GOVERNOR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null)
if [ "$GOVERNOR" != "performance" ]; then
    echo "- Set CPU governor to 'performance' for better performance" >> "$REPORT_FILE"
fi

# Swappiness recommendation
SWAPPINESS=$(cat /proc/sys/vm/swappiness)
if [ "$SWAPPINESS" -gt 10 ]; then
    echo "- Reduce swappiness to 10 or lower for server workloads" >> "$REPORT_FILE"
fi

# I/O scheduler recommendations
for disk in $(lsblk -d -o NAME | tail -n +2); do
    SCHEDULER=$(cat /sys/block/$disk/queue/scheduler 2>/dev/null | grep -o '\[.*\]' | tr -d '[]')
    ROTATIONAL=$(cat /sys/block/$disk/queue/rotational 2>/dev/null)

    if [ "$ROTATIONAL" = "0" ] && [ "$SCHEDULER" != "none" ]; then
        echo "- Set I/O scheduler to 'none' for SSD $disk" >> "$REPORT_FILE"
    elif [ "$ROTATIONAL" = "1" ] && [ "$SCHEDULER" != "mq-deadline" ]; then
        echo "- Set I/O scheduler to 'mq-deadline' for HDD $disk" >> "$REPORT_FILE"
    fi
done

echo "" >> "$REPORT_FILE"
echo "Report saved to: $REPORT_FILE"
echo "View with: cat $REPORT_FILE"
EOF

chmod +x ~/performance-audit.sh
~/performance-audit.sh

echo "Performance audit complete!"
echo "Run anytime with: ~/performance-audit.sh"

🚨 Fix Common Problems

Performance troubleshooting guide! 🔧

Problem 1: High CPU Usage and Load

Solution:

# Identify CPU bottlenecks:
# 1. Find CPU-intensive processes
top -bn1 | head -20
ps aux --sort=-%cpu | head -10

# 2. Check CPU frequency scaling
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# Set to performance:
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# 3. Analyze CPU usage patterns
sar -u 5 12  # CPU usage every 5 seconds for 1 minute
mpstat -P ALL 5  # Per-CPU statistics

# 4. Check for CPU throttling
grep -i "cpu clock throttled" /var/log/messages
# Check CPU temperature:
sensors | grep Core

# 5. Optimize CPU-bound processes
# Use nice/ionice to adjust priorities:
renice -10 $(pgrep important_process)
ionice -c 1 -n 4 $(pgrep important_process)

# 6. Enable CPU performance governor permanently:
sudo dnf install kernel-tools
sudo systemctl enable cpupower
echo 'CPUPOWER_START_OPTS="frequency-set -g performance"' | sudo tee /etc/default/cpupower

Problem 2: Memory Pressure and Swapping

Solution:

# Fix memory issues:
# 1. Identify memory hogs
ps aux --sort=-%mem | head -10
smem -r -k  # Install: sudo dnf install smem

# 2. Reduce swappiness
echo 1 | sudo tee /proc/sys/vm/swappiness
echo 'vm.swappiness = 1' | sudo tee -a /etc/sysctl.conf

# 3. Clear system caches
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

# 4. Optimize dirty pages
echo 15 | sudo tee /proc/sys/vm/dirty_ratio
echo 5 | sudo tee /proc/sys/vm/dirty_background_ratio

# 5. Check for memory leaks
# Monitor process over time:
while true; do
    ps aux | grep process_name | awk '{print $6}'
    sleep 60
done

# 6. Add more swap if needed
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# 7. Configure huge pages for large applications
HUGEPAGE_SIZE=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
PAGES_NEEDED=$((4*1024*1024/$HUGEPAGE_SIZE))  # 4GB
echo $PAGES_NEEDED | sudo tee /proc/sys/vm/nr_hugepages

Problem 3: Disk I/O Bottlenecks

Solution:

# Optimize disk performance:
# 1. Check I/O wait times
iostat -x 1 5
iotop -o  # Show only processes doing I/O

# 2. Optimize I/O scheduler
# For SSDs:
echo none | sudo tee /sys/block/nvme0n1/queue/scheduler
# For HDDs:
echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler

# 3. Increase read-ahead for sequential workloads
blockdev --setra 8192 /dev/sda

# 4. Mount with performance options
# Add to /etc/fstab:
# /dev/sda1 /data ext4 defaults,noatime,nodiratime 0 2

# 5. Enable write-back caching (if safe)
hdparm -W 1 /dev/sda

# 6. Optimize file system
# For ext4:
tune2fs -o journal_data_writeback /dev/sda1
# For XFS, remount with:
mount -o remount,noatime,nodiratime,logbufs=8 /dev/sda1

# 7. Check disk health
smartctl -H /dev/sda
smartctl -a /dev/sda | grep -E "Reallocated|Pending|Uncorrectable"

Problem 4: Network Performance Issues

Solution:

# Network optimization:
# 1. Test network performance
iperf3 -s  # On server
iperf3 -c server_ip -t 60  # On client

# 2. Optimize TCP parameters
cat | sudo tee /etc/sysctl.d/99-network-performance.conf << 'EOF'
# Network performance optimization
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
EOF

sudo sysctl -p /etc/sysctl.d/99-network-performance.conf

# 3. Check network interface settings
ethtool eth0
# Enable features:
ethtool -K eth0 rx on tx on sg on tso on gso on

# 4. Optimize network card queue
echo 4096 | sudo tee /sys/class/net/eth0/queues/rx-*/rps_cpus

# 5. Check for packet loss
ip -s link show eth0
# Look for errors, dropped packets

# 6. Optimize application socket buffers
# In application config, increase:
# SO_RCVBUF and SO_SNDBUF to 16MB or higher

📋 Performance Optimization Checklist

ComponentOptimizationStatus
CPUGovernor set to ‘performance’
MemorySwappiness ≤ 10
StorageAppropriate I/O scheduler
NetworkTCP BBR congestion control
File Systemnoatime mount option
KernelOptimized sysctl parameters
ApplicationsTuned for workload
MonitoringPerformance baselines established

💡 Tips for Success

Master performance tuning like a professional! 🌟

  • 📊 Measure First: Always baseline before optimizing
  • 🎯 Target Bottlenecks: Focus on the biggest performance killers
  • 🔄 Test Incrementally: Change one thing at a time
  • 📝 Document Changes: Keep track of what works
  • 🔍 Monitor Continuously: Watch for performance regressions
  • Balance Trade-offs: Performance vs security vs stability
  • 💾 Plan Rollbacks: Be ready to revert changes
  • 🧪 Test Under Load: Verify improvements under realistic conditions
  • 📈 Track Trends: Monitor long-term performance patterns
  • 🤝 Share Knowledge: Document optimizations for the team

🏆 What You Learned

Congratulations! You’re now a performance tuning expert! 🎉

  • ✅ Mastered system performance assessment and baselining
  • ✅ Optimized kernel parameters and system configuration
  • ✅ Implemented storage and I/O performance improvements
  • ✅ Configured application-specific performance tuning
  • ✅ Built comprehensive optimization workflows
  • ✅ Created performance monitoring and auditing systems
  • ✅ Solved common performance bottlenecks
  • ✅ Gained professional system optimization skills

🎯 Why This Matters

Your performance expertise transforms system capabilities! 🚀

  • Speed Multiplication: 2-5x performance improvements possible
  • 💰 Cost Optimization: Maximize existing hardware investments
  • 🎯 User Satisfaction: Deliver lightning-fast experiences
  • 📈 Scalability: Handle more load without hardware upgrades
  • 💼 Professional Value: High-demand optimization skills
  • 🔧 Problem Solving: Diagnose and fix performance issues
  • 🌟 System Mastery: Deep understanding of Linux internals
  • 🏆 Competitive Advantage: Outperform with optimized systems

You now possess the power to make any AlmaLinux system blazingly fast! 🏆

Optimize everything, everywhere! 🙌