Skip to content

Deployment overview

A single-process Zocket app (Bun adapter + WebSocket) is all you need to get started. For multi-region, multi-tenant, or hosted deployments you split the system into three processes connected by NATS JetStream.

Client ─► Gateway ─► NATS JetStream ─► Runtime ─► Actor code
▲ │ │
└──── OUTBOUND ◄──────┴────────────────┘
ProcessPackageResponsibility
Gateway@zocket/gatewayTerminates WebSockets, authenticates sessions, bridges WS ↔ NATS
Runtime@zocket/runtimeHosts actor instances, executes methods, publishes state patches
NATS / JetStream@zocket/nats-transportDurable work-queue (inbound) + per-session outbound buffer

The control plane (the hosted platform or your own build) sits alongside and handles auth, project config, and bundle storage. Gateways and runtimes call it over HTTP, not NATS.

See the architecture page for the full NATS subject map and actor execution model.

  • All three processes share one NATS cluster.
  • Gateways are stateless and horizontally scalable — add more to handle more WebSockets.
  • Runtimes are keyed by project + deployment. A project typically has one runtime (scaled vertically), but NATS work-queue semantics mean you can run multiple runtimes behind the same consumer name if your actors are stateless enough to tolerate instance migration.
  • The control plane is the only component that talks to your database and object store.

docker-compose.yml at the repo root spins up NATS + gateway + runtime for local testing.

Terminal window
docker compose up

This starts:

  • natsnats:2.10-alpine with JetStream enabled (--jetstream --store_dir /data), ports 4222 (client) and 8222 (monitoring)
  • gateway — built from packages/gateway/Dockerfile, exposed on host port 3001
  • runtime — built from packages/runtime/Dockerfile, exposed on host port 8080

You’ll still need a running control plane (your platform instance or the hosted one) — set CONTROL_PLANE_URL on both gateway and runtime.

VariableGatewayRuntimeNotes
NATS_URLDefault nats://localhost:4222
CONTROL_PLANE_URLDefault http://localhost:3000
CONTROL_PLANE_INTERNAL_TOKENShared secret for /api/internal/* calls
PORTHTTP port, default 3000
API_PORTHealth/report API, default 8080
BUNDLE_DIRWhere bundles are stored on disk, default /app/bundles
DEPLOYMENT_IDrequiredFails to start if unset
WORKSPACE_ID / PROJECT_IDDefault to local-workspace / local-project

Full reference on the Gateway, Runtime, and NATS transport pages.