A Whole SaaS Suite on One Box

Nine-plus apps, one VPS, and why vertical beats horizontal.

A Whole SaaS Suite on One Box

I run nine-plus Extant 2000 apps on one VPS. Each app is a container. Traefik routes by subdomain. One deploy path, one backup path and one place to look.

The pieces

  • Containers. Each app is its own container with its own compose file.
  • Traefik. It routes by subdomain, such as app.example.com, and gets certificates from Let’s Encrypt. The Plain Traefik post shows the five labels.
  • Shared Postgres. The apps use one Postgres server. Giving each app its own database and role is safer than sharing one, because a leak then stays with one app. A role per app limits a leak to one app. The read-only Metabase post shows the pattern for a read-only role.
  • Version control. The compose files sit in version control. A box rebuild starts from the repository.

Lanes

Untrusted workloads get their own network segments and egress rules. Production apps, the media stack and the retro lab share the hardware, in separate lanes.

A lane is a Docker network plus rules. The hardening post gives a generic example for an untrusted network on 198.51.100.0/24: the chain drops traffic to private ranges, to 169.254.0.0/16 (which includes the cloud metadata address) and to SMTP ports 25, 465 and 587. Those rules sit in the DOCKER-USER chain, which runs before Docker’s own chains.

That example is iptables only. On a dual-stack host it leaves IPv6 unfiltered, so write matching ip6tables rules or turn IPv6 off. I keep IPv6 off on the untrusted network, so those rules cover it.

Why one place

One box means one set of backups to test, one deploy command to learn and one set of logs. When a service misbehaves, I check the proxy log, then the container log, then the database. There are three places to look and no more.

The cost is that the box is a single point of failure. A disk fault takes everything down at once. Test restores on a schedule, because a backup you have never restored is a guess.

Vertical before horizontal

I add RAM and CPU to this machine before I add a second machine. A second server brings networking, service discovery and a second set of patches. Until one machine runs out of room, that work buys nothing.

The check for room is the one from the migration post. Read %st in top and the st column in vmstat 1. High steal means the host is oversold, and no container setting changes that. Memory pressure and disk I/O are the other two signs, and I have no numbers to quote for either.

A new app, step by step

  1. Write a compose file with the app and its labels.
  2. Create a database role for it in the shared Postgres.
  3. Put the app on the lane that fits its trust level.
  4. Commit the compose file.
  5. Deploy and check the certificate.
  6. Add it to the backup job.

Subscribe to Just another Geek

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe