Getting ssd right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including trim and io-scheduler considerations.
Prerequisites
- Basic familiarity with the Linux command line
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Root or sudo access to the server
Baseline Measurement
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# Kernel tuning: /etc/sysctl.d/99-performance.conf
cat << 'EOF' | sudo tee /etc/sysctl.d/99-performance.conf
# Network performance
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
# Memory management
vm.swappiness = 10
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
# File descriptors
fs.file-max = 2097152
fs.nr_open = 2097152
EOF
sudo sysctl --system
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Kernel and OS Tuning
Security should be a primary consideration when configuring ssd. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
# Benchmark before and after optimization
# CPU benchmark
sysbench cpu --cpu-max-prime=20000 run
# Memory benchmark
sysbench memory --memory-block-size=1M --memory-total-size=10G run
# Disk I/O benchmark
sysbench fileio --file-total-size=4G --file-test-mode=rndrw prepare
sysbench fileio --file-total-size=4G --file-test-mode=rndrw run
sysbench fileio --file-total-size=4G cleanup
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Wrapping Up
Following this guide, your ssd setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.