Sockudo
A high-performance, scalable WebSocket server implementing the Pusher protocol in Rust.
Star History
Features
- 🚀 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
Quick Start
Docker (Recommended)
# Clone and start with Docker Compose
# Server runs on http://localhost:6001
# Metrics on http://localhost:9601/metrics
From Source
# Install Rust (if not already installed)
|
# Build and run
Basic Usage
Connect using any Pusher-compatible client:
import Pusher from 'pusher-js';
const pusher = ;
const channel = pusher.;
channel.;
Configuration
Environment Variables
# 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
Performance Tuning
# 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
Deployment Scenarios
| 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+ |
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Load Balancer │────│ Sockudo Node │────│ Redis Cluster │
│ (Nginx) │ │ (Rust/Tokio) │ │ (State Store) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
└──────────────│ Sockudo Node │─────────────┘
│ (Rust/Tokio) │
└─────────────────┘
Documentation
- 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
Testing
# Run all tests
# Interactive WebSocket testing
&& &&
# Open http://localhost:3000
# Load testing
Contributing
- 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
License
Licensed under the MIT License.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: sockudo.app
- Discord: Join our Discord
- X: @sockudorealtime
- Email: sockudorealtime