LiveKit Node Deployment
When a single server cannot meet concurrency requirements, you can deploy multiple LiveKit nodes to expand the cluster.
Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ Master Server │
│ TgoRTC Server + MySQL + Redis + LiveKit + Nginx │
└─────────────────────────────────────────────────────────────┘
↑
Redis Sync (6380)
Webhook Callback (8080)
↓
┌─────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│LiveKit │ │LiveKit │ │LiveKit │
│Node 1 │ │Node 2 │ │Node 3 │
└─────────┘ └─────────┘ └─────────┘
Step 1: Get Master Server Info
Run the following command on the master server to get key configuration:
cat ~/tgortc/.env
You need to record 4 items:
| Info | Field | Description |
|---|---|---|
| Master server IP | - | Public IP address |
| Redis password | REDIS_PASSWORD | Required for node to connect Redis |
| LiveKit API Key | LIVEKIT_API_KEY | Must be the same across all nodes |
| LiveKit API Secret | LIVEKIT_API_SECRET | Must be the same across all nodes |
Step 2: Deploy Node
Run the one-click deployment script on a new server.
Required Parameters
| Parameter | Description |
|---|---|
--master-ip | Master server IP address |
--redis-password | Redis password (same as master server) |
--livekit-key | LiveKit API Key (same as master server) |
--livekit-secret | LiveKit API Secret (same as master server) |
Optional Parameters
| Parameter | Description | Default |
|---|---|---|
--cn | Use China mirror acceleration | - |
--tgortc-url | TgoRTC Server address (for Webhook callback) | http://<master-ip>:8080 |
--node-ip | This node's public IP | Auto-detected |
--redis-port | Redis port | 6380 |
--dir | Deployment directory | ~/livekit-node |
China Servers
curl -fsSL https://gitee.com/No8blackball/tgo-rtcserver/raw/main/scripts/deploy-livekit-node.sh | sudo bash -s -- \
--cn \
--master-ip <MASTER_SERVER_IP> \
--redis-password "<REDIS_PASSWORD>" \
--livekit-key "<LIVEKIT_API_KEY>" \
--livekit-secret "<LIVEKIT_API_SECRET>"
Overseas Servers
curl -fsSL https://raw.githubusercontent.com/TgoRTC/TgoRTCServer/main/scripts/deploy-livekit-node.sh | sudo bash -s -- \
--master-ip <MASTER_SERVER_IP> \
--redis-password "<REDIS_PASSWORD>" \
--livekit-key "<LIVEKIT_API_KEY>" \
--livekit-secret "<LIVEKIT_API_SECRET>"
If the master server has a domain configured, you can specify the Webhook callback address with --tgortc-url:
curl -fsSL ... | sudo bash -s -- \
--cn \
--master-ip <MASTER_SERVER_IP> \
--redis-password "<REDIS_PASSWORD>" \
--livekit-key "<LIVEKIT_API_KEY>" \
--livekit-secret "<LIVEKIT_API_SECRET>" \
--tgortc-url "https://api.example.com"
Step 3: Configure Master Server
After node deployment, go back to the master server and add the new node to load balancing:
cd ~/tgortc
# Edit .env file, add or modify LIVEKIT_NODES (multiple nodes separated by commas)
# LIVEKIT_NODES=node1IP:7880,node2IP:7880
nano .env
# Reload Nginx configuration
./deploy.sh reload-nginx
Step 4: Verify Cluster
# Test node connectivity from master server
curl http://<NODE_IP>:7880
# View node info on the node server
cd ~/livekit-node
./deploy-livekit-node.sh info
Node Management
All management commands are executed on the node server:
cd ~/livekit-node
./deploy-livekit-node.sh info # View node info
./deploy-livekit-node.sh status # Check service status
./deploy-livekit-node.sh logs # View logs
./deploy-livekit-node.sh restart # Restart service
./deploy-livekit-node.sh update # Update LiveKit
./deploy-livekit-node.sh stop # Stop service
sudo ./deploy-livekit-node.sh firewall # Configure firewall
Port Reference
The node server needs to open the following ports (cloud security group + system firewall):
| Port | Protocol | Purpose |
|---|---|---|
| 7880 | TCP | LiveKit HTTP/WebSocket |
| 7881 | TCP | LiveKit RTC TCP |
| 3478 | UDP | TURN UDP |
| 5349 | TCP | TURN TLS |
| 50000-50100 | UDP | WebRTC media |
Additionally, the master server needs to open the following ports for nodes:
6380/TCP— Redis (cluster sync)8080/TCP— TgoRTC Server (Webhook callback)
Configuration Files
The deployment script automatically generates livekit.yaml. Key configuration:
keys:
prodkey: <secret>
redis:
address: <MASTER_SERVER_IP>:6380
password: <REDIS_PASSWORD>
db: 0
webhook:
api_key: prodkey
urls:
- http://<TGORTC_ADDRESS>/api/v1/webhooks/livekit
FAQ
Q1: LiveKit node cannot connect to Redis?
- Ensure master server firewall allows port
6380 - Ensure cloud security group allows node IP access
Q2: Rooms not syncing after node deployment?
- Check if Redis connection is normal
- Ensure all nodes use the same API Key and Secret
Q3: How to add more nodes?
Repeat Step 2 on a new server. After deployment, go back to Step 3 to update LIVEKIT_NODES on the master server and reload Nginx.