powerful-librarian-81681
02/13/2026, 11:03 AMtall-airline-16756
02/13/2026, 11:03 AMtall-airline-16756
02/13/2026, 11:03 AMpowerful-librarian-81681
02/13/2026, 11:06 AMtall-airline-16756
02/13/2026, 11:06 AMpowerful-librarian-81681
02/13/2026, 11:08 AMtall-airline-16756
02/13/2026, 11:08 AMawsvpc
◦ CPU/Memory: start with 2048 CPU units (2 vCPU) and 4096 MiB for PoC; increase for load tests
◦ Container port mappings:
▪︎ TCP: API/WS port (e.g., 7880)
▪︎ UDP: media port range (e.g., 40000–40100) — map these as container ports in the task and ensure NLB forwards UDP
◦ Environment variables / secrets:
▪︎ LIVEKIT_API_KEY, LIVEKIT_API_SECRET (use Secrets Manager)
▪︎ LIVEKIT_UDP_PORT_MIN, LIVEKIT_UDP_PORT_MAX (match your chosen range)
▪︎ LIVEKIT_ANNOUNCED_IP / LIVEKIT_ANNOUNCED_DOMAIN (public NLB DNS or IP)
▪︎ TURN URLs / credentials
• Service:
◦ Attach to NLB target groups (one for TCP/WS, one for UDP range)
◦ Health check: HTTP health endpoint of LiveKit
◦ Autoscaling: target custom metric or CloudWatch metric (see above)
If you’d like, I can produce:
• A sample ECS task definition JSON snippet and abbreviated CloudFormation outline for the NLB + Fargate service (UDP + TCP listeners).
• A short list of exact LiveKit environment variables to configure for UDP port ranges and announced IPs.
• A recommended set of metrics and CloudWatch alarms to feed autoscaling.
Next question
• Do you already have a TURN server (self-hosted or hosted)? If not, do you want a sample coturn setup and configuration to use with LiveKit?
Tell me which of the three deliverables above you’d like next (task definition snippet, LiveKit env var list, or metrics/autoscaling rules), and confirm whether you have TURN — I’ll generate the concrete artifacts.powerful-librarian-81681
02/13/2026, 11:08 AMtall-airline-16756
02/13/2026, 11:09 AMawsvpc
• Container port mappings:
◦ TCP 7880
◦ UDP 40000–40100 (expose as container ports)
• Environment variables (example names):
◦ LIVEKIT_API_KEY / LIVEKIT_API_SECRET (store in Secrets Manager)
◦ LIVEKIT_PORT (or equivalent) for API
◦ LIVEKIT_UDP_PORT_MIN=40000
◦ LIVEKIT_UDP_PORT_MAX=40100
◦ LIVEKIT_ANNOUNCED_IP or LIVEKIT_ANNOUNCED_DOMAIN = NLB public IP or DNS
• Health check: HTTP health endpoint of LiveKit
3) Security groups & subnets
• Place tasks in private subnets with NAT for outbound (or public subnets if you prefer tasks with public IPs).
• Security groups: allow inbound TCP 7880 and UDP 40000–40100 from 0.0.0.0/0 (or restrict to your client networks for PoC).
• Ensure NLB can reach those ports and ENIs.
4) Announced IP / ICE candidates
• Configure LiveKit to advertise the NLB’s public DNS/IP so clients receive reachable ICE candidates.
• Verify ICE candidates in client logs during test connections.
5) Autoscaling & metrics (practical approach)
• Export a custom metric: active peer count per task or aggregated across tasks. If LiveKit exposes metrics, use a sidecar or script to push the peer count to CloudWatch.
• Autoscaling policy:
◦ Scale-out: when aggregated active peers > X per task (e.g., scale to keep ~200–300 peers per task as a starting point)
◦ Scale-in: use conservative cooldown (e.g., 10–15 minutes) to avoid dropping active sessions
• Start with a minimum of 0 tasks if you accept cold starts; set minimum >0 if you need lower latency for spikes.
Sizing heuristic for ~1000 concurrent users
• Start with a target of ~200–300 peers per 4 vCPU / 8–16 GB task as a hypothesis.
• That suggests 4–5 tasks to handle 1000 peers if the per-task capacity matches the hypothesis.
• Run load tests and measure CPU, memory, and packet loss to refine per-task capacity — increase tasks rather than single large tasks.
Cost-conscious tips
• Allow scaling to zero if cold starts are acceptable; otherwise keep a small baseline.
• Use smaller tasks for better granular scaling (easier to add capacity for spikes).
• Compare Fargate costs vs small EC2 spot-backed ASG for sustained baseline — Fargate is operationally simpler but can be pricier at scale.
Testing checklist (short)
1. Deploy 1 task behind NLB; verify clients can connect, gather ICE candidates, and see media (test from different networks).
2. Instrument LiveKit to export peer counts to CloudWatch.
3. Run load tests, ramp to 1000 connections, monitor CPU, memory, packet loss, connection time, and ICE failures.
4. Test scaling: simulate bursts and ensure new tasks register and accept traffic via NLB.
5. Test task termination while clients are connected to observe reconnect behavior and user impact.
Limitations & risks to watch
• No official documentation/testing for Fargate — you may encounter UDP limitations or unexpected NAT/ENI behaviors.
• Without TURN, some clients (especially behind symmetric NATs) will fail to establish media.
• LiveKit session continuity may break on task termination; client reconnect/resume handling is required.
If you’d like next, I can provide either:
• A sample ECS task definition JSON snippet + minimal CloudFormation outline for the NLB and Fargate service (UDP+TCP), or
• A focused list of exact LiveKit environment variables to set for PoC (UDP port ranges, announced IP, API keys), or
• A short script example that pushes LiveKit peer counts to CloudWatch for autoscaling.
Which of those three would you like next?