Linux Kernel Parameter Tuning for Servers is a common requirement for VPS administrators. This guide provides practical instructions that you can follow on Ubuntu 22.04/24.04 or Debian 12, though most steps apply to other distributions as well.
Prerequisites
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Root access to the server
- Root or sudo access to the server
- SSH client on your local machine
- A registered domain name (for public-facing services)
Initial Setup
Performance benchmarks show that properly tuned kernel can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.
# Systemd service management
sudo systemctl status nginx
sudo systemctl enable --now nginx
sudo systemctl restart nginx
# View service logs
sudo journalctl -u nginx -f --since "10 minutes ago"
# List all running services
systemctl list-units --type=service --state=running
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
- Use SSH keys instead of password authentication
- Keep all software components up to date
- Enable firewall and allow only necessary ports
- Use strong, unique passwords for all services
Configuration Steps
For production deployments, consider implementing high availability by running multiple instances behind a load balancer. This approach provides both redundancy and improved performance under heavy load.
# Server resource monitoring
htop # Interactive process viewer
iostat -x 1 5 # Disk I/O stats (5 samples)
vmstat 1 5 # Virtual memory stats
ss -tlnp # Open listening ports
netstat -an | wc -l # Total connections
This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.
Configuration Options
Security should be a primary consideration when configuring kernel. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
- Set up monitoring before going to production
- Test disaster recovery procedures regularly
- Maintain runbooks for common operations
Automation and Scheduling
Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.
# Systemd service management
sudo systemctl status nginx
sudo systemctl enable --now nginx
sudo systemctl restart nginx
# View service logs
sudo journalctl -u nginx -f --since "10 minutes ago"
# List all running services
systemctl list-units --type=service --state=running
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
Configuration Options
It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.
Summary
You've successfully configured kernel on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.