Repository navigation
deployment
Ferdi ÜNAL edited this page Jan 25, 2026
·
3 revisions
This guide covers production deployment strategies for Soketi.rs.
docker run -d \
--name soketi \
-p 6001:6001 \
-p 9601:9601 \
-v $(pwd)/config.json:/app/config.json:ro \
--restart unless-stopped \
soketi-rs:latestversion: '3.8'
services:
soketi:
image: soketi-rs:latest
ports:
- "6001:6001"
- "9601:9601"
volumes:
- ./config.json:/app/config.json:ro
environment:
- RUST_LOG=info
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2'
memory: 1Gversion: '3.8'
services:
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
command: redis-server --appendonly yes
soketi:
image: soketi-rs:latest
ports:
- "6001-6003:6001"
volumes:
- ./config.json:/app/config.json:ro
environment:
- RUST_LOG=info
depends_on:
- redis
deploy:
replicas: 3
volumes:
redis-data:apiVersion: apps/v1
kind: Deployment
metadata:
name: soketi
labels:
app: soketi
spec:
replicas: 3
selector:
matchLabels:
app: soketi
template:
metadata:
labels:
app: soketi
spec:
containers:
- name: soketi
image: soketi-rs:latest
ports:
- containerPort: 6001
name: websocket
- containerPort: 9601
name: metrics
env:
- name: RUST_LOG
value: "info"
volumeMounts:
- name: config
mountPath: /app/config.json
subPath: config.json
resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "1Gi"
cpu: "2000m"
livenessProbe:
httpGet:
path: /
port: 6001
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 6001
initialDelaySeconds: 5
periodSeconds: 5
volumes:
- name: config
configMap:
name: soketi-configapiVersion: v1
kind: Service
metadata:
name: soketi
spec:
type: LoadBalancer
ports:
- port: 6001
targetPort: 6001
name: websocket
- port: 9601
targetPort: 9601
name: metrics
selector:
app: soketiapiVersion: v1
kind: ConfigMap
metadata:
name: soketi-config
data:
config.json: |
{
"host": "0.0.0.0",
"port": 6001,
"adapter": {
"driver": "Redis",
"redis": {
"host": "redis-service",
"port": 6379
}
}
}apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: soketi-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: soketi
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80{
"family": "soketi",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "1024",
"memory": "2048",
"containerDefinitions": [
{
"name": "soketi",
"image": "soketi-rs:latest",
"portMappings": [
{
"containerPort": 6001,
"protocol": "tcp"
}
],
"environment": [
{
"name": "RUST_LOG",
"value": "info"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/soketi",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}- Target Group: WebSocket protocol
- Health Check: HTTP on port 6001
- Sticky Sessions: Enabled
- Connection Draining: 300 seconds
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: soketi
spec:
template:
spec:
containers:
- image: gcr.io/project-id/soketi-rs:latest
ports:
- containerPort: 6001
env:
- name: RUST_LOG
value: "info"
resources:
limits:
memory: "1Gi"
cpu: "2000m"az container create \
--resource-group soketi-rg \
--name soketi \
--image soketi-rs:latest \
--ports 6001 9601 \
--cpu 2 \
--memory 2 \
--environment-variables RUST_LOG=infoupstream soketi {
least_conn;
server soketi1:6001;
server soketi2:6001;
server soketi3:6001;
}
server {
listen 80;
server_name ws.example.com;
location / {
proxy_pass http://soketi;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket timeouts
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
}
}frontend websocket
bind *:80
mode http
option http-server-close
option forwardfor
default_backend soketi_servers
backend soketi_servers
mode http
balance leastconn
option httpchk GET /
server soketi1 soketi1:6001 check
server soketi2 soketi2:6001 check
server soketi3 soketi3:6001 check
scrape_configs:
- job_name: 'soketi'
static_configs:
- targets: ['soketi:9601']
metrics_path: '/metrics'
scrape_interval: 10sImport dashboard ID: soketi-rs-dashboard
Key metrics to monitor:
- Active connections
- Messages per second
- CPU usage
- Memory usage
- Error rate
- Latency
groups:
- name: soketi
rules:
- alert: HighConnectionCount
expr: soketi_connections > 80000
for: 5m
labels:
severity: warning
annotations:
summary: "High connection count"
- alert: HighErrorRate
expr: rate(soketi_errors_total[5m]) > 10
for: 5m
labels:
severity: critical
annotations:
summary: "High error rate"{
"ssl": {
"enabled": true,
"cert_path": "/etc/ssl/certs/server.crt",
"key_path": "/etc/ssl/private/server.key"
}
}# Allow WebSocket
ufw allow 6001/tcp
# Allow Metrics (internal only)
ufw allow from 10.0.0.0/8 to any port 9601
# Deny all other traffic
ufw default deny incomingapiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: soketi-policy
spec:
podSelector:
matchLabels:
app: soketi
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: nginx
ports:
- protocol: TCP
port: 6001
egress:
- to:
- podSelector:
matchLabels:
app: redis
ports:
- protocol: TCP
port: 6379- Use Redis for clustering in production
- Enable metrics and set up monitoring
- Configure health checks for automatic recovery
- Set resource limits to prevent resource exhaustion
- Use SSL/TLS for secure connections
- Implement rate limiting to prevent abuse
- Set up log aggregation for debugging
- Use sticky sessions with load balancers
- Configure connection timeouts appropriately
- Regular backups of configuration and data
- Check connection count
- Review message size limits
- Enable connection pooling
- Increase instance count
- Check load balancer timeout settings
- Verify network stability
- Review rate limiting configuration
- Check Redis connectivity
- Enable Redis adapter
- Increase CPU allocation
- Review database queries
- Check network latency
For more information, see the main documentation.