how can i spin off more workers in a container?
# ask-ai
n
how can i spin off more workers in a container?
t
Thanks for reaching out, Hwuiwon. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you spin off more workers in a container, you can deploy multiple instances of the worker process. Each container runs one worker instance, and LiveKit will automatically load-balance jobs across all available workers. Here’s a friendly guide on how you can do this: • Deploy Workers in Containers: Consider using orchestration tools like Kubernetes or Docker Swarm to easily scale the number of containers. Each container should run one worker process. • Environment Variables: Make sure each container has the necessary variables like
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
set up properly. • Autoscaling: You can scale based on CPU or memory usage. For example, 4 CPU cores can typically handle about 25 voice agents. • Graceful Shutdown: It’s a good idea to configure a grace period (like 10+ minutes) to allow active jobs to finish smoothly when shutting down workers. Keep in mind, workers are stateless and connect outbound to the LiveKit server via WebSocket. You also have the flexibility to customize worker behavior using parameters like
worker_type
,
load_threshold
, and
num_idle_processes
to fit specific job types or resource needs. If you’d like, I’m here to help with any further details or assist you through the implementation process—just let me know! Sources: Deployment and scaling | LiveKit Docs | Deploying to custom environments | LiveKit Docs | examples/avatar_agents/audio_wave/dispatcher.py | Worker options | LiveKit Docs