Skip to content

docker host for 20+ microservices—swap or suffer?

VPS Hosting by uma 3 replies 180 views
#1

Running 22 containers on a 2GB Contabo VPS. Debian 12, Docker CE, nothing exotic. Every night around 03:00 the OOM killer visits. : memory climbs until something critical gets axed. Usually it's Prometheus, which is deeply ironic. Current mitigation: nothing. I watch it die. Options I'm considering:

  • 2GB swap file on SSD
  • Zram with 50% memory allocation
  • Both, because why choose suffering
The SSD is "enterprise" from OVHcloud's cheapest tier. Wear worries feel theoretical at this price point, but I've been burned before. Status page would go red if I lose this node. Alert fatigue is real; I already mute the disk-full warnings. Anyone running similar density on 2GB? But I need more graphs. What's your swap strategy?

436 days. reboot is surrender.
#2
uma said:
2GB swap file on SSD

Swap on SSD is fine. The virtualization tax on memory overcommit is worse than any NAND wear. Your real problem is cgroup limits—Docker defaults are permissive.

Set memory.limit_in_bytes per container. Without limits, one leaky microservice consumes the host. I've seen OpenVZ nodes collapse from this; KVM at least isolates properly.

Zram trades CPU for compressed RAM. On low-end hosts the CPU cost is measurable. Swap + zram together is just panic layered on panic.

Virtualization tax applies to your monitoring stack too. Run Prometheus with --storage.tsdb.retention.time=2h or move it off-node.

virsh list --all | wc -l: 47
#3
kate3 said:
Swap on SSD is fine

How do you say, obviously the SSD will last forever /s

Or you should worry about wear, clearly the electrons enjoy being shuffled around for your 22 containers that should have been one binary. I do not know why anyone runs Prometheus on 2GB, whether this is masochism or education.

Your zram panic layering is beautiful. Clearly you will post Grafana screenshots when this explodes. /s

2 #4
Fio --randread --bs=4k --iodepth=64 --runtime=60
OVHcloud €3 tier:  IOPS=4.2k, BW=17MB/s
Contabo €2.5:     IOPS=8.1k, BW=32MB/s
local NVMe ref:     IOPS=85k,  BW=340MB/s

Decent disk IO, meh network

Swap on Contabo SSD = 32MB/s compressed. Zram on 2GB = ~160MB/s effective if 5:1. CPU overhead 15-20% on single-core VPS.

  • Zram alone: faster, eats CPU
  • Swap alone: slower, zero CPU
  • Both: zram first, swap fallback = optimal for your case

Run the benchmark yourself. Numbers beat theory.

fio, iperf, geekbench. results or gtfo.

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft