Skip to main content
This guide covers deploying Enclave to production environments, including configuration, monitoring, and operational best practices.

Deployment Architecture

Single-Server Deployment

For smaller workloads:

Several Servers

For production scale, run several instances of the server that executes scripts (your application with @enclave-vm/core, or an EnclaveJS broker) behind a load balancer. A session of a broker lives in the memory of the broker that created it, so route a session’s later requests to the same instance. The packages have no shared session store and no separate execution tier: @enclave-vm/runtime does not execute scripts yet.

Pre-Deployment Checklist

Security

  • Set securityLevel: 'STRICT' for untrusted code
  • Configure memory limits: the sandbox’s memoryLimit is an estimate, so give the container a limit as well
  • Set appropriate timeouts
  • Authenticate callers in front of every endpoint that accepts code, and in front of every session route of the EnclaveJS broker (the broker has no authentication of its own)
  • Give the broker’s session routes an identify hook, so that a session belongs to the caller that created it (see below)
  • Use HTTPS: the EnclaveJS client and broker exchange plain JSON
  • Enable input validation
  • Review tool permissions
  • Consider the AI Scoring Gate as an additional, heuristic signal
Authentication in front of the broker does not tell its routes whose session is whose: without an identify hook they answer every caller for every session (the list of sessions, a session’s state and events, and the request to end it). The hook returns the caller your authentication found:
A request for which the hook returns no identity is answered with 401, and a session is answered only for the caller that created it. The hook can be left out only where a single trusted backend is the one caller of the routes. See Who may see a session.

Performance

  • Configure worker pool for CPU-bound loads
  • With several brokers, route a session’s requests to the broker that created it
  • Configure connection pooling
  • Enable response compression
  • Set up CDN for static assets

Monitoring

  • Configure logging
  • Set up metrics collection
  • Configure alerting
  • Enable tracing
  • Set up error tracking

Infrastructure

  • Configure auto-scaling
  • Set up health checks
  • Configure load balancer
  • Set up SSL/TLS
  • Configure DNS

Configuration

Environment Variables

Production Configuration

Docker Deployment

Dockerfile

Docker Compose

Kubernetes Deployment

Deployment Manifest

Service and Ingress

Monitoring

Health Endpoints

Metrics

Structured Logging

Error Handling

Global Error Handler

Graceful Shutdown

Security Hardening

Rate Limiting

Request Validation

Performance Tuning

Connection Pooling

Deployment Platforms

Vercel

Railway

Render