karawaci.kode

2026-05-15 · 5 min

Systemd vs Docker untuk VPS Indonesia: Pilih Sederhana

Setiap kali ada developer baru join freelance saya, pertanyaan pertama: “Pak Reza, deploy-nya pakai Docker?” Saya hampir selalu jawab: tidak. Pakai systemd.

Penjelasan ini bukan anti-Docker. Docker sangat powerful untuk specific use case. Tapi untuk SMB Indonesia yang VPS-nya satu, tidak ada Kubernetes, tim cuma 1-3 orang — Docker often over-engineering.

Konteks: VPS 4GB / 4 CPU di Hetzner Singapore

Setup standard saya untuk klien SMB:

  • VPS Hetzner cx41 (4GB / 4 CPU, $11/month)
  • Ubuntu 24.04 LTS
  • Nginx reverse proxy
  • Postgres 17
  • App layer: Bun + Hono atau Go + Fiber

App jalan via systemd service:

# /etc/systemd/system/myapp.service
[Unit]
Description=My Warung App
After=network.target postgresql.service

[Service]
Type=simple
User=myapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/local/bin/bun run /opt/myapp/server.ts
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
Environment="NODE_ENV=production"
EnvironmentFile=/opt/myapp/.env

[Install]
WantedBy=multi-user.target

Deploy script:

#!/bin/bash
# deploy.sh
git pull
bun install --production
bun run build
sudo systemctl restart myapp
sudo journalctl -u myapp -n 50 --no-pager

That’s it. 15 lines of config. Done.

Dengan Docker, saya butuh

  1. Dockerfile (writing image)
  2. docker-compose.yml (orchestration)
  3. Network config (frontend, backend network)
  4. Volume mount (data persistence)
  5. Health check config
  6. Restart policy
  7. Resource limits
  8. Logging driver
  9. nginx-proxy atau Traefik untuk reverse proxy

50+ lines of config minimum, lebih kalau pakai Docker Swarm atau Kubernetes.

Resource overhead

VPS 4GB, app saya (Hono + Postgres + Redis):

Systemd setup: 350MB RAM used. Docker setup (same app): 580MB RAM used.

Docker tax ~230MB karena: container runtime, multiple syscalls, network bridge overhead, isolation overhead.

Untuk VPS 4GB, 230MB = 5.7% kapasitas. Tidak break, tapi gratis kapasitas yang bisa untuk caching.

Yang systemd kasih, tanpa drama

  1. Restart on failure: Restart=always di unit file.
  2. Logging: Journald otomatis. journalctl -u myapp -f untuk realtime tail.
  3. Permission isolation: User=myapp untuk run app sebagai non-root user.
  4. Auto-start on boot: systemctl enable myapp.
  5. Resource limits: MemoryMax=500M, CPUQuota=200% (2 cores) di unit file.
  6. Graceful shutdown: TimeoutStopSec=30 plus SIGTERM handler di app.

Semua di unit file ~25 lines.

Yang Docker kasih (yang systemd tidak)

  1. Dependency isolation: app A pakai Node 18, app B pakai Node 22. Docker easy. Systemd harus pakai nvm or manual paths.
  2. Multi-architecture build: Docker buildx untuk arm64 + amd64. Systemd: native compile.
  3. Easy multi-environment: dev image = prod image. Systemd: deployment script harus handle env differences.
  4. Service discovery: docker compose otomatis. Systemd: manual network=bridge or unix sockets.
  5. Quick scale-out: Docker swarm trivial. Systemd: harus setup load balancer manual.

Untuk klien SMB: poin-poin ini biasanya tidak relevan. App-nya satu, dependency-nya satu set, scale-nya vertical (upgrade VPS) bukan horizontal.

Kapan saya pakai Docker

  • Klien punya tim DevOps yang preference Docker (tidak fight existing flow)
  • Multi-tenant SaaS dengan per-customer database container
  • Setup local dev yang harus matched production tanpa “works on my machine” issue
  • Deploy ke Kubernetes (memang harus pakai Docker)

Kapan saya pakai systemd

  • VPS tunggal SMB Indonesia
  • Side project pribadi
  • Project warisan yang code masih jalan (no migration)

Saran

Junior dev sering install Docker karena “industri standard”. Mungkin benar di Bay Area startup. Untuk Indonesia SMB context: pertimbangkan systemd. Lebih sederhana, lebih hemat, less to maintain.

Yang penting bukan tool. Yang penting: deploy bisa diulang, restart on failure, logging accessible. Systemd kasih semua itu, gratis, sudah dibuilt-in Ubuntu.

Ditulis oleh Reza Pradipta