A high-performance, scalable WebSocket server implementing the Pusher protocol in Rust.
- 🚀 High Performance - Handle 100K+ concurrent connections
- 🔄 Pusher Compatible - Drop-in replacement for Pusher services
- 🏗️ Scalable Architecture - Redis, Redis Cluster, NATS adapters
- 🛡️ Production Ready - Rate limiting, SSL/TLS, metrics
- ⚡ Async Cleanup - Non-blocking disconnect handling
- 📊 Real-time Metrics - Prometheus integration
# Clone and start with Docker Compose
git clone https://github.com/RustNSparks/sockudo.git
cd sockudo
make up
# Server runs on http://localhost:6001
# Metrics on http://localhost:9601/metrics# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build and run
git clone https://github.com/RustNSparks/sockudo.git
cd sockudo
# Fast local development build (default - no external dependencies)
cargo run --release
# Production build with all features
cargo run --release --features fullSockudo supports optional compilation of backends to speed up local development:
# Local development (fastest - default)
cargo build # ~30-50% faster compile
# With specific backends
cargo build --features "redis,postgres" # Redis + PostgreSQL
cargo build --features "redis-cluster,mysql" # Redis Cluster + MySQL
# Full production build
cargo build --release --features full # All backendsAvailable Features:
local(default) - In-memory implementations onlyredis- Redis adapter, cache, queue, rate limiterredis-cluster- Redis Cluster supportnats- NATS adaptermysql/postgres/dynamodb- Database backendssqs/lambda- AWS integrationsfull- All features enabled
Connect using any Pusher-compatible client:
import Pusher from 'pusher-js';
const pusher = new Pusher('app-key', {
wsHost: 'localhost',
wsPort: 6001,
cluster: '',
forceTLS: false
});
const channel = pusher.subscribe('my-channel');
channel.bind('my-event', (data) => {
console.log('Received:', data);
});# Basic settings
PORT=6001
HOST=0.0.0.0
DEBUG=false
# Default app credentials
SOCKUDO_DEFAULT_APP_ID=app-id
SOCKUDO_DEFAULT_APP_KEY=app-key
SOCKUDO_DEFAULT_APP_SECRET=app-secret
# Scaling drivers
ADAPTER_DRIVER=redis # local, redis, redis-cluster, nats
CACHE_DRIVER=redis # memory, redis, redis-cluster, none
QUEUE_DRIVER=redis # memory, redis, redis-cluster, sqs, none# Connection limits
SOCKUDO_DEFAULT_APP_MAX_CONNECTIONS=100000
SOCKUDO_DEFAULT_APP_MAX_CLIENT_EVENTS_PER_SECOND=10000
# Cleanup performance (for handling mass disconnects)
CLEANUP_QUEUE_BUFFER_SIZE=50000
CLEANUP_BATCH_SIZE=25
CLEANUP_WORKER_THREADS=auto
# CPU scaling
ADAPTER_BUFFER_MULTIPLIER_PER_CPU=128- Global defaults (apply to all SQL DBs unless overridden):
DATABASE_POOLING_ENABLED=true
DATABASE_POOL_MIN=2
DATABASE_POOL_MAX=10
# Legacy cap if pooling disabled
DATABASE_CONNECTION_POOL_SIZE=10- Per‑database overrides (take precedence over global when set):
# MySQL
DATABASE_MYSQL_POOL_MIN=4
DATABASE_MYSQL_POOL_MAX=32
# PostgreSQL
DATABASE_POSTGRES_POOL_MIN=2
DATABASE_POSTGRES_POOL_MAX=16- config/config.json keys:
{
"database_pooling": { "enabled": true, "min": 2, "max": 10 },
"database": {
"mysql": { "pool_min": 2, "pool_max": 10, "connection_pool_size": 10 },
"postgres": { "pool_min": 2, "pool_max": 10, "connection_pool_size": 10 }
}
}Behavior:
- When
database_pooling.enabledis true, managers use per‑DBpool_min/pool_maxif provided; otherwise they fall back to the globaldatabase_pooling.min/max. - When disabled, managers use
connection_pool_sizeas the max connections for backward compatibility.
| Scenario | CPU/RAM | Adapter | Cache | Queue | Max Connections |
|---|---|---|---|---|---|
| Development | 1vCPU/1GB | local | memory | memory | 1K |
| Small Production | 2vCPU/2GB | redis | redis | redis | 10K |
| High Traffic | 4vCPU/4GB+ | redis | redis | redis | 50K+ |
| Multi-Region | 8vCPU/8GB+ | redis-cluster | redis-cluster | redis-cluster | 100K+ |
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Load Balancer │────│ Sockudo Node │────│ Redis Cluster │
│ (Nginx) │ │ (Rust/Tokio) │ │ (State Store) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
└──────────────│ Sockudo Node │─────────────┘
│ (Rust/Tokio) │
└─────────────────┘
- Full Documentation - Complete setup and configuration guide
- Performance Tuning - Optimize for your workload
- Docker Deployment - Production-ready containers
- API Reference - WebSocket and HTTP API details
# Run all tests
make test
# Interactive WebSocket testing
cd test/interactive && npm install && npm start
# Open http://localhost:3000
# Load testing
make benchmark- 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
Licensed under the MIT License.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: sockudo.app
- Discord: Join our Discord
- X: @sockudorealtime
- Email: sockudorealtime