Legendary Arena Lab

Swapfile

foundations

Migration in progress. api.legendary-arena.com and PostgreSQL are moving from Render to a self-hosted DigitalOcean Ubuntu host behind Cloudflare. Render remains rollback-ready until decommission phase.

Swapfile

Give the 4 GB droplet a 2 GB safety margin for deploy-time builds.

Summary

The droplet starts at 2 vCPU / 4 GB (D-002). Measured production use is about 1 GB, but pnpm -r build runs on the box during every deploy and spikes well above that. Without swap, the OOM killer can take PostgreSQL or the game server mid-deploy.

This page owns infra/scripts/08-swap.ps1, which:

  • creates a 2 GB /swapfile (fallocate, falling back to dd), mode 600
  • enables it and adds it to /etc/fstab so it survives a reboot
  • sets vm.swappiness=10, so Node and Postgres stay in RAM and swap is used only under real pressure
  • is idempotent: an active /swapfile is left alone, and the fstab line is never duplicated

Overrides: LA_SWAP_SIZE_MB (default 2048) and LA_SWAPPINESS (default 10).

Execute

sudo pwsh -File infra/scripts/08-swap.ps1

Verification

swapon --show
free -h
cat /proc/sys/vm/swappiness
grep swapfile /etc/fstab

Expected:

  • /swapfile listed by swapon --show at 2G
  • swappiness 10
  • exactly one /swapfile line in /etc/fstab

Operational note

Swap in steady use means the box is undersized. If memory holds above ~70% or swap is in use outside deploys, resize to 4 vCPU / 8 GB. Choose CPU and RAM only so the 80 GB disk stays and a later downsize remains possible.

References

  • Plan section 1 (Compute) and section 5 (Infra script manifest)
  • Decision D-002 (start at 2 vCPU / 4 GB with a 2 GB swapfile)