running a website off a machine with 1GB of RAM
November 07, 2026 · astrogcplinux
I have a decent amount of experience with Microsoft Azure, mostly data engineering with a little container and web app work. I wanted to try another major cloud provider, and Google Cloud Platform has a free tier that includes a small VM you can run around the clock at no cost.
There are catches. When I set this up, the free VM had to be an e2-micro, it had to live in us-west1, us-central1 or us-east1, and it came with 1 GB of RAM. (Google changes these terms, so check their free tier page before you copy my setup.)
That 1 GB is the real constraint. Two decisions made it comfortable: Astro and a swap file.
Astro: do the work before the server sees it
Astro ships zero JavaScript by default, which is a good fit for a portfolio and blog. My posts are Markdown files, and npm run build turns the whole site into plain HTML, CSS and images in a dist/ folder. Nginx serves those files directly. There’s no Node process, no database and nothing running per request, so the server has almost nothing to do.
The build also happens somewhere else. A GitHub Actions workflow runs the build when I push, then copies only dist/ to the VM. The VM never sees my source code and never runs npm install, which matters because installing packages and building a frontend is exactly the kind of work that can eat most of 1 GB by itself.
So publishing looks like this: write a Markdown file, push to GitHub, and a minute later it’s live.
The swap file: a safety net
RAM is fast but small. Swap is a file on disk that the operating system can use as overflow RAM. When memory fills up, Linux moves chunks of memory that haven’t been used lately out to the swap file, which frees real RAM for whatever needs it now. If something needs those chunks later, Linux reads them back.
Without swap, a memory spike on a 1 GB machine ends with the kernel’s out-of-memory killer picking a process and killing it. That could be your web server or even your SSH session. Swap trades that crash for a slowdown.
Disk is much slower than RAM, so swap is not extra memory. It’s insurance. If a machine is using swap constantly, it needs more RAM.
Setting one up takes a few commands:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
The last line makes it survive reboots. You can confirm it’s active with free -h or swapon --show.
I also lowered vm.swappiness, which controls how eagerly Linux uses swap, so it only kicks in when memory is actually tight:
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
Does a static site even need it?
Honestly, rarely. Because Astro does its work at build time, my server mostly idles, and swap may barely get touched. But a system upgrade, a certificate renewal or a future backend service can spike memory at the wrong moment, and a swap file costs a couple of gigabytes of disk and nothing else. It’s cheap insurance.
The takeaway
On a free tier, resources are a budget. Build on someone else’s machine, serve plain files, and keep a swap file as a cushion. That’s enough to run a site comfortably on 1 GB.