NODED.CLOUD/Blog/What Actually Fits on a 4 GB VPS: A Docker Compose Memory Budget

What Actually Fits on a 4 GB VPS: A Docker Compose Memory Budget

24 Sept 2026 · Mario Marin

A 4 GB machine gives you about 3.2 GB to spend. Here is what each container really costs, three stacks that fit inside it, and one that does not.

"Will my stack fit on a 4 GB VPS?" is the most common pre-sales question we get, and the honest answer is a budget, not a yes or no. A 4 GB machine has roughly 3.6 GB of usable memory once the kernel and a minimal Linux install have taken their share, and every container you add spends from that. Once you write the numbers down, the decision makes itself.

This post is the arithmetic: what the common pieces actually cost in RAM, three example stacks that fit, one that does not, and how to check your own plan before you pay for anything.

Start with what is left

On our VPS II KVM — 4 GB RAM, 2 vCPU, 40 GB disk, €6 a month in Bucharest — a realistic starting budget after a minimal Debian or Ubuntu install and the container runtime is about 3.5 GB. Reserve some of that deliberately:

  • 250 MB kept free as headroom. A machine at 100% memory does not fail gracefully; it fails through the OOM killer, which picks a victim you did not choose.
  • No swap, or a small swap file only. Swap on a busy database turns a memory problem into a latency problem. If you rely on swap to fit, you do not fit.

That leaves roughly 3.2 GB to spend. Now price the pieces.

What the common containers really use

Steady-state figures for small production workloads — not the vendor minimums, and not idle-after-boot numbers:

ComponentRealistic footprintNotes
Reverse proxy (Caddy / nginx / Traefik)30–80 MBCheap. Traefik is the hungriest of the three.
PostgreSQL, small dataset400–700 MBshared_buffers at 25% of what you allot it, plus per-connection backends.
MySQL / MariaDB, small dataset500–800 MBDefault InnoDB buffer pool is often oversized for a 4 GB box; tune it down.
Redis / Valkey as a cache100 MB + your dataSet maxmemory explicitly or it will grow into the whole machine.
A Node or Python web app150–400 MB per processMultiply by worker count. Four Gunicorn workers is four times the number.
PHP-FPM pool (WordPress-class app)300–600 MBDriven by pm.max_children, which is the setting people forget.
A JVM service600 MB – 1.5 GBSet -Xmx. Container-aware defaults still take 25% of the host.
Elasticsearch / OpenSearch1.5–2 GB minimumThis is the component that does not fit. See below.
Prometheus, short retention300–600 MBGrows with series count, not with scrape interval.
Grafana100–200 MBCheap for what it gives you.
Background worker (queue consumer)150–300 MB eachSame runtime cost as a web process, without the traffic.

Three stacks that fit in 3.2 GB

Small SaaS or web app — about 1.8 GB

Reverse proxy (60 MB) + PostgreSQL (600 MB) + two app workers (600 MB) + one queue worker (250 MB) + Redis capped at 128 MB (230 MB). Comfortable, with room for a deploy to run a second copy of the app during the switchover.

WordPress-class site with caching — about 1.6 GB

Reverse proxy (60 MB) + PHP-FPM with pm.max_children tuned (500 MB) + MariaDB with a trimmed buffer pool (700 MB) + Redis object cache capped at 128 MB (230 MB). Our note on unmanaged WordPress hosting goes further into the PHP side.

Self-hosted tooling box — about 2.6 GB

Reverse proxy (60 MB) + an automation tool with PostgreSQL (1.1 GB) + a lightweight analytics instance (400 MB) + Prometheus and Grafana with short retention (700 MB) + a password vault (50 MB). Tight but real, and it consolidates five subscriptions onto one €6 machine.

One that does not fit

App + PostgreSQL + Elasticsearch. The search cluster alone wants 1.5–2 GB before it indexes anything meaningful, and with a JVM heap plus the OS page cache it needs, you are into the 8 GB shape (VPS III, €10 in Bucharest) or splitting search onto its own machine. Trying to squeeze it into 4 GB produces exactly one outcome: the OOM killer chooses your database.

The same is true of any JVM-heavy pairing, and of running a build agent on the same box as the thing it deploys to.

