Server optimization is the set of adjustments made to the operating system, web server, database and application layers to get more performance out of the same hardware. A properly configured VDS can run faster than a larger server that hasn't been tuned.
In this guide we cover 12 basic optimization steps you can apply to a Linux-based VDS. Commands are given with Ubuntu/Debian examples; always take a backup before making changes.
1. Measure First
Start optimizing based on measurements, not guesses. Watch CPU and RAM usage with htop, disk reads and writes with iotop and disk usage with df -h. Changes made without knowing whether the bottleneck is CPU, RAM, disk or network often bring no benefit.
2. Keep the System Up to Date
Updates close security holes and often bring performance improvements:
sudo apt update && sudo apt upgrade -y
3. Turn Off Unnecessary Services
Services you don't use consume RAM and CPU. List running services with systemctl list-units --type=service --state=running and disable the ones you don't need with systemctl disable --now service-name.
4. Configure Swap Properly
A small swap space helps prevent processes from being killed suddenly when RAM fills up. To keep swap from being used too often, you can lower the vm.swappiness value (e.g. 10). If swap is used constantly, the answer isn't tuning but more RAM.
5. Choose and Tune the Web Server
- Nginx or LiteSpeed/OpenLiteSpeed usually use fewer resources under many concurrent connections.
- If you use Apache, run it with
mpm_eventand PHP-FPM. - Enable Gzip or Brotli compression and HTTP/2.
6. PHP-FPM and OPcache
For PHP applications, OPcache keeps compiled code in memory and shortens response times noticeably. In PHP-FPM, set pm.max_children according to your RAM: (available RAM) / (average PHP process size) is a simple starting formula.
7. Database Settings
In MySQL/MariaDB the most effective setting is usually innodb_buffer_pool_size; on a server running only the database, roughly half to 70% of RAM is a common starting point. Turn on the slow query log to find which queries run slowly and add the necessary indexes.
8. Add a Caching Layer
- Page cache (LiteSpeed Cache, Nginx FastCGI cache)
- Object cache (Redis or Memcached)
- Browser cache headers for static files
9. Keep Disk Usage Under Control
A full disk leads to database errors and slowness. Limit log file growth with logrotate, move old backups off the server and find large folders with du -sh /var/* | sort -h.
10. Network and Kernel Settings
On high-traffic servers, TCP BBR congestion control and raising file descriptor limits (ulimit -n) can help. Apply such sysctl settings one at a time and measure after each change.
11. Security Is Performance Too
Brute-force attacks and bot traffic waste server resources. Use key-based login for SSH, install fail2ban and open only the necessary ports in the firewall. For attack types, see our article types of DDoS attacks.
12. Continuous Monitoring
Monitor resource usage with tools such as Netdata, Zabbix or Prometheus/Grafana, and set up alerts for a full disk or high load. You'll notice problems before your users do.
When Optimization Isn't Enough
If the CPU or RAM is constantly at its limit despite all the tuning, the server is simply too small. With ViHyper VDS plans you can upgrade to a bigger plan from the client area. For what to check when choosing a VDS, read our article choosing an affordable VDS.
Frequently Asked Questions
How often should a server be optimized?
Reviewing your settings after major updates, traffic increases or new application installs is a good habit. Monitoring tools show you when action is needed.
Do similar steps apply to Windows servers?
The logic is the same: measure, turn off unnecessary services, keep things updated and use caching. The tools differ; on Windows you use Task Manager, Resource Monitor and Performance Monitor.
Are ready-made optimization scripts safe?
Don't run scripts found online without understanding what they do. Applying each setting one by one and measuring its effect is both safer and more instructive.