Sockudo Guide
Welcome to the Sockudo guide! This comprehensive documentation will walk you through everything you need to know to get Sockudo up and running, configure it for your needs, and understand its core features.
Sockudo is a high-performance WebSocket server built in Rust that is compatible with the Pusher protocol. This means you can use existing Pusher client libraries (like Laravel Echo, pusher-js, and others) to connect to Sockudo and build real-time applications.
What is Sockudo?
Sockudo provides real-time, bidirectional communication between clients and servers using WebSockets. Key features include:
- Pusher Protocol Compatibility: Drop-in replacement for Pusher with existing client libraries
- High Performance: Built in Rust for speed and efficiency
- Horizontal Scaling: Multiple adapters for scaling across instances (Redis, NATS, Redis Cluster)
- Flexible Storage: Support for MySQL, PostgreSQL, DynamoDB, and in-memory app management
- Comprehensive Features: Rate limiting, webhooks, metrics, SSL/TLS, and more
- Docker Ready: Full Docker and Kubernetes support for modern deployments
Quick Navigation
Getting Started
- Getting Started: Install and run your first Sockudo server
- Channels: Understand public, private, and presence channels
- Configuration: Comprehensive configuration guide
Core Features
- Webhooks: Set up event notifications to your application
- Scaling: Scale Sockudo using different adapters and load balancing
- Monitoring: Monitor performance with Prometheus and Grafana
Operations
- Deployment: Production deployment strategies and best practices
- Troubleshooting: Diagnose and solve common issues
- SSL Configuration: Secure your connections with SSL/TLS
Architecture Overview
Sockudo is designed with modularity and scalability in mind:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Client Apps │ │ Load Balancer │ │ Sockudo │
│ (Browser/App) │◄──►│ (Nginx/HAProxy│◄──►│ Instances │
│ │ │ /K8s Ingress) │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌────────────────────────┼────────────────────────┐
│ │ │
┌─────────▼────────┐ ┌─────────▼────────┐ ┌─────────▼────────┐
│ Adapter │ │ App Manager │ │ Cache │
│ (Redis/NATS/ │ │ (Memory/MySQL/ │ │ (Memory/Redis) │
│ Local/Cluster) │ │ Postgres/Dynamo)│ │ │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
┌─────────▼────────┐ ┌─────────▼────────┐ ┌─────────▼────────┐
│ Queue │ │ Rate Limiter │ │ Webhooks │
│ (Memory/Redis/ │ │ (Memory/Redis) │ │ (HTTP/Lambda) │
│ SQS/Cluster) │ │ │ │ │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Key Components
- Adapter: Handles message broadcasting between instances for horizontal scaling
- App Manager: Manages application credentials and settings
- Cache: Improves performance by caching frequently accessed data
- Queue: Processes background tasks like webhook delivery
- Rate Limiter: Protects against abuse and ensures fair usage
- Metrics: Provides observability via Prometheus-compatible endpoints
Use Cases
Sockudo is perfect for building:
Real-Time Applications
- Live Chat Systems: Multi-user chat rooms with presence indicators
- Collaborative Tools: Real-time document editing, whiteboards
- Gaming: Multiplayer games with real-time state synchronization
- Live Updates: News feeds, social media updates, notification systems
Business Applications
- Dashboard Updates: Real-time analytics and monitoring dashboards
- Order Tracking: Live order status updates for e-commerce
- Customer Support: Real-time customer service chat
- Financial Data: Live stock prices, trading platforms
IoT and Monitoring
- Device Monitoring: Real-time sensor data and device status
- Alert Systems: Instant notifications for critical events
- Live Metrics: System performance and health monitoring
Channel Types
Sockudo supports three types of channels, each designed for different use cases:
Public Channels
- No authentication required
- Open to all clients
- Perfect for: Public announcements, news feeds, general updates
const channel = pusher.subscribe('news-updates');
channel.bind('breaking-news', function(data) {
console.log('Breaking news:', data);
});
Private Channels
- Require authentication
- Secure user-specific data
- Perfect for: User notifications, private messages, secure updates
const channel = pusher.subscribe('private-user-123');
channel.bind('new-message', function(data) {
console.log('Private message:', data);
});
Presence Channels
- Require authentication
- Track who's online
- Perfect for: Chat rooms, collaborative editing, multiplayer games
const channel = pusher.subscribe('presence-chat-room');
channel.bind('pusher:member_added', function(member) {
console.log('User joined:', member.id, member.info);
});
Getting Started Path
If you're new to Sockudo, we recommend following this learning path:
1. Quick Start (30 minutes)
- Install and run Sockudo with default settings
- Test basic connectivity with a simple WebSocket client
- Send your first event via the HTTP API
2. Basic Configuration (1 hour)
- Configure your first application with custom credentials
- Set up channels and understand the different types
- Enable basic monitoring to see what's happening
3. Production Preparation (2-4 hours)
- Configure SSL/TLS for secure connections
- Set up webhooks to react to events
- Plan your scaling strategy with appropriate adapters
4. Advanced Topics (As needed)
- Deploy to production with Docker/Kubernetes
- Set up comprehensive monitoring with Prometheus/Grafana
- Implement advanced features like rate limiting and caching
Configuration Overview
Sockudo's configuration is highly flexible and supports both JSON files and environment variables:
{
"debug": false,
"host": "0.0.0.0",
"port": 6001,
"adapter": {
"driver": "redis"
},
"app_manager": {
"driver": "mysql"
},
"cache": {
"driver": "redis"
},
"metrics": {
"enabled": true,
"port": 9601
}
}
Or using environment variables:
HOST=0.0.0.0
PORT=6001
ADAPTER_DRIVER=redis
APP_MANAGER_DRIVER=mysql
CACHE_DRIVER=redis
METRICS_ENABLED=true
Client Library Compatibility
Sockudo works with standard Pusher client libraries:
JavaScript (Browser)
import Pusher from 'pusher-js';
const pusher = new Pusher('your-app-key', {
wsHost: 'your-sockudo-server.com',
wsPort: 6001,
forceTLS: true
});
Laravel Echo
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'your-app-key',
wsHost: 'your-sockudo-server.com',
wsPort: 6001,
forceTLS: true
});
PHP
use Pusher\Pusher;
$pusher = new Pusher(
'your-app-key',
'your-app-secret',
'your-app-id',
[
'host' => 'your-sockudo-server.com',
'port' => 6001,
'scheme' => 'https'
]
);
Community and Support
Documentation
- Complete Configuration Reference: Detailed configuration options
- Troubleshooting Guide: Solutions for common issues
- Deployment Guide: Production deployment strategies
Getting Help
- GitHub Issues: Report bugs or request features
- GitHub Repository: Source code and documentation
Community
- Check the project's GitHub repository for the latest updates and community discussions
- Review the main README.md file in the repository root for additional information
- Look for examples and sample configurations in the project repository
What's Next?
Ready to get started? Here are your next steps:
- Begin with Getting Started to install and run Sockudo
- Explore Channels to understand how real-time communication works
- Dive into Configuration to customize Sockudo for your needs
- Set up Monitoring to keep track of your server's performance
- Plan for Production Deployment when you're ready to go live
Whether you're building a simple chat application or a complex real-time system, Sockudo provides the performance, reliability, and flexibility you need to succeed.
Welcome to the world of high-performance real-time communication with Sockudo! 🚀