Summary: Set per-container resource limits, monitor usage, clean up logs and images, tune the reverse proxy, and ensure backups and basic hardening. Many "under-spec" servers are simply poorly configured.

1. Monitor First

Install light monitoring (Netdata, Prometheus + Grafana, or Uptime Kuma). Watch CPU, RAM, disk, I/O, and connection counts. Without data, tuning is guessing.

2. Resources and Docker

  • Set memory and CPU limits per container so one process cannot consume everything.
services:
  app:
    deploy:
      resources:
        limits:
          memory: 512M

Resource-limit syntax can differ between Compose versions; check the documentation for yours.

  • Use small images (alpine/slim) and multi-stage builds.
  • Clean up unused images and volumes periodically (docker system prune, with care).
  • Rotate container logs so the disk does not fill:
logging:
  driver: json-file
  options:
    max-size: "10m"
    max-file: "3"

3. Memory and Swap

On small-RAM VPS instances (for example 2GB), swap as a buffer prevents processes from being killed suddenly by the OOM killer. Swap is not a substitute for RAM; if it is constantly used, upgrade the spec.

4. Nginx / Reverse Proxy

  • Enable compression and static asset caching.
  • Tune timeouts and buffer sizes to the application.
  • Use HTTP/2 and automatic HTTPS certificates.
  • Rate-limit sensitive endpoints.

5. Database on the Same Server

On small servers, give the database a sensible amount of memory and do not run too many heavy services together. See database optimization.

6. Basic Hardening

  • SSH keys only, disable password login, disable direct root login.
  • Firewall (UFW) opening only the needed ports.
  • fail2ban and automatic security updates.
  • Keep secrets out of code and images.

7. Backup and Recovery

Daily backup to separate storage, test restores, and take a snapshot before major changes. A cheap server without backups is an expensive risk (n8n example).

8. When to Upgrade

Upgrade when CPU/RAM stay high after optimization, not before. Compare the cost of a bigger plan with hosting cost optimization.

FAQ

What is the minimum RAM for Docker?

Docker itself is light; requirements come from the applications inside. Add up all containers plus headroom for the OS.

Is a Singapore or local VPS better?

It depends on latency needs, data compliance, and support. Both are fine if configured well.

Next steps

Hand your server tuning and monitoring to Oneflux, from audit to regular care.