victorious-room-41442
02/18/2026, 8:01 AMtall-airline-16756
02/18/2026, 8:01 AMtall-airline-16756
02/18/2026, 8:01 AMprewarm (or setup_fnc in Python) step on worker processes before they receive agent jobs. Use prewarm to load heavy resources (for example, ML models or VAD libraries) once so they’re ready when a session starts.
• Keeping resources in worker state: Load reusable components during prewarm and store them in proc.userdata (or equivalent worker-local storage). That avoids reloading on each session and reduces per-session latency.
• Cold-start prevention for deployments: Workers can be kept pre-warmed (i.e., started and initialized ahead of load) so you get deterministic, low startup latency in production.
How to apply this in practice
1. Implement a prewarm or setup_fnc on your worker to:
◦ Load model files (e.g., Silero VAD) and initialize any heavy libraries.
◦ Cache those objects on proc.userdata.
1. In your session/job handler, reuse the cached objects from proc.userdata instead of reinitializing them.
2. Configure your deployment to maintain a pool of pre-warmed workers if you need consistent low-latency responses under variable load.
If you’d like, I can:
• Show a short example of how to load and cache a model in prewarm.
• Recommend deployment settings for worker pool size based on expected concurrency.
Which would help you most?
Sources: External data and RAG | LiveKit Documentation | Simple Content Filter | LiveKit Documentation | Gemini Realtime Agent with Live Vision | LiveKit Documentation | Server options | LiveKit Documentation | Silero VAD plugin | LiveKit Documentationvictorious-room-41442
02/18/2026, 8:02 AMtall-airline-16756
02/18/2026, 8:02 AMvictorious-room-41442
02/18/2026, 8:02 AMtall-airline-16756
02/18/2026, 8:03 AMprewarm / setup_fnc that loads models into proc.userdata) does not incur an extra LiveKit cold-start fee. Any cost is the normal compute/network usage that your agents consume while running (these are covered by standard agent/session pricing and your hosting/compute costs).
• Agent session minutes are billed the same whether an agent was pre-warmed or experienced a cold start. Agent session costs (the per-minute agent rate) include hosting, networking, and observability, so cold starts do not add a separate line item.
When extra costs can appear
• If you keep more workers running to avoid cold starts (an always-on pool or dedicated capacity), you will incur the normal cost of those worker instances (your plan’s agent/session minutes or your own cloud compute costs) because they stay active longer.
• Enterprise customers can request dedicated capacity or always-on workers in contracts tailored to guarantee latency; those arrangements are handled in the custom enterprise pricing rather than as per-cold-start charges.
If helpful, I can:
• Show a short example of using `prewarm`/`setup_fnc` to load a model and store it in proc.userdata.
• Help estimate the incremental cost of keeping N pre-warmed workers running for your expected concurrency (tell me expected concurrent agents and average session length).
Which would you like me to walk through?
Sources: Pricing | LiveKit | Server options | LiveKit Documentation | Deploy and scale agents on LiveKit Cloud | How much can LiveKit scale? | LiveKitvictorious-room-41442
02/18/2026, 8:04 AMtall-airline-16756
02/18/2026, 8:05 AMagent_name. Jobs are round‑robin assigned across them for redundancy and higher throughput.
• Graceful draining and session preservation: During scaling or deployments, LiveKit drains workers without dropping active sessions so user experience stays intact through spikes and updates.
What you control to improve spike handling
• Size your warm pool: Keep enough pre-warmed workers for your expected burst level. More warm workers = fewer autoscale launches and lower peak latency.
• Autoscaling thresholds: For self-hosted setups, scale proactively — trigger new workers at a lower utilization threshold (e.g., 0.5) rather than waiting for high load (e.g., 0.7).
• Reuse heavy resources via prewarm: Use prewarm / setup_fnc to load models and cache them in worker-local state (e.g., proc.userdata). That keeps newly created workers useful immediately.
• Run multiple workers/regions: Spread workers across regions and run multiple instances per agent to reduce localized hotspots and improve failover.
• Monitor effective load metrics: Track CPU/GPU, memory, and network to tune autoscaling and warm-pool size before spikes occur.
When spikes still cause latency
• The remaining latency during extreme spikes typically comes from time to spin up new instances or from external resource limits (cloud VM provisioning, model download times). Mitigation options:
◦ Increase pre-warmed capacity for expected peak periods.
◦ Use smaller, faster-to-start worker types for burst capacity.
◦ Cache large model files in the worker image or use local persistent storage so new workers initialize faster.
If you want, I can:
• Help estimate how many pre-warmed workers you should keep based on expected concurrency and average session length.
• Show an example prewarm pattern that caches a model into proc.userdata for immediate reuse.
Which would be most helpful?
Sources: Deploy and scale agents on LiveKit Cloud | Self-hosted deployments | LiveKit Documentation | Agents Framework | livekit/livekit_composite | DeepWikivictorious-room-41442
02/18/2026, 8:06 AMtall-airline-16756
02/18/2026, 8:06 AM