Recommend infra for self hosting livekit
# ask-ai
v
Recommend infra for self hosting livekit
t
Thanks for reaching out, Justin. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’ll recommend infrastructure for self‑hosting LiveKit and cover options depending on scale and use (voice-only vs. video, small vs. large deployment). Quick question before full details: do you plan to run on cloud VMs (AWS/GCP/DO) or on your own bare‑metal/colocated servers, and do you expect mostly audio or video (and roughly how many concurrent participants/rooms)? That helps me tailor CPU/GPU and scaling guidance. Below are general recommendations you can use now. 1) Server sizing (per machine) • Small / dev / proof of concept ◦ 2–4 vCPU, 4–8 GB RAM, 10 GB disk ◦ Good for low‑traffic testing, small rooms, or audio‑only. • Production voice-focused ◦ 4+ vCPU, 8–16 GB RAM per agent/server ◦ Provides stable performance for many concurrent audio sessions. • Production video or heavy processing ◦ 8+ vCPU, 16–64 GB RAM depending on concurrent video streams, room size, and whether you do transcoding/recording. ◦ If you need hardware video encode/decode, use NVIDIA GPUs for accelerated encoding. 2) GPU (optional) • Use GPUs when you need hardware‑accelerated video encoding/decoding or GPU‑based processing. • NVIDIA GPUs integrate with common encoders (e.g., nvh264enc) for lower CPU usage on heavy video workloads. 3) OS, containers, and orchestration • Run on a modern Linux server (Ubuntu Server is common). • Use Docker for containerized deployment; for production, run LiveKit via Kubernetes with Helm charts for reliability and autoscaling. • For cloud VMs, cloud‑init templates simplify provisioning. 4) Networking requirements • Open TCP ports: 443 (HTTPS/WSS), 7880, 7881 (control/HTTP as needed). Keep SSH (22) locked down. • Open UDP ports used for WebRTC media (e.g., default 7882) to allow direct media flows and ICE candidates. • Use a valid SSL certificate (Let’s Encrypt, cloud provider, or commercial CA) for secure WSS/HTTPS. 5) Domain & DNS • Point a domain A record to your server/public load balancer and use that domain in certificates and client connection URLs. 6) Storage • Ephemeral storage: 10+ GB per agent for container layers and temp files. • Persistent storage: only required if you record/egress sessions to disk. Use S3/GCS or local persistent volumes depending on retention needs. 7) Load balancing & scaling • LiveKit distributes work across agent servers; scale agent workers horizontally to meet demand. • On Kubernetes, use Horizontal Pod Autoscaler (HPA) and tune readiness/termination grace periods so in‑flight sessions complete on rollouts. • For VM deployments, use autoscaling groups or manual scaling policies. 8) High‑availability & resilience • Deploy multiple LiveKit servers/agents across availability zones for fault tolerance. • Use health checks and automatic restart policies for containers. • Monitor CPU, network bandwidth, and socket counts to detect hotspots early. 9) Example deployment flow (high level) 1. Provision VM(s) or Kubernetes cluster and secure networking. 2. Obtain SSL cert and set DNS for your domain. 3. Deploy LiveKit server and agent containers (Docker or Helm). 4. Open necessary ports and test connectivity with a connection test tool. 5. Scale agents based on observed CPU/network usage. If you share: • target platform (AWS/GCP/VMs/bare metal), • expected concurrent participants or rooms, • whether you’ll do recordings/transcoding or need GPU acceleration, I’ll translate that into a recommended instance type (e.g., EC2 family), autoscaling rules, and a concrete node sizing plan. Sources: Self-hosted deployments | LiveKit Documentation | Yeah, but can it run DOOM? | Running LiveKit on AWS