Disk is a separate budget

The VPS II includes 40 GB, and a container stack spends it faster than people expect: images and layers, database files, logs, and whatever your application writes. A workable split is 10 GB for the system and images, the rest for data, and a hard log rotation policy from day one — an unrotated container log is the most common way a 40 GB disk fills.

If you need more room later, extra storage is €4 a month per 50 GB increment, up to three increments, which is cheaper than moving up two shapes for capacity you do not need in RAM.

When to buy the next shape instead

Our ladder and what each step is really for:

ShapeRAM / vCPU / diskBucharestFrankfurt · ViennaBuy it when…
VPS I KVM2 GB / 1 / 20 GB€4.00€5.50One service plus a proxy, or a single static site
VPS II KVM4 GB / 2 / 40 GB€6.00€9.00App + database + cache + a worker — the stacks above
VPS III KVM8 GB / 2 / 60 GB€10.00€16.00A search engine, a JVM service, or a database with a real working set
VPS IV KVM16 GB / 4 / 80 GB€16.00€26.00Several of the above at once, or CPU-bound work that wants 4 vCPU

Note that the vCPU count moves from 2 to 4 at the fourth shape. If your problem is concurrency rather than memory — many simultaneous requests, parallel builds, video encoding — that step is what you are buying, not the RAM. The location price list has the full grid for all five of our EU locations.

Measure it for three cents

The budget above is a planning tool. The real number comes from your stack on a real machine:

  1. Order a VPS II hourly — €0.0083 per hour in Bucharest, €0.0125 in Frankfurt.
  2. Bring the whole stack up and drive it with realistic traffic, not a health check.
  3. Read per-container memory (docker stats or systemd-cgtop) at peak, not at rest, and check whether anything is being reclaimed.
  4. Destroy the machine. Four hours in Bucharest is €0.03.

Hourly services need €5 of account credit to create, bill from that balance each hour, and keep billing while stopped — destroying the machine is what ends the charge. Our break-even post covers when to switch a machine you are keeping onto the monthly price.

How Noded Can Help

Write your stack's budget with the table above, then prove it on an hourly VPS II from the hourly VPS page before committing to a monthly plan. If the numbers say 8 GB, buy 8 GB — a machine that swaps is more expensive than the €4 a month you saved. Send us your component list in a ticket if you want us to sanity-check it; we will tell you when a smaller shape is enough.

FAQ

How much usable RAM does a 4 GB VPS have?

Roughly 3.6 GB after the kernel and a minimal install, and you should plan to spend about 3.2 GB so there is headroom. Anything that only fits by relying on swap does not fit.

Can I run Docker on a 4 GB VPS?

Yes — the runtime itself is a small overhead. What matters is the sum of the containers, and the defaults (buffer pools, JVM heaps, PHP-FPM children, uncapped Redis) are what break 4 GB machines, not the count of containers.

Will Elasticsearch fit in 4 GB?

Not alongside an application and a database. Budget the 8 GB shape, or put search on its own machine.

Do I need swap?

A small swap file is reasonable insurance against a brief spike. Sizing your stack to require swap is not — latency collapses long before the memory runs out.

What if I run out of disk rather than memory?

Add storage increments: €4 a month per 50 GB, up to three per machine. Rotate your container logs first, which is free.

← All posts

Related services

Run this on NODED.CLOUD.

Keep reading

More from the NOC.

01 Sept 2026·Mario Marin

Self-Hosted Error Tracking: GlitchTip on a VPS

A sizing and setup guide for running GlitchTip, the open-source Sentry-compatible error tracker, on a self-hosted VPS — with a look at why teams move off per-event SaaS pricing and keep error data on EU infrastructure.

Read post
27 Jul 2026·Mario Marin

Minecraft Server Hosting in Europe

A NOC engineer's guide to Minecraft server hosting in Europe: how RAM maps to real player counts, why sub-5ms EU ping matters, and where free 1 Tbps DDoS protection fits in.

Read post
25 Sept 2026·Mario Marin

Sizing a VPS for Redis or Valkey

One number decides the shape: resident data. Then maxmemory, the eviction policy, persistence and the firewall decide whether it survives production.

Read post

Like the way we run things? Spin up a server in 60 seconds.