Sblurp

Fly.io

Fly runs the server image for you. There is no operating system to patch. One community costs about $4 a month.

Steps

  1. Install flyctl and sign in:

    fly auth login
    
  2. Copy server/fly.toml from the repository. Change app, SBLURP_NAME, SBLURP_BASE_URL and BACKUP_NAME.

  3. Make the app, a volume and addresses. Replace my-community with your app name:

    fly apps create my-community
    fly volumes create sblurp_data -a my-community -r sjc -s 1 --snapshot-retention 14 -y
    fly ips allocate-v4 --shared -a my-community
    fly ips allocate-v6 -a my-community
    
  4. Add DNS records for your domain: an A record with the shared IPv4 address and an AAAA record with the IPv6 address. On Cloudflare, set them to "DNS only" (grey cloud) so Fly can get the certificate.

  5. Add the certificate and wait for "Issued":

    fly certs add chat.example.com -a my-community
    fly certs check chat.example.com -a my-community
    
  6. Deploy a released image:

    fly deploy --ha=false --image ghcr.io/OWNER/sblurp-server:stable
    
  7. Join your community first. The first person to join becomes the owner.

Backups on Fly

Without R2 secrets the image runs with no backups. To turn them on, set the secrets before the first deploy:

fly secrets set --stage -a my-community \
  AWS_ACCESS_KEY_ID='<R2 access key ID>' \
  AWS_SECRET_ACCESS_KEY='<R2 secret access key>' \
  R2_ENDPOINT='https://<ACCOUNT_ID>.r2.cloudflarestorage.com' \
  BACKUP_PASSWORD='<backup password>'

See Backups for what gets copied and how to restore.

Why the settings in fly.toml

  • One machine. SQLite allows one writer. Never scale past one machine. --ha=false stops Fly from making a second.
  • Always on. auto_stop_machines = "off" and min_machines_running = 1, because the machine holds every open Subscribe stream.
  • h2c. h2_backend = true makes Fly's proxy speak HTTP/2 to the server, so Connect streams and gRPC work.
  • High concurrency. Each open Subscribe is one request. The limit is 5,000 soft and 10,000 hard. The default soft limit of 20 is far too low.
  • Idle timeout of 600 s. Subscribe also sends a heartbeat every 25 s.
  • Health check on /healthz, with a 30 s grace period because the first boot may restore from R2.
  • 512 MB. A file backup run can use 50 to 100 MB.

Updates

Fly does not update by itself. Run the deploy command again for each release. To grow, raise the memory with fly scale memory 1024 or the volume with fly volumes extend <volume ID> -s 3.

Cost

About $4 a month for one community on a 512 MB shared-cpu-1x machine with a 1 GB volume. Fly has no free tier for new accounts. Check fly.io for current prices.