red-army-65692
12/19/2025, 4:12 AMtall-airline-16756
12/19/2025, 4:12 AMtall-airline-16756
12/19/2025, 4:13 AMred-army-65692
12/19/2025, 4:16 AMtall-airline-16756
12/19/2025, 4:16 AMred-army-65692
12/19/2025, 4:17 AMtall-airline-16756
12/19/2025, 4:18 AMred-army-65692
12/19/2025, 4:19 AMtall-airline-16756
12/19/2025, 4:19 AMred-army-65692
12/19/2025, 4:21 AMtall-airline-16756
12/19/2025, 4:21 AMproc.userdata instead of loading per session.
3. Optionally pre‑initialize external clients (STT/TTS/LLM SDKs) and keep connections/auth ready in the same setup function.
4. Enable preemptive generation or instant connect to reduce perceived latency.
Minimal Python example
from livekit.agents import AgentServer, JobProcess, JobContext
from livekit.plugins import silero, inference
def prewarm(proc: JobProcess):
# load VAD into process memory once
proc.userdata["vad"] = silero.VAD.load()
# initialize STT/TTS/LLM clients if needed
proc.userdata["stt_client"] = inference.STTClient(api_key="...") # example
proc.userdata["tts_client"] = inference.TTSClient(api_key="...")
server = AgentServer()
server.setup_fnc = prewarm
@server.rtc_session()
async def entrypoint(ctx: JobContext):
vad = ctx.proc.userdata["vad"]
stt = ctx.proc.userdata["stt_client"]
tts = ctx.proc.userdata["tts_client"]
session = AgentSession(
vad=vad,
stt=stt,
tts=tts,
preemptive_generation=True,
)
await session.start(agent=MyAgent(), room=ctx.room)
await ctx.connect()
Additional recommendations
• Prewarm each worker process (the setup runs per process) so all workers are ready for first calls.
• Keep long‑lived SDK clients or HTTP sessions to avoid reconnect overhead.
• Load only what you need (VAD is highest impact to prewarm; STT/TTS benefit if local models are used).
• Monitor memory and startup time to ensure prewarming fits your deployment (each worker will hold the models in RAM).
• Combine with instance sizing (e.g., c6g.16xlarge) and separating LiveKit vs agent processes to avoid resource contention.
Would you like a tailored snippet for your exact stack (Python package names, container init, or Kubernetes InitContainers/Helm hooks)?
Sources: MCP Agent | LiveKit docs | Agent server options | LiveKit docs | TTS Comparison | LiveKit docs | VAD Metrics | LiveKit docs | Uninterruptable Agent | LiveKit docsred-army-65692
12/19/2025, 4:23 AMtall-airline-16756
12/19/2025, 4:23 AMlivekit_egress_available or custom metric).
Operational checks to run now
• Check which processes use CPU during recording (top, htop, or container pids); Chrome and GStreamer will be top consumers.
• Inspect CloudWatch/Prometheus for CPU, CPUCreditBalance (if using T instances), and per‑pod CPU usage.
• Correlate spikes with start of composite jobs to confirm recording is the culprit.
If you want, I can:
• Recommend instance sizes and expected concurrency for your recording load, or
• Provide a Kubernetes HPA example and an egress separation checklist.
Which would you prefer?
Sources: Universal Egress | Composite and web recordings | LiveKit docs | Self-hosting the Egress Service | LiveKit docs | Self-hosting the Ingress Service | LiveKit docs | RoomComposite Egress | LiveKit Docsred-army-65692
12/19/2025, 4:27 AMtall-airline-16756
12/19/2025, 4:27 AM