Deployment Architecture
A production Wormkey deployment requires:- Control Plane - Node.js service (port 3001)
- Gateway - Go service (port 3002)
- TLS/SSL - HTTPS and secure WebSocket (wss://) support
Pre-Deployment Checklist
- Build artifacts created (
make build) - Environment variables configured for production
- TLS certificates obtained (Let’s Encrypt, Cloudflare, etc.)
- Domain names configured and DNS records set
- Firewall rules allow traffic on required ports
- Process manager or container orchestration configured
Building for Production
Deployment Platforms
Platform-Agnostic Considerations
Wormkey can be deployed to any platform that supports:- Node.js 18+ runtime (control plane)
- Go 1.20+ runtime or static binaries (gateway)
- WebSocket connections
- Environment variable configuration
Example: Render.com
The source code references Render.com in environment variables. Here’s the configuration:Example: Docker Deployment
Example: Systemd Services
For bare-metal or VM deployments:TLS/SSL Configuration
Option 1: Reverse Proxy (Recommended)
Use nginx or Caddy to terminate TLS and proxy to Wormkey services.Option 2: Cloudflare Tunnel
Cloudflare Tunnel provides automatic TLS without exposing ports:config.yml
Environment Variables for Production
Set these in your deployment platform:Control Plane
Gateway
State Management
For production, consider:- Sticky sessions - Route CLI connections to the same gateway instance
- Short restart windows - Minimize downtime during deploys
- Database integration (future) - Persist sessions to Redis, PostgreSQL, etc.
- Session expiration - Sessions auto-expire (default: 24h)
Monitoring and Health Checks
Both services expose health check endpoints:Control Plane
Gateway
- Interval: 30 seconds
- Timeout: 5 seconds
- Threshold: 3 consecutive failures trigger restart
Scaling Considerations
Current Limitations (v0)
- Single instance only - No horizontal scaling due to in-memory state
- No load balancing - Tunnel connections must reach the same gateway instance
- Connection limits - Default: 20 viewers per session (configurable)
Performance Characteristics
Based on the source code:- Stream chunk size: 32KB (
packages/gateway/main.go:974) - Control stream ID: 0 (reserved)
- Binary protocol: Low overhead for tunnel frames
- WebSocket multiplexing: Multiple HTTP streams over single WebSocket
Future Scaling Strategies
- Shared state backend - Redis for session/viewer state
- Gateway clustering - Consistent hashing for slug→instance routing
- Database persistence - PostgreSQL for session metadata
- Message queue - For cross-instance communication
Security Best Practices
- Use HTTPS/WSS in production (required)
- Set secure headers (X-Frame-Options, CSP, etc.)
- Rate limit session creation at control plane
- Configure firewall rules (allow only 443, block direct port access)
- Use environment variables for secrets (never hardcode)
- Enable CORS only for trusted origins
- Monitor for abnormal traffic patterns
- Implement request logging and audit trails
- Keep dependencies updated (
npm audit,go list -m all)
Troubleshooting Production Issues
Sessions not persisting
Cause: In-memory storage clears on restart. Solution: Accept this limitation in v0, or implement database persistence.WebSocket connections failing
Causes:- Reverse proxy not configured for WebSocket upgrade
- Firewall blocking WebSocket traffic
- TLS certificate issues
Control plane unreachable from gateway
Causes:- Network policy blocking internal traffic
- Wrong
WORMKEY_CONTROL_PLANEURL - Control plane not started
High memory usage
Cause: In-memory session storage grows over time. Mitigation:- Set shorter session expiration
- Implement periodic cleanup of expired sessions
- Restart services during low-traffic windows
CLI Configuration for Production
Users connecting to your self-hosted instance need to configure their CLI:Cost Optimization
Wormkey is lightweight and can run on minimal infrastructure:- Control Plane: 256MB RAM, 0.25 vCPU (handles session metadata only)
- Gateway: 512MB RAM, 0.5 vCPU (handles all proxy traffic)
- Storage: None required (in-memory only)
- Database: None required in v0
- Render/Railway: ~$10-20/month (2 services)
- DigitalOcean Droplet: ~$12/month (1 VM, both services)
- AWS Lightsail: ~$10/month (1 instance)
Next Steps
- Review Environment Variables reference
- Read the Protocol Specification to understand internals
- Set up monitoring and alerting
- Plan for database integration (future)
- Join the community for support