NEWS

How to size a cheap VPS for your self-hosted apps

Photo: Kevin Ache / Unsplash

For self-hosted apps, RAM is what decides how small a server you can get away with. Processor speed matters far less for the tools people usually move off their own machines: an analytics dashboard, a notes app with search, a small agent that answers a few requests an hour. Each one runs in a container with its own data store, and a database wants RAM for its cache before it serves a single page.

That keeps the monthly bill low. A plan with one core and 2GB of memory costs around $3 a month at the cheaper VPS hosts, and an Interserver coupon code can bring the first month of a VPS down to a single cent, which buys a full billing cycle to install the stack and watch what it really uses before the regular rate starts.

Plenty of people start on a laptop instead. They follow the guide and the dashboard loads. Then the lid closes on the train home, and the next morning the analytics show a gap where the evening should be. A rented server stays on around the clock, and it adds one more monthly bill.

Memory goes to the database first

Plausible makes a good benchmark because it is one of the heavier popular options. Its Community Edition runs the app next to a ClickHouse database, and Plausible’s own setup notes recommend at least 2GB of RAM so that neither process gets killed for lack of memory. The same notes ask for a processor with the SSE 4.2 instruction set, which ClickHouse needs. Run grep sse4_2 /proc/cpuinfo on a fresh server before installing anything: an empty result means the install will fail however much memory is free.

Lighter tools built on SQLite never start a separate database server, so they leave most of a 2GB plan untouched.

The command docker stats shows the live memory of each container. Check it after a day of real traffic rather than straight after the install, because caches fill as data arrives.

Two apps on one small server

Photo: Gabriel Heinzer / Unsplash
A Linux command line showing an ubuntu prompt with sudo typed

Stacking several apps on one box is where small plans fall over. Put analytics, a notes app and a reverse proxy on 2GB and everything works until the database cache grows, at which point the Linux kernel’s out-of-memory killer steps in. It ends the process using the most memory, which on an analytics box is usually the database itself. The dashboard goes blank, the app logs say little, and only dmesg turns up the line that explains it, “Out of memory: Killed process”, followed by the name of whatever the kernel stopped.

A swap file will buy you some time on a server like this, but everything slows down while it does. On plans sold in fixed slices, more memory means one more slice, so going from 2GB to 4GB doubles a bill that started small. For two database-backed apps, 4GB is the comfortable floor.

Disk space and old images

Docker keeps every image it has pulled, and each update you pull leaves the old one behind. The command docker system df lists what images, containers and volumes are using, and docker image prune -a clears the images no container uses. Analytics data grows with every visit, so check the disk once a month for the first few months.

Keep backups off the server

A snapshot stored with the same provider protects you against a bad update. It does little when the account or the machine itself is the problem. Named volumes hold the data that matters, and they survive the removal of a container, which makes them easy to forget about during a cleanup.

Photo: Luca Bravo / Unsplash

Docker’s guide to backing up volumes shows the standard approach: a temporary container mounts the volume and writes a tar archive into a folder you can copy elsewhere. Pulling that archive down to a home machine each night takes one cron job and a few lines of shell.

When to add a slice

The first month is the measuring period. Three signs show the plan is too small: swap in use for most of the day, which free -h reports; an out-of-memory line in dmesg; and pages that load slowly at quiet hours. If you see any one of them, add a slice before the regular billing starts.

For one analytics dashboard or one notes app on a personal site, 2GB holds without trouble. Two database-backed apps belong on 4GB. If your agent calls a hosted model, it barely needs any memory of its own. If it runs a model locally, you are looking at a different class of machine.

You may also like

Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted