Vast.ai Deployment Improvements (February 2026)
This document describes the comprehensive improvements made to Vast.ai deployment for GPU-accelerated streaming and duel hosting.Overview
The Vast.ai deployment has been significantly enhanced with better reliability, audio capture, database persistence, and diagnostic capabilities. These changes ensure stable 24/7 streaming with automatic recovery.Major Improvements
1. PulseAudio Audio Capture
What: Capture game audio (music and sound effects) for streaming. Implementation:- User-mode PulseAudio (more reliable than system mode)
- Virtual sink (
chrome_audio) for audio routing - Automatic fallback to silent audio if PulseAudio fails
- XDG runtime directory at
/tmp/pulse-runtime
2. DATABASE_URL Persistence
Problem:DATABASE_URL was lost during git reset operations in deployment.
Solution: Write secrets to /tmp before git reset, restore after:
3. Database Warmup
Problem: Cold start issues with PostgreSQL connection pool. Solution: Warmup step after schema push with 3 retry attempts:4. Stream Key Management
Problem: Stale stream keys in environment overrode correct values from secrets. Solution: Explicit unset and re-export before PM2 start:5. YouTube Removal
What: YouTube streaming explicitly disabled from default destinations. Why: Focusing on Twitch, Kick, and X for lower latency and better live betting experience. Implementation:6. Streaming Diagnostics
What: Comprehensive diagnostic output after deployment. Includes:- Streaming API state
- Game client status (port 3333)
- RTMP status file
- FFmpeg processes
- PM2 logs (filtered for streaming keywords)
7. Solana Keypair Setup
What: Automated Solana keypair configuration from environment variable. Implementation:~/.config/solana/id.json
Impact: Keeper bot and Anchor tools work without manual keypair setup.
8. Health Checking
What: Wait for server health before considering deployment successful. Implementation:Deployment Flow
Complete Deployment Sequence
Port Mappings
| Internal | External | Service |
|---|---|---|
| 5555 | 35143 | HTTP API |
| 5555 | 35079 | WebSocket |
| 8080 | 35144 | CDN |
Configuration
GitHub Secrets
Required secrets for Vast.ai deployment:Workflow Triggers
Environment Variables
Monitoring
PM2 Commands
Health Checks
Diagnostic Logs
Troubleshooting
Deployment Fails
Check:- SSH connection to Vast instance
- GitHub secrets are set
- Vast instance has enough disk space
Database Connection Fails
Check:DATABASE_URLis set in/tmp/hyperscape-secrets.env- Database is accessible from Vast instance
- Warmup step completed successfully
PulseAudio Not Working
Check:- PulseAudio is running
chrome_audiosink exists- XDG_RUNTIME_DIR is set
Stream Not Appearing
Check:- Stream keys are configured
- FFmpeg is running
- RTMP connection is established
Health Check Timeout
Check:- Server is actually starting
- No port conflicts
- Database connection works
Performance
Resource Usage
| Resource | Idle | Streaming | Peak |
|---|---|---|---|
| CPU | 10-15% | 30-40% | 60% |
| RAM | 2GB | 3GB | 4GB |
| GPU | 5% | 20-30% | 50% |
| Network | 1Mbps | 5Mbps | 10Mbps |
Optimization Tips
-
Reduce video bitrate for lower bandwidth:
-
Disable audio if not needed:
-
Use lower resolution:
-
Disable model agents for lower CPU:
Best Practices
1. Monitor Logs
Always monitor logs after deployment:2. Verify Health
Check health endpoint before considering deployment successful:3. Test Streaming
Verify stream is live on all platforms:4. Backup Secrets
Keep backup of secrets file:Related Documentation
- docs/streaming-audio-capture.md - PulseAudio setup
- docs/streaming-improvements-feb-2026.md - Streaming changes
- docs/duel-stack.md - Duel system architecture
- scripts/deploy-vast.sh - Deployment script
- ecosystem.config.cjs - PM2 configuration