Skip to content

More than one machine

One server is enough for most teams. When it isn’t, Lyra scales by running more copies of the same image. Every copy is the same code; a setting called ROLE decides which parts each one runs.

Copies on different machines can’t share Docker volumes or memory, so they share these instead:

Why
One Postgres 17 database The only place Lyra keeps data for good. Give Lyra its own, so heavy database views never slow down another product’s database
One Redis 7 Passes live edits and events between copies, so two people on different copies see each other type, and counts rate limits for all copies together. It holds nothing that can’t be lost
One S3-compatible bucket Uploaded files. See Your own proxy and S3
The same settings The same APP_URL, AUTH_SECRET and the rest, on every copy
ROLE Runs
all Everything, in one process. The default
api The API, the MCP endpoint, live updates (/api/live) and the web app. No live editing and no background jobs
collab The same as api, plus live editing (/collab). No background jobs
jobs Only background jobs, such as emails, imports and cleanup. It answers no requests

Any role other than all needs REDIS_URL; the server refuses to start without it.

A typical split:

┌──▶ ROLE=api (2 or more copies) ──┐
docs.acme.com ──▶ load balancer ─┤ ├──▶ Postgres, Redis, S3
└──▶ ROLE=collab (/collab only) ──────┤
ROLE=jobs (1 or more copies) ──┘

Send /collab to the collab copies, and everything else to the api copies. Run at least one jobs copy: emails, sign-in links included, and imports are background jobs, so without one they never run. Follow Your own proxy for the load balancer’s settings.

Each copy opens up to DATABASE_POOL_SIZE database connections, 20 by default. Check that your Postgres allows that many for every copy together.

The web app is static files. To serve it from a CDN instead of Lyra:

  1. Leave WEB_DIST_DIR empty on the server, so it serves only the API.
  2. Put the built web app on the CDN, at APP_URL.
  3. Have the CDN send /api, /collab, /oauth, /.well-known and /mcp to the server, so the app and the API share one address and one sign-in cookie.

If you publish pages on a separate domain with SHARE_URL, point that domain straight at the server, not at the CDN.

Postgres is the only place data lives, so losing Redis or a copy of Lyra loses nothing. While Redis is down, people on different copies stop seeing each other’s changes live, and rate limits are skipped rather than refusing every request.