If you're running on a budget VPS with limited RAM and CPU, every bit of optimization matters. This guide covers practical ways to shrink your application's resource footprint without upgrading your plan.
Step 1 — Identify What's Actually Using Resources
ps aux --sort=-%mem | head -10
ps aux --sort=-%cpu | head -10
Reducing Memory Usage
Tune Database Buffer Pool for Small VPS
Don't leave MySQL/MariaDB's default settings unchanged on a small VPS — explicitly cap the buffer pool to leave room for everything else:
innodb_buffer_pool_size = 256M
See How to Tune MySQL/MariaDB Performance for a VPS.
Reduce PHP-FPM Worker Count
sudo nano /etc/php/8.3/fpm/pool.d/www.conf
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
Disable Unused Services
systemctl list-units --type=service --state=running
Stop and disable anything you don't actually need running.
Use Lightweight Alternatives
| Heavier Option | Lighter Alternative |
|---|---|
| Apache with mod_php | Nginx with PHP-FPM |
| MySQL | MariaDB (similar features, sometimes lighter footprint) |
| Full desktop-oriented tools | CLI-only monitoring (htop instead of a full dashboard stack) |
Reducing CPU Usage
Enable Caching Aggressively
See How to Add Caching to Speed Up a Slow Web Application — caching reduces repeated computation, directly lowering CPU load.
Optimize Cron Job Scheduling
Avoid scheduling multiple resource-intensive cron jobs at the exact same time — stagger them across different minutes/hours.
Reducing Disk Usage
Set Log Rotation and Journal Limits
sudo journalctl --vacuum-size=100M
Clean Package Cache Regularly
sudo apt clean
sudo apt autoremove -y
Limit Docker Log Sizes
See Managing Docker Logs for setting max-size/max-file limits.
Adding Swap as a Safety Net
Even on a small VPS, a modest swap file prevents OOM kills during brief memory spikes — see How to Enable and Configure Swap on a Linux VPS.
Choosing a Lightweight Web Server
Nginx generally uses less memory per connection than Apache, making it a good default choice for resource-constrained VPS instances.
Running Only What You Need
Resist installing monitoring stacks, admin panels, or extra services "just in case" on a genuinely small VPS — each additional running service consumes baseline resources whether actively used or not.
When Optimization Isn't Enough
If you've applied these optimizations and still consistently hit resource limits, it's a genuine signal to upgrade — see How to Choose the Right VPS Plan for Your Workload rather than continuing to over-optimize a fundamentally undersized server.
Quick Wins Checklist
- Cap database buffer pool explicitly
- Tune PHP-FPM worker count to match available RAM
- Disable unused services
- Enable caching for expensive operations
- Set log rotation limits
- Add swap as a safety buffer
Related Articles
- How to Tune MySQL/MariaDB Performance for a VPS
- How to Add Caching to Speed Up a Slow Web Application
- How to Choose the Right VPS Plan for Your Workload
