A high-performance, production-ready WebSocket proxy and load balancer designed for distributed game server architectures. Atlas intelligently routes client connections across multiple Horizon game servers while providing seamless server transitions, real-time traffic analysis, and advanced spatial routing capabilities.
- Spatial Load Balancing - Route clients to servers based on 3D world coordinates
- Seamless Client Transfers - Move players between servers without connection drops
- WebSocket Proxy - High-performance TCP passthrough with WebSocket support
- Real-time Traffic Analysis - Non-blocking data skimming for monitoring and debugging
- Health Monitoring - Automatic server health checks with failover capabilities
- Dynamic Server Registration - Horizon servers register themselves with their region bounds
- Predictive Server Transitions - Detect client movement patterns to preload server instances
- Cross-Server Communication - Facilitate object and player transitions between server boundaries
- Maestro Integration - Works with Horizon-Maestro for auto-scaling
- Production-Ready Architecture - Comprehensive error handling, logging, and monitoring
Atlas operates as a spatial routing layer in front of your Horizon game server cluster:
βββββββββββββββββββ
Clients βββββββββββΊ β Atlas Proxy β βββββ Maestro (orchestrator)
β :9000/:9001 β
ββββββββββ¬βββββββββ
β Spatial Routing
βββββββββββββββββββββΌββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββ
β Horizon β β Horizon β β Horizon β
β (0,0,0) β β (1,0,0) β β (0,1,0) β
β :8080 β β :8081 β β :8082 β
βββββββββββββ βββββββββββββ βββββββββββββ
Region 0 Region 1 Region 2
- 9000 - Client WebSocket proxy port
- 9001 - REST API for server registration and management
proxy- Main proxy server and connection handlingserver- Backend server management and spatial routingclient- Client connection tracking and state managementtransfer- Server-to-server client migration systemspatial- 3D region management and coordinate routingskim- Real-time traffic analysis and monitoringconfig- Configuration managementerror- Comprehensive error handling and result types
- Rust 1.70+
- Horizon game servers running (or use with Maestro for auto-deployment)
git clone https://github.com/Far-Beyond-Dev/Horizon-Atlas
cd horizon-atlas
cargo build --release# Set environment variables
export ATLAS_PROXY_ADDR=0.0.0.0:9000
export ATLAS_API_ADDR=0.0.0.0:9001
export ATLAS_REGION_SIZE=1000.0
cargo runThe easiest way to run Atlas is via Horizon-Maestro, which automatically deploys and configures Atlas along with Horizon game servers:
cd Horizon-Maestro
MAESTRO_AUTO_BOOTSTRAP=true cargo runMaestro will:
- Deploy Atlas with proper configuration
- Deploy initial Horizon game server(s)
- Configure servers to register with Atlas automatically
| Variable | Default | Description |
|---|---|---|
ATLAS_PROXY_ADDR |
0.0.0.0:9000 |
Client WebSocket proxy address |
ATLAS_API_ADDR |
0.0.0.0:9001 |
REST API address |
ATLAS_MAESTRO_URL |
- | Maestro URL for auto-scaling requests |
ATLAS_REGION_SIZE |
1000.0 |
Size of each region in world units |
ATLAS_AUTO_SCALE |
false |
Request new regions from Maestro automatically |
Horizon servers register themselves with Atlas on startup:
# Register a server
curl -X POST http://localhost:9001/servers/register \
-H "Content-Type: application/json" \
-d '{
"server_id": "horizon-0-0-0",
"address": "127.0.0.1:8080",
"region": {"x": 0, "y": 0, "z": 0},
"center": {"x": 500.0, "y": 500.0, "z": 500.0},
"bounds_size": 500.0,
"capacity": 1000
}'| Endpoint | Method | Description |
|---|---|---|
GET /servers |
GET | List all registered servers |
POST /servers/register |
POST | Register a new server |
DELETE /servers/<id> |
DELETE | Unregister a server |
GET /servers/<id>/stats |
GET | Get server statistics |
POST /transfer |
POST | Initiate client transfer |
GET /health |
GET | Health check |
Atlas uses 3D spatial regions to route clients to the appropriate server:
// Each server manages a cubic region of the world
struct ServerRegion {
center: Vec3, // Center point (e.g., 500, 500, 500)
bounds_size: f64, // Half-size (e.g., 500 = 1000x1000x1000 cube)
region: (i32, i32, i32), // Region coordinates (0,0,0)
}
// When a client connects at position (750, 200, 300):
// Atlas finds the server whose region contains that position
// and routes the connection accordinglyWhen a client moves near a region boundary, Atlas:
- Detects the boundary approach via traffic analysis
- Notifies the target server to prepare
- Seamlessly transfers the client connection
- Maintains game state consistency
services:
atlas:
image: ghcr.io/far-beyond-dev/horizon-atlas:main
ports:
- "9000:9000" # Proxy
- "9001:9001" # API
environment:
- ATLAS_PROXY_ADDR=0.0.0.0:9000
- ATLAS_API_ADDR=0.0.0.0:9001
- ATLAS_MAESTRO_URL=http://maestro:8000
- ATLAS_REGION_SIZE=1000.0
- ATLAS_AUTO_SCALE=truedocker build -t horizon-atlas:local .src/
βββ main.rs # Application entry point
βββ lib.rs # Module declarations
βββ proxy.rs # Main proxy server logic
βββ server.rs # Backend server management
βββ client.rs # Client connection handling
βββ transfer.rs # Client migration system
βββ spatial.rs # 3D region management
βββ skim.rs # Traffic analysis
βββ config.rs # Configuration management
βββ persistence.rs # State persistence
βββ error.rs # Error types and handling
Atlas is part of the Horizon distributed game server ecosystem:
- Horizon - The game server instances that Atlas routes to
- Horizon-Maestro - Orchestrator that deploys Atlas and Horizon
- Horizon-Network-Common - Shared API types for communication
Client β Atlas (spatial routing) β Horizon Server
β
Maestro (scaling requests)
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation - Website
- Issues - GitHub Issues
- Discussions - GitHub Discussions
Atlas - Intelligent spatial proxy for distributed Horizon game servers.
