Skip to main content

Infrastructure

Infrastructure

A self-hosted Patch server needs a machine, Postgres, and an object store. A CDN in front of downloads is optional, but recommended for running in production.

Install is the setup you run. This page is how to choose the shape. Starting machine size is there.

One host​

cmpatch selfhost install puts Caddy, the API, the release worker, Postgres, and Silo on one Docker host, with TLS and two hostnames. A machine with 2GB RAM, 1vCPU and 30GB of storage is enough for most deployments.

You can also run Patch on Fly.io, using their Tigris integration for object storage. This is less work to set up, and is still suitable for most deployments.

When to move something off the machine​

Each piece is changed for a different reason.

CDN​

Add Cloudflare or CloudFront for a production install. Every device that takes an update fetches the bundle, so this is about latency and keeping that traffic off the host, at any audience size.

The installer offers this as a step. Skipping it leaves the install complete. A later run of the installer does not ask again. Turning a CDN on afterwards is an edit to .env.selfhost, then a rerun of install.sh, as CDN settings describes.

Postgres​

Move Postgres off the host when you want the provider's snapshots and point-in-time recovery, or when you need the extra storage capacity. The server keeps raw metric events for 8 days. That usage is about 2 GB per 100,000 daily active users.

The guided installer keeps Postgres on the server. A separate database is scripts/selfhost/install.sh on the server, with --database-mode external and --database-url set to a postgresql:// URL. Those two flags are part of that install, alongside the domains and sign-in values the script already asks for.

Object storage​

Move release files off the host when retained bundles are using lots of disc space. Frequent releases to staging can be a main contributor.

The installer can keep Silo on the server, or use Cloudflare R2, Amazon S3, or Google Cloud Storage. It can create those buckets or walk you through the console. External storage uses two buckets: one public for downloads, one private for _internal/ objects.

Azure Blob Storage is not supported.

note

Amazon S3 needs a permanent access key for a dedicated user, scoped to those two buckets. A temporary SSO or STS key is rejected. Google Cloud Storage needs anonymous reads on the public bucket, so Public Access Prevention cannot be enforced on it, and the project has to allow a service-account key.

Large user bases​

Patch serves the manifests and bundles through a CDN so requests rarely hit your server. Not handling large request volumes means you won't need extra complexity such as queues, Redis caching, or API gateways, even for millions of users.

Data transfer bills aren't an issue if you use Cloudflare. They don't bill for downloads from the CDN, so even petabytes of bundle downloads will be free. R2 does not charge egress either, so it is recommended for serving millions of users. Amazon S3 and Google Cloud Storage still charge egress when the CDN fetches an object from them.