Performance Optimization
Beam offers three tunnel modes to balance speed and privacy. Choose the right mode for your use case and optimize performance with caching, circuit prebuilding, and geographic relay selection.
Tunnel Modes
Low - IP visible to peer
No
beam 3000 --mode=fastMedium - Server exposed, clients hidden
Yes
beam 3000 --mode=balancedHigh - Full anonymity
Yes
beam 3000 --mode=privateComparison with Other Tools
| Tool | Type | Encryption | Latency | Privacy |
|---|---|---|---|---|
| Beam (fast) | Direct P2P | E2E | ~30-50ms | Low |
| Beam (balanced) | Single-hop Tor | E2E + Tor | ~80-150ms | Medium |
| Beam (private) | 3-hop Tor | E2E + Tor | ~200-500ms | High |
| ngrok | Centralized | TLS | ~50-100ms | Low |
| Cloudflare Tunnel | Edge Network | TLS + WAF | ~20-50ms | Low |
| Tailscale | Mesh VPN | WireGuard | ~30-80ms | Medium |
| LocalTunnel | Centralized | TLS | ~100-200ms | Low |
Performance Optimizations
Pre-establishes Tor circuits before they're needed, eliminating the 2-3 second circuit build time on first request.
beam 3000 --prebuild-circuits=5Default: 3 circuits. More circuits = faster failover but higher memory.
Caches static assets (JS, CSS, images, fonts) to reduce round-trips through Tor. Especially effective for balanced and private modes.
beam 3000 --cache-size=200beam 3000 --cache-ttl=600Default: 100MB cache, 300s TTL. Disable with --no-cache.
Select Tor relays closer to your location for reduced latency. Uses ISO 3166-1 country codes.
beam 3000 --geo-prefer=US,CA,MXNot recommended for private mode - reduces anonymity by constraining relay selection.
Keeps Tor circuits alive between requests, avoiding reconnection overhead. Enabled by default in balanced and private modes.
# Automatic - circuits persist for session durationCircuits automatically rebuild on failure or after extended idle periods.
Best Practices by Use Case
Webhook Development
beam 3000 --mode=balanced --prebuild-circuits=3 --cache-ttl=60Balanced mode provides .onion address for webhooks while keeping latency reasonable. Lower cache TTL since webhook payloads change frequently.
Real-time Applications
beam 3000 --mode=fast --no-cacheFast mode with disabled caching for WebSocket and real-time data. Lowest latency but requires trusted network.
Privacy-Sensitive Testing
beam 3000 --mode=private --prebuild-circuits=5 --no-cacheFull Tor anonymity with extra prebuilt circuits for reliability. Caching disabled to prevent data persistence.
High-Traffic Static Sites
beam 3000 --mode=balanced --cache-size=500 --cache-ttl=3600 --geo-prefer=USLarge cache with long TTL for static assets. Geographic optimization for US-based users. Great for demos and presentations.
Performance Troubleshooting
High Latency in Balanced/Private Mode
- Increase prebuild circuit count:
--prebuild-circuits=5 - Try geographic optimization:
--geo-prefer=YOUR_COUNTRY - Enable verbose logging to identify bottlenecks:
-v - Check if Tor is running properly:
tor --verify-config
Slow First Request
- Circuit building takes 2-3 seconds on first connection
- Enable circuit prebuilding (default) to eliminate this delay
- Consider fast mode for development where privacy isn't critical
Cache Not Working
- Only static assets are cached (JS, CSS, images, fonts)
- Check if your responses include proper Cache-Control headers
- Private mode disables caching by default for security
- Increase cache size if serving large assets:
--cache-size=200
Performance CLI Options
| Option | Default | Description |
|---|---|---|
| --mode | balanced | Tunnel mode: fast, balanced, or private |
| --cache-size | 100 | Cache size in MB |
| --cache-ttl | 300 | Cache TTL in seconds |
| --no-cache | false | Disable response caching |
| --geo-prefer | - | Preferred relay countries (ISO codes) |
| --prebuild-circuits | 3 | Number of circuits to prebuild |
| --no-prebuild | false | Disable circuit prebuilding |