Skip to main content

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:

InfoFieldDescription
Master server IP-Public IP address
Redis passwordREDIS_PASSWORDRequired for node to connect Redis
LiveKit API KeyLIVEKIT_API_KEYMust be the same across all nodes
LiveKit API SecretLIVEKIT_API_SECRETMust be the same across all nodes

Step 2: Deploy Node

Run the one-click deployment script on a new server.

Required Parameters

ParameterDescription
--master-ipMaster server IP address
--redis-passwordRedis password (same as master server)
--livekit-keyLiveKit API Key (same as master server)
--livekit-secretLiveKit API Secret (same as master server)

Optional Parameters

ParameterDescriptionDefault
--cnUse China mirror acceleration-
--tgortc-urlTgoRTC Server address (for Webhook callback)http://<master-ip>:8080
--node-ipThis node's public IPAuto-detected
--redis-portRedis port6380
--dirDeployment 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>"
Using a Domain

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):

PortProtocolPurpose
7880TCPLiveKit HTTP/WebSocket
7881TCPLiveKit RTC TCP
3478UDPTURN UDP
5349TCPTURN TLS
50000-50100UDPWebRTC 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.