Skip to main content

Multi-Node Setup

Scale your music bot across multiple Lavalink nodes for improved performance, load distribution, and high availability.

Basic Multi-Node Configuration

Simple Multi-Node Setup

Load Balancing Strategies

AquaLink provides several built-in load balancing strategies that can be set using the loadBalancer option in the Aqua constructor.
  • leastLoad (default): Selects the node with the lowest overall load, calculated based on CPU usage, memory, playing players, and REST API calls. This is generally the best option for most use cases.
  • leastRest: Selects the node with the fewest REST API calls.
  • random: Selects a random connected node.

Advanced Node Configuration

You can add custom properties to your node configurations for use in advanced, custom logic (like a custom node selector). The library itself will ignore these extra properties.

Example with Custom Properties

Node Selection Logic

Custom Node Selector Example

While AquaLink has a built-in node selector based on the loadBalancer option, you can implement your own logic to choose nodes for specific players.

Player Migration

Seamless Migration Example

This example shows how you could manually migrate a player from one node to another, preserving its state.

Node Monitoring

Health Monitoring Example

Here is an example of a class that periodically checks the health of all connected nodes.