Thanks — this is really helpful context. I’ll address your three asks (AWS scaling, LiveKit + pipeline scaling, and likely bottlenecks) and give targeted, practical recommendations you can act on.
Acknowledgement
• You’re running everything on one c7i.4xlarge and start failing ~10–25 concurrent calls. Your load test shows CPU spikes and the latency breakdown you shared (LLM ~625ms, TTS ~750ms, E2E ~1.6s avg, ~3.1s p95).
Recommendations — AWS infra and cost-conscious scaling
1. Move off a single large EC2 to a multi-node containerized setup:
â—¦ Containerize agents and app (FastAPI + agent worker) and run on ECS (Fargate) or EKS. Both support autoscaling; ECS Fargate reduces infra ops, EKS gives more control and cheaper spot instance options.
◦ Use AWS Auto Scaling (CPU-based) with sensible targets (scale up around 50–70% CPU) and short cool-downs for voice bursts.
1. Use horizontal scaling for LiveKit (don’t rely on a single node):
â—¦ Deploy multiple LiveKit server instances behind a Network Load Balancer for signaling/WSS.
â—¦ Make sure required ports (TCP 443, UDP for media) are open and health checks are configured.
◦ Run multiple agent workers across nodes — LiveKit’s agent model expects one job per worker and scales horizontally.
1. Cost saving options:
â—¦ Use spot instances for non-critical inference or agent nodes (with fallbacks).
â—¦ Right-size instance types per role: smaller many-worker nodes for agents, fewer larger nodes for heavy LLM/TTS inference if you self-host models.
â—¦ Consider LiveKit Cloud if operational cost/time is higher than per-session fees.
Scaling LiveKit + real-time pipelines
1. Treat agents as stateful jobs and scale horizontally:
â—¦ Each agent process handles a session; add nodes to increase concurrent sessions.
â—¦ Use Kubernetes/ECS task autoscaling tied to queue depth or CPU.
1. Separate concerns into services:
â—¦ Signaling/turn/media: LiveKit servers (scale horizontally).
â—¦ Agent logic: containerized workers (scale to session load).
◦ AI inference (STT/LLM/TTS): dedicated inference service(s) — can be shared across sessions or per-session depending on latency needs.
1. Reduce latency with streaming + co-location:
â—¦ Use streaming STT and streaming LLM responses to start TTS sooner and shave RTT.
â—¦ Co-locate inference (or use same AZ) as LiveKit nodes to reduce network hops.
â—¦ For TTS, stream audio generation if supported to avoid blocking until full output is ready.
Known bottlenecks and targeted mitigations
1. CPU-bound voice processing:
â—¦ VAD, STT pre/post processing, codecs, and TTS can spike CPU. Move heavy stages to dedicated worker nodes and autoscale on CPU.
â—¦ Avoid burst-throttled instance families (t-class).
1. LLM and TTS network/TTFB:
◦ Your LLM & TTS TTFBs (~600–750ms) are the primary latency contributors. Options:
▪︎ Use lower-latency LLMs or smaller models for interactive flows.
▪︎ Use streaming APIs so you can pipeline LLM -> partial TTS.
▪︎ Cache responses or pre-generate common replies.
1. Redis or shared state contention:
â—¦ Ensure Redis (ElastiCache) has enough capacity and is in same AZ/region. Monitor ops/sec and latency.
â—¦ Use Redis connection pooling and sharding if needed.
1. Single-node LiveKit/agent dispatcher limits:
◦ An agent scheduler will retry failed assignments; don’t overload a single LiveKit/agent host — scale out.
Quick action plan (first 2–4 weeks)
1. Containerize agent + FastAPI and deploy to ECS/EKS with CPU autoscaling.
2. Split inference off to dedicated nodes/services; enable streaming for STT/LLM/TTS.
3. Run a multi-node LiveKit deployment behind an NLB with health checks.
4. Load-test again, monitor CPU, network, Redis latency, and per-stage TTFB; iterate thresholds and instance sizes.
5. If ops overhead is too high, evaluate LiveKit Cloud to remove infra scaling burden.
If you want, tell me:
• Whether you prefer ECS (lower ops) or EKS (more control/spot usage),
• If you self-host LLM/TTS or use external APIs,
and I’ll give a concrete node-sizing and autoscaling configuration (CPU thresholds, replica counts, and cost-optimized instance recommendations).
Sources:
Self-hosted deployments | LiveKit Documentation |
Deploy and scale agents on LiveKit Cloud | LiveKit |
Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit |
Running LiveKit on AWS | LiveKit |
Running LiveKit on AWS | LiveKit, with interactive elements