Deployment / Distributed Set-up
LiveKit is architected to be distributed, with homogeneous instances running across many servers. In distributed mode, Redis is required as shared data store and message bus.
When Redis is configured, LiveKit automatically switches to a distributed setup by using Redis for room data as well as a message bus. In this mode, each node periodically reports their stats to Redis; this enables them to be aware of the entire cluster and make routing decisions based on availability and load. We recommend this setup for a redundant deployment.
When a new room is created, the node that received this request is able to choose an available node from the cluster to host the room.
When a client establishes a signal connection to LiveKit, it creates a persistent WebSocket connection with one of the instances. That instance will then acts as a signaling bridge, proxying messages between the node where the room is hosted and the client.
In a multi-node setup, LiveKit can support a large number of concurrent rooms. However, there are limits to the number of participants in a room since, for now, a room must fit on a single node.
It's simple to scale up instances, but what about scaling down? Terminating an instance while it's hosting active sessions would be extremely disruptive to the end user.
LiveKit solves this problem by providing connection draining natively. When it receives a request to terminate (via
SIGQUIT) and there are participants currently connected, it will put itself into draining mode. While draining, the instance would:
When all participants have disconnected, the server will complete draining and shut down.
It's possible to deploy LiveKit to multiple data centers, allowing users located in different regions to connect to a server that's closest to them.
LiveKit supports this via a region-aware, load aware node selector. It's designed to be used in conjunction with region-aware load balancing of the signal connection.
Here's how it works:
node_selector:kind: regionawaresysload_limit: 0.5# list of regions and their lat/lon coordinatesregions:- name: us-west-2lat: 37.64046607830567lon: -120.88026233189062- name: us-eastlat: 40.68914362140307lon: -74.04445748616385