Skip to content

Architecture

Vesicle is a Matrix homeserver split into four first-party services plus a small set of platform components. Helm is the supported way to run this layout in Kubernetes.

The four first-party services are Gateway, Engine, Worker and Auth. Each is a separate Deployment with its own replica count, so you can scale the busy path without scaling a monolith. They are written in Go and run as non-root containers.

HTTPS for the homeserver host (<serverName>) lands on your ingress (or Gateway API), then on gateway. The gateway serves well-known locally and forwards the rest over NATS request/reply.

flowchart LR
  clients[Clients and remote homeservers]
  ingress[Ingress HTTPS]
  gw[Gateway]
  nats[NATS]
  eng[Engine]
  auth[Auth]
  wk[Worker]
  pg[(PostgreSQL)]
  clients --> ingress --> gw --> nats
  nats --> eng
  nats --> auth
  eng --> pg
  wk --> nats
  wk --> pg
PathWhere it goes
/.well-known/matrix/client, /.well-known/matrix/serverGateway, locally
GET /302 to Element Web (chat.<serverName>), when Element Web is enabled
/_matrix/client/… login, logout, refreshHTTP reverse proxy to MAS (compat)
/_matrix/client/… (rest)NATS → Engine
/_matrix/federation/…, /_matrix/key/…NATS → Engine
/_synapse/admin/…NATS → Engine
/_synapse/mas/…NATS → Auth

Auth is not a public HTTP API. The gateway and the other services call it over NATS.

The worker takes no inbound HTTP. It runs the background roles: federation sending to other servers, and the durable queues that outlive a request.

Satellite hostnames do not go through the gateway. They are separate routes:

HostTarget
account.<serverName>Matrix Authentication Service
chat.<serverName>Element Web
admin.<serverName>Element Admin
mrtc.<serverName>Matrix RTC authorisation and LiveKit SFU

See DNS and hostnames and Ingress.

ComponentPodRole
Gatewayvss-gatewayPublic entry for client-server and federation HTTP, well-known, and root redirect to Element Web
Enginevss-engineThe central logic: client API, rooms and events, sync, and inbound federation. It also owns the database schema and runs the migration
Workervss-workerBackground roles: federation sending and other durable queues
Authvss-authAuthentication integration with Matrix Authentication Service

All four read their configuration from a JSON file and secret files that the chart generates. Resource names are <release>-<component>; the examples use the release name vss.

ComponentPodRole
Matrix Authentication Service (MAS)vss-matrix-authentication-serviceOIDC and account flows (account.<serverName>). Optional
PostgreSQLvss-postgres-NThe database, a CloudNativePG cluster (or your own server). See Choose a database and Back up and restore
NATS (JetStream)vss-natsMessaging between the services, durable queues, and the media store

vss-nats-box is a NATS utility pod from the NATS chart, not a Vesicle service.

These are optional in the chart values and off by default:

ComponentPodRole
Element Webvss-element-webMatrix client (chat.<serverName>)
Element Adminvss-element-adminAdmin console (admin.<serverName>)
Matrix RTCvss-matrix-rtc-authorisation, vss-matrix-rtc-sfulk-jwt-service plus LiveKit SFU (mrtc.<serverName>)
flowchart TB
  subgraph firstParty [First-party services]
    gw2[Gateway x2]
    eng2[Engine x2]
    wk2[Worker x2]
    auth2[Auth x2]
  end
  subgraph platform [Platform]
    mas[MAS]
    pg[PostgreSQL]
    nats2[NATS JetStream]
  end
  subgraph addons [Optional add-ons]
    ew[Element Web]
    ea[Element Admin]
    rtc[Matrix RTC]
  end
  gw2 --> nats2
  nats2 --> eng2
  nats2 --> auth2
  nats2 --> wk2
  eng2 --> pg
  wk2 --> pg
  auth2 --> mas
  mas --> pg

See Install with Helm for the install that produces this layout, including example kubectl output.

The design goal is that every first-party service runs with many replicas. See Scaling and availability for what that means and what still sets the limit.

Each first-party service is its own Kubernetes Deployment with replicaCount (default 2) and a PodDisruptionBudget (minAvailable: 1). Replicas coordinate through NATS and PostgreSQL, never through in-process state, so you can run any number of them. You scale:

ServiceScale when
GatewayIngress concurrency and HTTP edge load
EngineClient-server API, sync and room load, and inbound federation
WorkerOutbound federation and background queue load
AuthToken verification and MAS integration load

Capacity also depends on the database, NATS, the network and the federation workload. A higher replica count alone does not remove those limits. Platform pieces (PostgreSQL, NATS, MAS) and the add-ons have their own replica settings.

Each service serves Prometheus metrics on port 2112 and the probe endpoints /livez and /readyz on the same port. The chart’s startup, readiness and liveness probes use them. ServiceMonitors render when the Prometheus Operator is installed.