How does livekit prevent cold start
# ask-ai
v
How does livekit prevent cold start
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 explain how LiveKit prevents cold starts and what you can do to keep startup latency low. What LiveKit uses to prevent cold start • Prewarming: LiveKit runs a
prewarm
(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 Documentation
v
How does pricing work
t
Thanks — I’ll explain how LiveKit pricing works and what affects your bill. High-level model • LiveKit uses a usage-based pricing model focused on the resources your application consumes: connection minutes, downstream bandwidth, and transcode (transcoding) minutes. • There are also self-serve plan tiers that include monthly allowances and additional features. Primary cost components • Connection minutes: You are charged for the time participants are connected to LiveKit servers. This starts at $0.0005 per minute and scales down with higher volume. Standard human participants and AI agents are billed for connection minutes. Ingress, egress, and SIP participants are not charged connection minutes (they may have other charges). • Downstream bandwidth: You are charged for data sent from LiveKit servers to participants (downstream). Upstream bandwidth (data sent to LiveKit) is free. Bandwidth pricing starts at $0.12 per GB and decreases with higher usage; total bandwidth cost depends on bitrate, session duration, and number of viewers. • Transcoding minutes: Charged when LiveKit performs transcoding for ingress/egress workflows (for example, bringing in external streams or exporting recordings). WHIP-based ingresses and simple track egresses typically do not require transcoding. Transcoding is billed per minute the ingress/egress runs, or per participant minute for composite layouts. Plans and included allowances • Build (free): Intended for development/testing and includes free connection minutes, bandwidth credits, inference credits, and observability tools. • Ship ($50/mo): Adds production features like team collaboration and email support plus higher limits. • Scale ($500/mo): Adds advanced features (role-based access, metrics export, region pinning) and discounted inference. • Enterprise (custom): Tailored plans with volume discounts, SLAs, SSO, and dedicated support. Each paid plan includes monthly allotments (agent sessions, telephony minutes, inference credits). Overage pricing applies once allowances are exceeded. Examples & pricing factors to consider • Viewer count and bitrate directly drive downstream bandwidth costs (higher resolution/codec = more bandwidth). • Using more efficient codecs (VP9, AV1) reduces bandwidth and thus cost; example livestream estimates show meaningful savings moving from H.264 → VP9/AV1. • AI agent sessions and WebRTC-connected agents have per-minute costs (for example, web-connected agent session cost and WebRTC connection cost are called out as per-minute components). • Transcoding is a significant factor for workflows that require composite layouts, multi-bitrate outputs, or protocol conversion. How to estimate your costs • Use the LiveKit Pricing Calculator: https://livekit.io/pricing • Monitor usage in your project dashboard to track connection minutes, downstream GB, and transcode minutes. • Consider codec choices, target bitrates, expected session length, and expected concurrent viewers to model bandwidth and transcoding needs. If you want, I can: • Run a quick cost estimate with your expected numbers (concurrent viewers, session length, target bitrate, number of participants). • Recommend which plan (Build / Ship / Scale) seems best for your stage and expected usage. Which would you like me to help with? Sources: Towards a future-aligned pricing model | Understanding and Estimating Pricing for Video Conference and Livestream Us... | Pricing | LiveKit | A Tale of Two Protocols: WebRTC vs. HLS for Live Streaming
v
How does cold start pricing work
t
Thanks — I’ll explain how cold-starts affect billing and what costs (if any) you should expect in LiveKit. Short answer • LiveKit does not charge a separate “cold start” fee. There’s no per-cold-start charge. How cold-start behavior maps to costs • Cold-start prevention (keeping workers pre-warmed and ready) is a feature included on paid plans (Ship and Scale). It is not billed separately — it’s included as part of those plans. • Prewarming code you run in your own agent processes (for example, a
prewarm
/
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? | LiveKit
v
How does livekit handle request spike with pre warmed
t
Thanks — I’ll explain how LiveKit handles request spikes when you use pre-warmed workers and what you can do to keep latency low during surges. How LiveKit handles spikes with pre-warmed workers • Pre-warmed worker pool: Paid plans keep a pool of workers pre-initialized and ready to accept sessions. These warm workers let incoming requests be served immediately without cold-start delays. • Elastic scaling: When demand rises beyond the warm pool, LiveKit automatically launches additional agent instances to handle extra load. New instances are added until capacity meets demand. • Load-aware scheduling: Sessions are dispatched based on effective load (CPU/GPU, memory, network health, and locality), not just connection counts. This balances work across workers so no single worker becomes a bottleneck. • Multiple workers per agent name: You can run several workers for the same
agent_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 | DeepWiki
v
Is there a maximum limit of pre warmed instances
t
Thanks — I’ll answer your question about maximum limits for pre-warmed instances and how those limits depend on your plan. Short answer • Yes — there are limits on how many pre-warmed (always-on) agent instances you can have, and those limits depend on your pricing plan. What the limits look like by plan • Build & Ship: Up to 600 concurrent agent sessions. Ship also allows multiple agent deployments (see next section). • Scale: Typically supports up to 600 concurrent agent sessions, with the option to request higher concurrency via the dashboard. • Enterprise: Supports unlimited concurrent agent sessions with custom capacity provisions available in your contract. Agent deployment / pre-warmed deployment limits • Build: 1 agent deployment (limited slots for keeping agents pre-warmed). • Ship: 4 agent deployments. • Scale: 4 agent deployments (you can request more capacity). • Enterprise: Unlimited agent deployments with custom provisioning available. Why limits exist • Pre-warmed agents consume compute continuously, so limits control baseline cost and ensure predictable capacity and quality of service. • If you need more always-on capacity than your plan allows, Scale and Enterprise offer options to increase those limits. What you can do if you need more pre-warmed capacity • On Scale, request higher concurrency or additional deployment slots through your project settings/dashboard. • On Enterprise, arrange custom capacity and dedicated always-on workers via your contract for guaranteed higher limits. • Use a mix of pre-warmed workers and autoscaling for burst traffic to reduce the number of strictly always-on instances while still keeping low-latency performance. If you want, I can: • Estimate how many pre-warmed workers you’ll need based on expected concurrent sessions and average session length. • Walk through how to request higher limits from your dashboard (for Scale) or outline what information Enterprise teams typically need when requesting custom capacity. Which would be most helpful? Sources: Pricing | LiveKit | Can you increase agent deployment limits? | LiveKit | How much can LiveKit scale? | LiveKit | Deploy and scale agents on LiveKit Cloud