Architecture Overview
Production deployment consists of the following services:Region Strategy
- Primary region:
iad(Ashburn, Virginia) — co-located with the database for lowest latency. - Edge regions:
lhr(London),gru(São Paulo) — for faster API responses globally. - Sequin: Single instance in
iadonly. CDC requires a persistent WAL connection and must run next to the database. Multiple instances would cause duplicate event processing.
Secrets Management
All environment variables are managed via Doppler under thestrait project with three configs:
Local Development
Fly.io Integration
Secrets are synced from Doppler to Fly.io via the Doppler-Fly integration. When you update a secret in Doppler, it automatically propagates to Fly machines.Operation Modes
Strait can run in three different modes, controlled by the--mode flag or the MODE environment variable:
api: Runs only the HTTP API server. Stateless and can be scaled horizontally.worker: Runs only the job execution engine. Scales based on queue depth.all(Default): Runs both the API and the worker in a single process. Ideal for small deployments or development.
Infrastructure Requirements
Strait requires the following backing services:- PostgreSQL 18: Primary data store and job queue (uses
SKIP LOCKED). - Redis 8: Used for pub/sub, SSE streaming, and CDC event publishing.
- Sequin: Required for Change Data Capture (CDC) from the Postgres WAL.
Docker Compose (Development)
For local development, useapps/strait/docker-compose.yml:
Fly.io Deployment
Project Structure
Deploying the Main App
The Dockerfile uses a multi-stage build: Go compile on Alpine, then copy the binary to a minimal runtime image (~16 MB).go vet, golangci-lint, go build, go test) before pushing to Fly. If any check fails, the deploy is aborted.
Deploying Sequin
Sequin uses the officialsequin/sequin:latest Docker image — no build step needed.
fly secrets set):
CI/CD
The GitHub Actions workflow (.github/workflows/deploy.yml) automatically deploys to Fly when:
- Code is pushed to
master - Changes are in
apps/strait/** - All required workflows pass (
Test,Lint,Security)
FLY_API_TOKEN — generate a deploy token scoped to the app:
Production Configuration
Required Environment Variables
See Environment Variables for the full reference.
Scaling Strategy
For high-traffic production environments, it is recommended to separate the API and worker processes:- Scale API: Increase the number of instances running in
apimode to handle more concurrent HTTP requests. - Scale Workers: Increase the number of instances running in
workermode to process more jobs from the queue. Since workers useSKIP LOCKED, they can safely compete for jobs without double-processing.
Graceful Shutdown
Strait implements graceful shutdown for both the API and the worker:- API: Stops accepting new requests and waits for active requests to finish (up to the configured timeout).
- Worker: Stops dequeuing new jobs and waits for currently executing jobs to complete or reach a checkpoint before exiting.